@mfalkvidd said in Best way to send nodeDistance and parentNode:
@xefil I've never seen anyone reuse a child ID, and I think it would confuse most controllers. Just look at the presentation call: first the sketch would present the child as type X, then the sketch would present the same child as type Y. Will the controller use the first, the second, both or none of the presentations?
But you may be right - maybe controllers can handle multiple data types per child id.
Well @mfalkvidd maybe it's me that I'm making confusion.
AFAYK, in case of HomeAssistant, it has an auto-discovery system which works, even if I don't like the naming convention it uses. BTW, using the above example, subscribing to MQTT server, I can get the values like follow:
api doc:
MY_MQTT_PUBLISH_TOPIC_PREFIX/FROM-NODE-ID/SENSOR-ID/CMD-TYPE/ACK-FLAG/SUB-TYPE
example message published on topic prefix mygateway1-out from node 28, on V_VAR1, which has id 24, becomes:
mygateway1-out/28/100/1/0/24
The same way, message published on topic prefix mygateway1-out from node 28, on V_VAR2, which has id 25, becomes:
mygateway1-out/28/100/1/0/25
This gives me the ability to subscribe on it and check for changes, like the logs shows me:
2018-12-31 08:37:09 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on mygateway1-out/28/100/1/0/24: b'0.0'
2018-12-31 08:51:09 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on mygateway1-out/28/100/1/0/25: b'1.0'
Looking deeper on what the controller recognize it during the presentation, using S_CUSTOM (id: 23) it's reassumed in this part of xml auto-generated:
"28": {
"protocol_version": "2.3.1",
"battery_level": 0,
"type": 18,
"children": {
<code_snipped>
"100": {
"description": "Internal variables",
"id": 100,
"values": {
"24": "0.0",
"25": "1.0"
},
"type": 23
}
},
"heartbeat": 0,
"sketch_name": "node28Studio",
"sketch_version": null,
"sensor_id": 28
},
So, actually the infos are correctly sent. It's more a matter if the usage of the IDs is correct to avoid further conflicts, if any.
That's the reason I'm asking
Thanks, Simon