homieiot / convention

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

Emphasize avoidance of Uppercase characters in Topic ID's #198

Closed sheilbronn closed 4 years ago

sheilbronn commented 4 years ago

I've been pulling my hair out trying to find out why the following Homie syntax doesn't lead to a succesful autodiscovery in OpenHAB 2.5.3:

homie/Alt/$homie 3.0.1
homie/Alt/$name MyDevice
homie/Alt/$state ready
homie/Alt/$nodes publicwifi
homie/Alt/publicwifi/$name PublicWifi
homie/Alt/publicwifi/$type PublicWifi
homie/Alt/publicwifi/$properties nrclients
homie/Alt/publicwifi/nrclients/$name Client count
homie/Alt/publicwifi/nrclients/$datatype integer
homie/Alt/publicwifi/nrclients/$unit #
homie/Alt/publicwifi/nrclients/$format 0:9999
homie/Alt/$state ready

It turns out that OpenHab auto-discovery becomes succesful only if the "A" in the topic part "Alt" is lower-cased! More specifically: "... only if the device topic part does not begin with an uppercase character..."

Section 2.1 of the Homie spec says: ... A topic level ID MAY contain lowercase letters from a to z, numbers from 0 to 9 as well as the hyphen character (-)....

I would suggest extending the spec by adding the following sentence: Please note that some Homie controllers (e.g. OpenHab) might rely on the topic not beginning with an uppercase character.

PS: Offcourse, there should be an issue raised for the Homie binding in OpenHAB also :)

sheilbronn commented 4 years ago

Offcourse, it would be nice if the Homie Online Validator would through a warning if the device ID part of the topic begins with an uppercase character....

sheilbronn commented 4 years ago

NB: OpenHab autodiscovery works fine with uppercase chars later on in the topic, e.g. "aLt".

mjcumming commented 4 years ago

The MAY means MAY ONLY from my understanding

sheilbronn commented 4 years ago

Then I would suggest to change the sentence in 2.1. to: A topic level ID MAY ONLY contain lowercase letters from a to z, numbers from 0 to 9 as well as the hyphen character (-).... This would make it really clear.

davidgraeff commented 4 years ago

That's how I read it as well "may only". And yes a PR that addresses this should change the wording and a minor version number bump.

The validator is located in the website repo and is a single js file, if someone want to have a look.

mjcumming commented 4 years ago

change to convention done

piegamesde commented 4 years ago

@mjcumming When a commit resolves an issue, please reference it with something like Closes #198. Not only will this automatically close the issue, but it will also link the discussion and the implementation of a feature.