homieiot / convention

🏡 The Homie Convention: a lightweight MQTT convention for the IoT
https://homieiot.github.io/
Other
710 stars 59 forks source link

DataType bug in specification 3.0.1 #179

Closed Alv3s closed 4 years ago

Alv3s commented 4 years ago

Hello everyone,

First I am not sure if I should raise this issue since a new specification was already released, but since that specification has breaking changes I feel like this issue should be raised.

I've been implementing the specification 3.0.1 for a project in a company I work with. I had a bug and while trying to fix it I see that the bug is due to a specification issue (design issue).

The problem is as follows:

I have a service that collects data from MQTT (in Homie 3.0.1 specification). This service, when finished receive all mandatory data of Homie Convention, sends an event, via Socket, for a frontend application that will generate the UI. The problem is with the field "Data Type" from a property, since it is not mandatory and fallback to a String and a string can be empty (""): (1) - I am receiving MQTT information regarding a device. I am waiting for everything that is mandatory until giving this information to the backoffice. (2) - Although I haven't received every piece of information of a device, I have received everything that is mandatory from the device. Since Data Type is not mandatory, I will assume it is a string, and since a string can be empty, I don't have to wait until I receive a value, since it can be empty. So, I say to the UI "This property is a string". (3) - After a bit, I receive the Data Type field, and it is not a String after all. So the UI has rendered something wrong. in top of that, I should wait for the value of that property to arrived.

Has a workaround, I have made DataType mandatory in my implementation.

davidgraeff commented 4 years ago

We discussed this problem in various issues. The nature of MQTT would actually force us to either enumerate all properties somewhere and a controller would wait for all those listed properties or make all properties mandatory.

There hasn't been any decision yet and the workaround solution so far is to wait for a specific time before assuming that all properties have been received.

Alv3s commented 4 years ago

Yes. What I am currently making is just that:

First I wait for the device the enumerate the nodes. Then I wait to enumerate the properties, then I wait each of the mandatory fields of those properties.

Since I will only work with our custom devices, I will make the DataType mandatory. A bit misleading if someone over time has to grab the project again.