I’m trying to use the Homie convention with the MQTT binding and am having trouble with the items file I think.
I’m using a nodeMCU with the LightOnOff example from the Homie library.
I have installed mosquitto to my raspberry pi which is also running openhab.
I have used MQTT.fx and have confirmed that openhab is connecting to mosquitto as a client by stopping the openhab service and monitoring the number of clients connected to mosquitto.
I have also seen the number of clients increase or decrease when removing power from the nodeMCU (and the serial monitor shows it is connecting to mosquitto).
Having seen all of this I’m (fairly) satisfied that openhab mqtt binding is working and the nodeMCU running the Homie example sketch is working. This leads me to believe that my problem is in the way I am writing the items file.
Switch LED {mqtt=">[openhabmqtt:devices/a002a6124dfd/light/on/state:ON:true],<[openhabmqtt:devices/a002a6124dfd/light/on/state:OFF:false],>[openhabmqtt:devices/a002a6124dfd/light/on/set:command:ON:true],>[openhabmqtt:devices/a002a6124dfd/light/on/set:command:OFF:false],"}
When you switch on the light from your nodeMCU, what topic is published from it?
Also you shouldn’t need mosquitto.retain=true unless you want to use the mqtt persistence service
Just had a quick look at the homie mqtt convention. Complicated!
But your item should be, I think:
Switch LED {mqtt=">[openhabmqtt:devices/a002a6124dfd/light/power/set:command:ON:true], >[openhabmqtt:devices/a002a6124dfd/light/power/set:command:OFF:false], <[openhabmqtt:devices/a002a6124dfd/light/power:state:MAP(homie.map)]"}
In your transormation folder you will need to create a file called homie.map with the following content:
Switch LED {mqtt=">[openhabmqtt:homie/a002a6124dfd/light/power/set:command:ON:true], >[openhabmqtt:homie/a002a6124dfd/light/power/set:command:OFF:false], <[openhabmqtt:homie/a002a6124dfd/light/power:state:MAP(homie.map)]"}
Switch LED {mqtt=">[openhabmqtt:homie/a002a6124dfd/light/on/set:command:ON:true], >[openhabmqtt:homie/a002a6124dfd/light/on/set:command:OFF:false], <[openhabmqtt:homie/a002a6124dfd/light/on:state:MAP(homie.map)]"}
Sorry, that’s what I already have, and have been switching from my sitemap in the BasicUI.
I just need a basic mqtt message format that I can send using a switch item to see that traffic in MQTT.fx. This will prove the openhab MQTT binding is working correctly.