OnOff Switch - MQTT


I have a (zwave) wallplug that I can control via Homey.
I also have setup a OnOff Switch in OpenHab (3.0.0 Release Build) to control the wallplug via MQTT.
Everything is working fine.

The only problem I have is when I switch the wallplug from Homey the status of the OnOff switch in OpenHab does not follow.
I have tried to add next to the MQTT Command topic also the MQTT State topic in the channel configuration but this does not work.

Any idea how to solve this?

Since it’s MQTT i would suggest to use MQTT.fx to check if homee populates the switch status to the MQTT broker.
If yes, check your openHAB configuration if the state topic if configured according to what’s sent to the broker

You must have that to recognise the actual state of the device.
Need more detail about what you tried, and what MQTT message the Homey/switch combination sends.

The state changes that you see when you control from openHAB are because of autoupdate.

First of all thanks for the quick reply!
Using MQTT Explorer I clearly see that Homey changes the onoff topic.
Based on that I tried to add as MQTT state topic the folowing: homie/homey-5bfd49d5f33a8c0d434191fb/wallplug-4/onoff but that does not visually change the status of the switch.
The MQTT command topic = homie/homey-5bfd49d5f33a8c0d434191fb/wallplug-4/onoff/set which allows me to control the wallplug

I suppose I mis something?

What payloads do you see on that topic?

But I see this Homey device uses Homie-MQTT standard. openHAB can automatically discover and configure for that.

Sorry what do you mean with payload (that’s why I’m called a beginner)?
Via the explorer I see:
onoff = false or true
$name = Wall plug 4 - Turned on
$retained = true
$settable = true
$datatype = boolean
set = false or true

Concerning Homie MQTT I indeed saw that option when adding a thing but couldn’t get it to work. If you could point me to a manual or the right direction, much appriciated !
Still a lot to learn.

MQTT payload; a complete MQTT message has a topic and a payload. Roughly like a postcard, the topic is the postal address and the payload the written words.
aircon/fan/motor "80%"

That looks like the homie self-advertising, where the device announces it’s capabilities. A listener like openHAB can use that to configure i.e. build Things and channels in our case.

It’s actually describing an on/off channel, note that it is telling you to expect or send payload “true” or “false” only.
openHAB will sort that out if it auto-configures. Otherwise you need to know that if manually configuring.

Note this is just a description. This topic is not going to tell you what the state is now, and you cannot send on/off commands to this topic.
We can manually read the description together with the homie standard though.
If your device base topic is xxxx/xxx/xxx, we can workout
is the topic that the device will use to report its state. The payload will be "true"or “false”.
is the topic that we should use send commands to the device. The payload will be "true"or “false”.

I think that’s where you should be looking really,not trying to bodge around it manually.

I managed to make it work via the homie MQTT device.
Indeed much easier. Thanks for the support and pointing me in the right direction !

1 Like