mysensors / MySensors

MySensors library and examples
https://www.mysensors.org
1.31k stars 891 forks source link

Feature request: MQTT with auto node id #844

Closed MPParsley closed 7 years ago

MPParsley commented 7 years ago

When using several hundred nodes that can be relocated it would be nice to automatically assign a new node id whenever a node is powered on in the network.

henrikekblad commented 7 years ago

Not sure what you mean here.. It is up to your controller to hand out ids. Works exactly the same over MQTT as the MySensors protocol.

MPParsley commented 7 years ago

Handing out the ID is indeed up to the controller but the documentation is somewhat unclear on this.

According to this documentation Auto ID is not supported through MQTT:

NOTE: No controller supports dynamic ID assignment through MQTT. All nodes must have MY_NODE_ID defined in the sketch to work with MQTT. If you don't set MY_NODE_ID, nodes will complain with the message "!TSM:ID:FAIL".

Yet, the documentation here states that "node ID generation" & "MQTT gateway" are supported by these controllers:

So as it is supported by these controllers I assumed some code would be needed on the Mysensors side for MQTT?

MPParsley commented 7 years ago

Closing this as it seems to be implemented on the MySensors side.

FYI: I tested this with mycontroller and as of the latest (build) version it supports auto node id generation with MQTT.

trlafleur commented 7 years ago

Can you please state how you tested this, as I'm looking at the code, I see no logic for storing or giving out of client ID in the MQTT examples or MQTT transport code.

Thanks

MPParsley commented 7 years ago

Hi @trlafleur,

In the node sketch I put #define MY_NODE_ID AUTO.

Note that you'll need to build the latest version of MyController (https://github.com/mycontroller-org/mycontroller) or you'll have to ask its maintainer to create a new release.

A SNAPSHOT version is available here: http://forum.mycontroller.org/topic/58/download-snapshot-build