[SOLVED] MQTT-Homie-Switch won't work

mqtt
switch
homie
Tags: #<Tag:0x00007fe0601e55a8> #<Tag:0x00007fe0601e53a0> #<Tag:0x00007fe0601e4f68>

(Manuel Schärer) #1

I have an MQTT-Device (ESP8266) with the following MQTT-States (under Homie-Convention):

homie/eg-bad-licht/$homie -> 3.0.1 (Retained)
homie/eg-bad-licht/$name -> EG - Bad - Licht (Retained)
homie/eg-bad-licht/$nodes -> light (Retained)
homie/eg-bad-licht/$state -> ready (Retained)
homie/eg-bad-licht/light/$name -> Light (Retained)
homie/eg-bad-licht/light/$properties -> power (Retained)
homie/eg-bad-licht/light/$type -> switch (Retained)
homie/eg-bad-licht/light/power -> ON 
homie/eg-bad-licht/light/power/$datatype -> enum (Retained)
homie/eg-bad-licht/light/power/$format -> ON,OFF (Retained)
homie/eg-bad-licht/light/power/$name -> Power (Retained)
homie/eg-bad-licht/light/power/$settable -> true (Retained)

In the Paper-UI the Thing will discover automatically and I can add it to the things. I have add the power-item as an switch:

Switch BadLampeSwitchLight “Bad - Lichtschalter:” (mqtt,Schalter,OrtBad) {channel=“mqtt:homie300:embedded-mqtt-broker:eg-bad-licht:light#power”}

The problem is, that when homie/eg-bad-licht/light/power change, nothing happens with the item. And when I change the item (toggle switch), nothing are published under homie/eg-bad-licht/light/power/set.

What is wrong?

Thanks for your help.

PS: My Openhab-Version is openHAB 2.5.0 Build #1485 under Debian.


(David Graeff) #2

Have you looked up the channel ID (and the Log)? Because dashes are not allowed in channel ids if I recall correctly. I know that node/properties without dashes work perfectly. If dashes don’t work, that’s a bug that need to be reported.


(Manuel Schärer) #3

Thank for your fast replay and your help.

Same behavior without dashes:
Switch BadLampeSwitchLight "Bad - Lichtschalter:" <light> (mqtt,Schalter,OrtBad) {channel="mqtt:homie300:embedded-mqtt-broker:egbadlicht:light#power"}

In the openhab.log I see no warning or error releated to this topic.

When I edit the thing in the paper ui, the channel-type of power is string and not switch.


(David Graeff) #4

Ok that helps. A homie enum is usually mapped to a string. Multi state switches are not yet a Thing in openHAB.

What you want is either a type “boolean” or a type enum but with predefined states. See https://www.openhab.org/addons/bindings/mqtt.generic/#supported-things. For a raw button you need PRESSED,RELEASED.


(Manuel Schärer) #5

OK, now it works, with boolean and without dashes. With dashes it not work, this was the reason, why i have change to enum.
Can you open the issue with dashes?

Thanks for your help.


(Manuel Schärer) #6

The issue exists at


(Bastiaan van Haastrecht) #7

So if I understand correctly, so in Adduino terms you cant use HomieNode type switch with Openhab currently? What type should be used?


(Bastiaan van Haastrecht) #8

Let me explain my problem a bit more. I have homie 3.0.1 running and trying to get a switch working in OH 2.4. I have this in my Arduino:

HomieNode doorbellNode("doorbell", "switch", "switch");
doorbellNode.advertise("pressed").setDatatype("enum").setRetained(false).setFormat("PRESSED,RELEASED").settable(boorbellPressedHandler);
doorbellNode.advertise("onoff").setDatatype("enum").setRetained(false).setFormat("PRESSED,RELEASED").settable(boorbellPressedHandler);
doorbellNode.setProperty("pressed").send("RELEASED");
doorbellNode.setProperty("onoff").send("PRESSED");

This is what i’ve come up with, with my interpertation of docs and examples. However this generates two dummy channels in the Homie MQTT thing. They are not of type switch. Any idea what I could be doing wrong here?


(David Graeff) #9

It must be a property of type boolean in oh2.4 to become a switch. With oh 2.5 it can also be an enum.


(Manuel Schärer) #10

I use boolean and it works. But it not work with the autodedected device, for that a bug is open. When you add the device manualy, it works.

PS: I use an NodeMCU with https://github.com/homieiot/homie-esp8266/tree/develop-v3
With this Device you will have WLAN included.


(Bastiaan van Haastrecht) #11

Thanks Manuel, do you have the github issue for this autodiscover bug for the boolean/switch?

I use an Wemos D1 mini china clone. Works perfectly.