This tutorial will show how to integrate the BLE gateway to OpenHAB3 leveraging the auto-discovery functionality. After this tutorial, you should see your Bluetooth Low Energy devices compatible with OpenMQTTGateway in OpenHAB3 without any file-based manual configuration.
Note that this tutorial is also available in OpenMQTTGateway documentation
Prerequisites
- OpenHAB 3.3 or higher
- MQTT broker installed with or without authentication
- A location defined in the “Model” section under “Settings”
IP address (if your broker is installed on the same server as OpenHAB)
The goal is to disable the IPv6 address of the broker server, so that the gateway can connect through IPv4.
- From the Administration click on Settings
- Click on Network Settings
- Click on Show Advanced
- Disable IPv6
- Click on Save
Note
If the broker is installed on another server you will also need to configure it with an IPv4 address.
Install the MQTT binding
- From the Administration click on Settings
- Click on Bindings
- Install the MQTT binding (you can search at the bottom right)
- Once installed click on Things under Settings
- Click on the + at the bottom right
- Click on MQTT Binding
- Click on MQTT broker
- Enter for the “Broker Hostname/IP” field, the IP address of your broker, if it is installed on the same server you can enter
localhost
- Click on “Show Advanced” if your broker has authentication activated, if not you can go to step 11
- Enter the broker credentials: username and password
- Click on Create Thing at the bottom, you should see your MQTT Broker in the Things list with the status “online”
Bravo👏, second step done! Now let’s add the Jinja transformation service.
Install Jinja Transformation
- From the Administration, click on Settings
- Click on Bindings
- Install Jinja Transformation (you can search at the bottom right)
Second step done!
Upload OpenMQTTGateway to an ESP32
Upload OpenMQTTGateway from the web by selecting esp32dev-ble-openhab
Or use another upload method from the Upload section.
Configure OpenMQTTGateway from the web portal
Or use another upload method from the Upload section that requires credentials before the build.
You should see the gateway connected to your broker by checking with an MQTT client like MQTT Explorer.
Adding the things
- From the Administration click on “Things” under “Settings”, you should see a number in the INBOX button
- Click on INBOX, you should see your BLE devices and the gateway
- Click on a device, a pop up “Add as Thing” should appear
- Rename it if you need, and click OK, repeat for each Thing discovered. The devices should appears as online progressively.
- Click on Model
- Select the location of where you want to create the Equipment
- Click on “Create Equipment from Thing”
- Click on Thing
- Select a Thing
- Rename your Equipment if you need
- Select the Channels
- Click on “Add to Model”
- Go to Model, if you unfold your location and Equipment you should be able to see values
Congratulation🎉! You were able to get data from your BLE sensors into OpenHAB. You can now add the others and use the data to build pages, leverage rules, and enjoy all the function of your Home Automation controller with BLE devices.
Commentaires
Enregistrer un commentaire