smarthome
smarthome copied to clipboard
[MQTT/Homie] name and datatype fields are mandatory for property
I started with the MQTT binding for openHAB 2.4 and tried to detect my Homie 3.0.1 device.
It will be recognized, but it seems that the channel type or something like this will not be recognized. In the PaperUI the channel is described like this:
light#on
mqtt:homie300:b4e62d2a6063:light#on
dummy
I saw #6784 and as my thing ID contained a hyphen I thought I had the same or a similar issue.. unfortunately even without a hyphen it is not working.
Thing is added manually as a Homie thing, I also tried the auto discovery after I added the MQTT broker.. same issue.
I even tried to debug it, but as I am not really familiar with the code I was not able to find an issue.
I noticed that the Property will be initialized with a channel that has as an accepted item type dummy
and I am not reaching the breakpoint where the channel will be changed to something with a valid accepted item type.
It seems that the attributesReceived
that will be set to the future in Property#subscribe(MqttBrokerConnection, ScheduledExecutorService, int)
will also not be reached, only initialized
will be set to true
.
Property#attributeChanged(String, Object, MqttBrokerConnection, ScheduledExecutorService, boolean
will be reached (e. g. for topic homie/b4e62d2a6063/light/on/$settable
), but as the property is not yet initialized
the attributesReceived()
method will not be called.
Could it be the case that there there is already a subscription to this topic when Property#subscribe(...)
will be called, so that this is not getting the retained value and the attributeChanged(...)
method will get it mistakenly?
@davidgraeff fyi
Ok, I found the issue. :smiley:
My Homie device is not sending a name
for the exposed property, but for the openHAB MQTT plugin a name
is mandatory:
https://github.com/eclipse/smarthome/blob/6a81231cda79d3812e8ff9868868190cf142be95/extensions/binding/org.eclipse.smarthome.binding.mqtt.generic/src/main/java/org/eclipse/smarthome/binding/mqtt/generic/internal/convention/homie300/PropertyAttributes.java#L43
According to the Homie specs the name
is not required:
https://homieiot.github.io/specification/#property-attributes
Additionally I noticed that the datatype
is also marked as mandatory, but according to the specs it is not and should default to string
.
Thanks for this analysis, that helps fixing this issue fast.
Has this issue been fixed yet? Also why is the item type set to dummy?
I haven't worked on mqtt, if no one else has, this issue is not yet fixed