I’m diving into MQTT, and thought I had it figured out pretty well after a lot reading, but I can’t figure out what I’m missing. My device is a Tasmota-flashed power strip with four controllable outlets and USB on/off. I can control it directly over WiFi from a browser, and MQTT is enabled.
I installed Mosquitto (no user/password), added the MQTT binding in PaperUI, and then set up my things and items. For the host, I’m pointing to my RPi’s IP address.
[INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'mqtt.things'
[INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.1.101' with clientid OpenHAB2
==> /var/log/openhab2/events.log <==
[hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from UNINITIALIZED to INITIALIZING
[hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from INITIALIZING to OFFLINE
[hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:tasmotapsb' changed from UNINITIALIZED to INITIALIZING
[hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:tasmotapsb' changed from INITIALIZING to ONLINE
Despite going to an OFFLINE status, the broker shows up in PaperUI as ONLINE. This makes me think that I’ve done something wrong in configuring the broker.
I can link items to my things and send commands, but I suspect that nothing is getting published to my Tasmota device.
I’m hoping it’s something really simple that I’m too tired to see.
I installed mqtt.fx and can publish/subscribe without issue, so my suspicion is that Tasmota isn’t communicating with the broker, even though it’s definitely connected to my WiFi. I added a user/password to Mosquitto and the Tasmota to make sure that wasn’t an issue, but it’s still not publishing or subscribing.
I’m starting to wonder if this is a firmware problem with the Tasmota. Maybe I should try downgrading or flashing Espurna? I could also try the embedded MQTT broker, but I can’t see Mosquitto being the problem since mqtt.fx can connect to it.
I tried removing the mqtt.things file and then adding it back, and got the same log result:
[hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from UNINITIALIZED to INITIALIZING
[hingStatusInfoChangedEvent] - 'mqtt:broker:mosquitto' changed from INITIALIZING to OFFLINE
[hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:tasmotapsb' changed from UNINITIALIZED to INITIALIZING
[hingStatusInfoChangedEvent] - 'mqtt:topic:mosquitto:tasmotapsb' changed from INITIALIZING to ONLINE
That’s why I was thinking of trying out the embedded broker…just to see if it would behave differently from Mosquitto.
In mqtt.fx I published ON and OFF commands to cmnd/tasmotapsb/POWER1. I can see them come back to me in the subscription, but that doesn’t trigger the device and I don’t see any commands being received in the Tasmota console. I’m not sure if I’m doing that right.
I tried triggering the POWER1 item on my sitemap and the command showed up in mqtt.fx. So, it leads me back to thinking that everything is fine with Mosquitto and OH, but the Tasmota device is not publishing or subscribing to the Mosquitto broker.
We have a winner! And as I predicted, it was something stupidly simple. I can’t believe how many times I looked at that without thinking, “you need to add the host IP”. And yet, I did think “how does the Tasmota know how to find the broker?”
Thanks @rossko57 and everyone else for your help. Now on to the the fun part of playing with the new toy…
Thats why I love the community… Often you cant see your own mistakes/typos etc, (I have been there so many times) but showing others they see things differently, and often spot it really fast.