homieiot / convention

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

Representing a state machine #305

Open nstadigs opened 2 hours ago

nstadigs commented 2 hours ago

i have a controller that uses state machines and I was hoping to be able to represent them using the homie convention.

Here's a simple example:

mermaid-diagram-2024-11-01-095617

This machines has two states (Paused, Running) and two transitions/actions (start, stop).

My initial intuition was to represent these as enums, where the payload can be Paused or Running and the /set endpoint listens for "start" and "stop" payloads. But it's not clear to me what the $format property represents in this case. It should probably be the payloads accepted by the /set endpoint, right?

How would you represent this using the homie spec?

nstadigs commented 2 hours ago

Found #70 and realized that I should probably represent the machine as a node and the states and actions as two different properties:

/homie/5/controller/my_machine/states <-- enum, not settable /homie/5/controller/my_machine/actions <-- enum, stateless, settable