homieiot / convention

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

Range setters - how to handle it? #14

Closed luke-lewandowski closed 7 years ago

luke-lewandowski commented 7 years ago

Hey!

I'm using ranged properties (as per your SDK for homie on esp8266).

zoneNode.advertiseRange("on", 1, 3).settable(zoneOnHandler);

What would be the standard message to MQTT to send range 1 with value X? eg. devices/c40f46e0/zone/on[1]/set ??

Sorry I just couldn't find any documentation on how to handle it.

Kind regards, Luke

euphi commented 7 years ago

The range index is appended with an underscore.

As example: Actual MQTT messages from my heating control. The set message is from Openhab and the reply of the homie-esp8266 device:

devices/hzgctrl/Relais/in_9/set ON
devices/hzgctrl/Relais/in_9 ON

For your information, the constructor of the node is:

RelaisNode::RelaisNode() :
        HomieNode("Relais", "switch16"), relais_bitset(0x0000), io(0x20) {
    advertiseRange("in",1,16).settable();
}

and the resulting properties message:

devices/hzgctrl/Relais/$properties in[1-16]:settable
luke-lewandowski commented 7 years ago

Hi Euphi,

It all makes sense now! Thanks.

Regards, Luke