@KennethLavrsen: Thank you for the information. I’m trying to configure the triggers without any values, as you suggested, but it’s not working properly, and I’m wondering if I can get your input.
I did review your post titled “Using the new action events in Zigbee2MQTT 2.0”. Where I’m not understanding things is the lines on how to format the conditions. In your examples, it looks like a template with curly brackets around the “trigger.to_state.attributes…” part. I tried to simulate what you did, but the automation throws an error; the yaml is as follows:
alias: Testing Zigbee2MQTT v2
description: ""
triggers:
- entity_id:
- event.zigbee_smart_button_action
id: Single
trigger: state
not_from: unavailable
enabled: true
conditions: []
actions:
- alias: >-
If Generic Fan Plug is ON --> turn it OFF; else if it is OFF --> turn it
ON
if:
- condition: "{{trigger.to_state.attributes.event_type == 'single'}}"
- condition: state
entity_id: switch.generic_smart_plug
state: "on"
enabled: true
then:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.generic_smart_plug
else:
- if:
- condition: "{{trigger.to_state.attributes.event_type == 'single'}}"
- condition: state
entity_id: switch.generic_smart_plug
state: "off"
enabled: true
then:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.generic_smart_plug
enabled: true
mode: single
So, then I tried changing the conditions to states, as follows, but it only works intermittently:
alias: Testing Zigbee2MQTT v2
description: ""
triggers:
- entity_id:
- event.zigbee_smart_button_action
id: Single
trigger: state
not_from: unavailable
enabled: true
conditions: []
actions:
- alias: >-
If Generic Fan Plug is ON --> turn it OFF; else if it is OFF --> turn it
ON
if:
- condition: or
conditions:
- condition: state
entity_id: event.zigbee_smart_button_action
attribute: event_type
state: single
- condition: state
entity_id: switch.generic_smart_plug
state: "on"
enabled: true
then:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.generic_smart_plug
else:
- if:
- condition: state
entity_id: event.zigbee_smart_button_action
attribute: event_type
state: single
- condition: state
entity_id: switch.generic_smart_plug
state: "off"
enabled: true
then:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.generic_smart_plug
enabled: true
mode: single