orchestracities/lego-diorama-usi-2022

reformat streelight code based on [#18]

Closed this issue · 0 comments

def on_message(client, userdata, msg):

the flow should be:

  1. subscribe to command topic
  2. when command received to turn on light (e.g. { "light": { "power": "on" } }):
    1. turn on lights (a leave them on - the off control will be done with an external logic that ask to turn off)
    2. send ack to cmdexe topic (e.g. { "light": { "power": "ok" } })
    3. update status attribute on attrs topic (e.g. { "powerState": "on" })
  3. when command received to turn off light (e.g. { "light": { "power": "off" } }):
  4. turn off lights
  5. send ack to cmdexe topic (e.g. { "light": { "power": "ok" } })
  6. update status attribute on attrs topic (e.g. { "powerState": "off" })