Skip to content

Need help with @mqtt_trigger and multiple instantiations using the YAML configuration #749

Answered by andisa-8
andisa-8 asked this question in Q&A
Discussion options

You must be logged in to vote

And I’m an idiot….

When I reduced the scope of the function then I forgot to add the trigger

    # register it in the global scope so pyscript sees it.
    registered_triggers.append(wall_switch_action)

And the correct (or at least working) configuration is:

    @mqtt_trigger(f"zigbee2mqtt/{config['switch_id']}", f"payload_obj['action'] == '{config['button']}_press'")
    @mqtt_trigger(f"zigbee2mqtt/{config['switch_id']}", f"payload_obj['action'] == '{config['button']}_press_release'")
    @mqtt_trigger(f"zigbee2mqtt/{config['switch_id']}", f"payload_obj['action'] == '{config['button']}_hold'")
    @mqtt_trigger(f"zigbee2mqtt/{config['switch_id']}", f"payload_obj['action'] == '{config['bu…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by andisa-8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant