Paso 2: Instale MQTT en su pi openhab
Esto es una continuación de mi post aquí
Utilice una conexión SSH para esta configuración. Hay otras formas de configurar MQTT con OpenHAB, pero este es compatible con ESP nodo 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
Ahora usted puede tratar de mosquitto:
Abrir dos ventanas de terminal. En el primer terminal que ejecute
mosquitto_sub -h 127.0.0.1 -t myTopic
En la segunda terminal ejecutar
mosquitto_pub -h 127.0.0.1 -t myTopic -m "My first message"
Activa a MQTT enlace con OpenHAb
sudo nano /opt/openhab/configurations/openhab.cfg
Buscar transporte MQTT y activar "dirección URL para el MQTT corredor" y "Id de usuario para autenticar con el corredor" por quitar la marquita en el principio de la línea.
################################# 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>