homieiot / convention

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

chore(state): add some more details around state management #272

Closed Tieske closed 8 months ago

Tieske commented 1 year ago

especially around safely adding/removing child relationships

schaze commented 1 year ago

I do not like the interweaved coupling of parent and child updates. This will make an implementation very cumbersome. Also you cannot guarantee another mqtt client will receive updates for different topics in sequential manor. In addition I want to keep coupling between parent and child as minimal as possible. Exact sequence and timing in MQTT do not work well in my experience.

I would clearly split this up and also switch the order when adding a child to first make sure the devices are published (with at least $state:init) before adding them to the parent (this way one could add multiple child devices with a single parent update).

Adding:

Removing, whilst leaving the device on the Homie network:

Removing, permanently

Tieske commented 8 months ago

@schaze thx, make sense. Updated.

I removed the "Removing, whilst leaving the device on the Homie network" part, since that is something that works in theory, but really do not see a real use-case for it.