Yes, I’m a newbie… (Barry) an IT tech for 30 years starting with PDP-11’s then AS/400’s but now mostly Wintel systems and networks.
That said, I’ve never been a unix guy…
My goal. To control sonoff switches using openhab2 using the Paper UI for configuration wherever possible.
So I got me a Pi 3 and gave it a go…
So far I have got openhabian with openhab 2.4 loaded and running.
I have mosquitto loaded and running and what I understand to be the very new 2.4.x MQTT binding loaded.
I can connect to mosquitto using MQFX on a PC.
I have two sonoff switches which I have flashed with Tasmota. I have these connected to wifi and communicating with the mosquitto MQTT on the Pi.
I now need to understand how to bring these elements together.
I thought by loading all the default choices… (Pi,openhabian,mosqitto,MQTT2.4.x) I would be taking the easy vanilla route… however, clearly most information out there is based on old 1.x bindings and configuration files.
I’d like to find a step by step guide of information based around the 2.4 MQTT binding and ideally config thru Paper UI, hopefully relationg to how to tie to and control sonoffs.
As it’s MQTT2, there is auto discovery option.
First step is to create a mqtt bridge.
Go to Paper UI -> Inbox.
If there isn’t a MQTT Bridge yet, click “+” and select MQTT Thing Binding.
If no Bridge is found, add it manually by selecting “manually add thing” or “add manually”, both do the same.
Select “MQTT Broker” to create the broker connection manually.
As Tasmota provides auto discovery (hass) since ~version 6.3, maybe the next step is working with auto discovery
If not, use inbox->mqtt->add manually-> generic mqtt thing to setup a thing per device or one thing for all devices.
Finally, define channels for the thing(s)
I am a complete noob in the area of home automation and I came here with the same problem as brivett.
I created the thing and as you suggested I added a channel to it with
stat/SmartPlug01/POWER
and
cmnd/SmartPlug01/POWER
The Thing is shown as “ONLINE” unter Configuration > Things, however, in the Paper UI unter Control, where I can see the thing with the channel I created, clicking on the toggle-switch next to it does not affect anything.
If I use mqtt-test-tools on my phone or mqtt.fx on my PC, I can switch on and off the plug with cmnd/SmartPlug01/POWER ON respectively OFF and I will receive status updates with a subscription to stat/SmartPlug01/POWER
I have no idea whatsoever on how to diagnose this issue…
Which version of openHAB and MQTT binding are you using?
If openHAB 2.4 with MQTT 2 you just migth need to restart.
Otherwise please checked which messages you recieve FROM openHAB on the MQTT tools, that should give you a clue what is wrong.
I use OpenHAB2.4 and the new MQTT binding, and I did restart the whole Raspberry PI I am running on without any success.
Otherwise please checked which messages you recieve FROM openHAB on the MQTT tools, that should give you a clue what is wrong.
What do you mean with MQTT tools? Are you talking about MQTT.fx and/or the iPhone-App that I used for testing (It’s called MQTTool)? Or do you mean any specific Mosquitto tools?
I was hoping to find some kind of status monitor for the Mosquitto server on the command line, showing a list of connected clients and maybe the incoming publishes, but did not tinf anything.
However, the Raspi is turned off currently and I will continue testing on the weekend.
I was talking about MQTT.fx. Using such you should see a message from your openHAB instance when switching the Power channel (you need to subscribe to that topic or better to all messages).
You did not mention the MQTT Broker Thing, which acts as a bridge, however I think your Generic MQTT Thing would not show online without it.
From my own experience trying to get this working (a long, long time and thinking that I hadn’t understood the fairly complex set up needed in openHAB):
I’m using openHAB2.4 and mosquitto both running on Synology DSM. I could control a Sonoff R2 Dual reliably from its web interface, but couldn’t get openHAB (using PaperUI) to control it. The control interface didn’t reflect the state of the relays and I couldn’t switch them.
Using MQTT.fx I was able to establish that OH was issuing the expected commands to the mosquitto broker, but there was no action on the sonoff.
The one thing I hadn’t checked was the console on the sonoff web ui. Eureka! This revealed that the sonoff wasn’t connecting to the mosquitto broker because it appears that in the Host field of the MQTT parameters in the sonoff web ui needs an IP address and won’t work with a host name. I changed it to the IP address, and with MQTT.fx subscribed to #, I saw a whole load of messages for the first time, and more importantly, everything is now working from OH.