Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

[MQTT/Homie] name and datatype fields are mandatory for property #6832

Open
chris922 opened this issue Jan 10, 2019 · 5 comments
Open

[MQTT/Homie] name and datatype fields are mandatory for property #6832

chris922 opened this issue Jan 10, 2019 · 5 comments

Comments

@chris922
Copy link

chris922 commented Jan 10, 2019

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?

@kaikreuzer
Copy link
Contributor

@chris922
Copy link
Author

Ok, I found the issue. 😃

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.

@chris922 chris922 changed the title [MQTT/Homie] not working dummy channel created for settable Jan 11, 2019
@davidgraeff
Copy link
Contributor

Thanks for this analysis, that helps fixing this issue fast.

@jimtng
Copy link

jimtng commented Jul 14, 2019

Has this issue been fixed yet? Also why is the item type set to dummy?

@davidgraeff
Copy link
Contributor

I haven't worked on mqtt, if no one else has, this issue is not yet fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants