- 
                Notifications
    You must be signed in to change notification settings 
- Fork 162
WIP Asyncio Program Flow
        Ellis Percival edited this page Jan 23, 2021 
        ·
        7 revisions
      
    _handle_mqtt_message():
- MQTT message received to <topic_prefix>/output/<output_name>/set
- Output name parsed from topic
- GPIO module object, output config and payload added to the module's output queue
digital_output_loop():
- Queue entry picked up
- Payload checked to ensure it matches configured on or off payloads
- 
set_digital_output()called to set the output
- MQTT message published to <topic_prefix>/output/<output_name>to confirm output change
_handle_mqtt_message():
- MQTT message received to <topic_prefix>/output/<output_name>/set_on_ms(or/set_off_ms)
- Output name parsed from topic
- Bespoke async function created to handle the toggling of the output with the delay in the middle (set_ms())
- 
set_ms()task added to the task loop
set_ms():
- Interval time parsed from payload (milliseconds)
- Digital output set to the desired value (on or off)
- MQTT message published to <topic_prefix>/output/<output_name>to confirm output change
- Task paused for specified interval
- Digital output set to the inverse of desired value (off or on)
- MQTT message published to <topic_prefix>/output/<output_name>to confirm output change
digital_input_poller():
- Input change recognised
- 
DigitalInputChangedEventevent fired with details of the change
EventBus.fire():
- Task added to task loop for publish_callback()
publish_callback():
- MQTT message published to <topic_prefix>/input/<input_name>with payload set according to the input's new value