Hi there,
I am about to setup a lab environment for openhab learning, development and staging. The configuration consists of 3 Raspberry Pi3B+ with Raspbian Stretch.
RPi1: General Purpose System
RPi2: Print server and Mosquitto-Broker
RPi3: Openhab 2.4
Now I struggle to implement a simple switch, that shall be switched by MQTT-messages. Some help would be appreciated.
I’ve already installed Mosquitto on all three Raspis. I’ve tested the Broker functionality of RPi2 successfully: Messages can be published by RPi1 to Broker RPi2 and can be subsribed by RPi3 from Broker RPi2. Everything works neatly.
Now it comes to Openhab:
I’ve installed the MQTT binding and created a thing…
Bridge mqtt:broker:Pi2MqttBroker [ host="192.168.12.1", secure=false ]
{
Thing topic W88Lab {
Channels:
Type switch : MqSw1 "Mqtt Lab Switch 1" [ stateTopic="MqSw1/enabled", commandTopic="MqSw1/set", on="ON", off="OFF"]
}
}
...
and created a corresponding item:
```csv
Switch W88LabMqSw1 "MQTT Lab Sw 1" { channel="mqtt:topic:Pi2MqttBroker:W88Lab:MqSw1" }
Furthermore I’ve diplayed this switch in a sitemap:
sitemap W88Lab label="SmartW88 Labor"
{
Frame label="MQTT Labor"{
Switch item=W88LabMqSw1 label="W88LabMqSw1"
}
}
The openhab.log shows, that thing and item are installed and the MQTT bridge has established a client session at the broker (the broker protocoll confirmed that). In the Papier-UI the things are online - everything looks fine, so far.
My expectation was, that openhab now is listening on inbound MQTT-Messages and I can controll my new MQTT-Switch from RPi1 by pubishing:
mosquitto_pub -h 192.168.12.1 -t W88Lab/MqSw1/set -m ON
Unfortuately nada. The switch in my sitemap remains OFF.
Where I am wrong?