Hi there,
My first post. I am new to OpenHAB - and new to Homie. So please bear with me…
I have OpenHabian 2.4 running in RPI3. I have created a java program that posts some usually pretty dumb switches to the embedded mqtt broker. Some can dim, some cannot. The autodiscovery feature works - no problem, but when I go into Things it PaperUI it says:
Status: OFFLINE - COMMUNICATION_ERROR java.lang.Exception: Did not receive mandatory topic value: homie/45208/$homie
But it’s there. My format is like this (please correct me, if you see any obvious errors):
homie/45208/$state > init
homie/45208/$homie > 3.0.0
homie/45208/$implementation > ZenseHome
homie/45208/$localip > 192.168.xx.xx:10001
homie/45208/$name > Spots primær
homie/45208/$id > 45208
homie/45208/$type > Lampeudtag m. PIR dæmpbar
homie/45208/$room > Køkken
homie/45208/$properties > power,dimmable,wattUsage
homie/45208/properties/power > OFF
homie/45208/properties/power/$settable > true
homie/45208/properties/power/$format > ON,OFF
homie/45208/properties/power/$retained > true
homie/45208/properties/dimmable > true
homie/45208/properties/dimmable/$settable > true
homie/45208/properties/dimmable/$format > 0:100
homie/45208/properties/dimmable/$retained > true
homie/45208/properties/dimmable/$format > integer
homie/45208/properties/wattUsage > 0.0
homie/45208/properties/wattUsage/$settable > false
homie/45208/properties/wattUsage/$format > 0:2000
homie/45208/properties/wattUsage/$retained > true
homie/45208/properties/wattUsage/$unit > w
homie/45208/properties/wattUsage/$format > float
homie/45208/$state > ready
Do you have any ideas as to what I can do different?
You are sending $homie, but I wonder if the issue is that your are defining dimmable as an integer but sending “true” as your value and that is causing it to stop processing other values. It is just a guess at a cause because I don’t have the code in front of me.
If you are able to use Kotlin instead of Java, I wrote a library with good test coverage that would prevent errors like that.
Hey @broconne
Thanks for your reply - it’s really appreciated. I might have misunderstood some of the Homie convention, because I though that it was:
homie/45208/properties/dimmable/set > 50
That was to be used, if I wanted to dim the lights to 50.
homie/45208/properties/dimmable > true
was just used to verify that the device IS true. But as stated, I might not get Homie precisely.
I only know Java - so I would have a hard time in changing to Kotlin…
So, I’ve been working a bit more with this and I found the homie validator here: https://homieiot.github.io/tools/
That helped me quite a lot. My device now looks like below paste. Now I can dim the device (only with manual input of numbers though - but it works), and I can see the watt usage. But I can not use the switch. In OpenHAB it doesnt even read the name, so I believe there is an error in one of the inputs. Not sure which one yet.
Does anyone have a link to documentation for MQTT Homie for OpenHAB? Specifically which types are available and examples of data?
I am not sure. I have tried setting it to false for power and dimmable, but then they stopped working. I believe they are true as default, so might not be needed.
I still have the issue that OpenHAB doesnt set my power node as a switch, but as a String instead… Can you see what I did wrong there?
Ahr, I hoped you were referring to an OpenHAB specific specification
And BONUS - you are right - I set it too boolean and now I have the correct switch. Now it just return true/false instead of ON/OFF. But I can handle that in my device code - so that’s not a big problem for me. THANKS!!!
Yes, I actually am sending all data each time. I can also see that OpenHAB doesn’t update them once I configure them. Should I send the MQTT payloads without a retained flag for that to function, you think?
I am a bit n00b in all this - so have been trying a whole lot to get it to work!
I think of it this way; Send all the parameters and setupinfo as retained payload upon connection to the broker -> send node values and states ie. every other second.