Stap 2: Installeer MQTT op uw openhab pi
Dit is een voortzetting van mijn post hier
Een SSH-verbinding gebruikt voor deze installatie. Er zijn andere manieren aan opstelling MQTT met OpenHAB, maar deze is compatibel met ESP knooppunt MCU.
sudo apt-get update
sudo apt-get install build-essential python quilt devscripts python-setuptools python3
sudo apt-get install libssl-dev libwrap0-dev libc-ares-dev
sudo wget http://mosquitto.org/files/source/mosquitto-1.4.1.tar.gz
tar zxvf mosquitto-1.4.1.tar.gz
cd mosquitto-1.4.1
make all
sudo make install
sudo ldconfig
Nu kunt u mosquitto proberen:
Twee terminal vensters openen. In de eerste terminal uitvoeren
mosquitto_sub -h 127.0.0.1 -t myTopic
In de tweede terminal uitvoeren
mosquitto_pub -h 127.0.0.1 -t myTopic -m "My first message"
MQTT Binding met OpenHAb inschakelen
sudo nano /opt/openhab/configurations/openhab.cfg
Kijk voor MQTT vervoer en de URL naar de MQTT inschakelen "makelaar" en de "Gebruikers-id te verifiëren met de makelaar" door het verwijderen van het hekje aan het begin van de regel.
################################# MQTT Transport ######################################<br># # Define your MQTT broker connections here for use in the MQTT Binding or MQTT # Persistence bundles. Replace <broker> with a id you choose. #</broker> # URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883 mqtt:mymosquitto.url=tcp://localhost:1883<br># Optional. Client id (max 23 chars) to use when connecting to the broker. # If not provided a default one is generated. # mqtt:mymosquitto.clientId=openHAB<br># Optional. User id to authenticate with the broker. mqtt:mymosquitto.retain=true<br># Optional. Password to authenticate with the broker. #mqtt:<broker>.pwd= <password></password></broker># Optional. Set the quality of service level for sending messages to this broker. # Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2 # (Deliver exactly once). Defaults to 0. #mqtt:<broker>.qos=<qos></qos></broker><br># Optional. True or false. Defines if the broker should retain the messages sent to # it. Defaults to false. #mqtt:<broker>.retain=<retain></retain></broker><br># Optional. True or false. Defines if messages are published asynchronously or # synchronously. Defaults to true. #mqtt:<broker>.async=<async></async></broker><br># Optional. Defines the last will and testament that is sent when this client goes offline # Format: topic:message:qos:retained #mqtt:<broker>.lwt=<last will="" definition=""></last></broker>