I figured it out! It now works perfectly and I don’t need a second event to turn off the filter. It’s all done in this one event:
- Press the button to start the 30 minute timer and turn on the air filter.
- If I change my mind, press the button to turn the filter off and cancel the timer.
- After 30 minutes the air filter turns off automatically.
So here’s some new things I learned here:
- The event part of the trigger (when the timer finishes) can be given a “trigger_id”.
- In the action → choose section I can look for this trigger_id and act upon it (turn off the filter).
- I also learned that in the action → choose options, the first one matches starting at the beginning.
For #3 - I had that option last (trigger_id matches from the event) and it didn’t work, most likely because one of the other options could also match. Once I moved it first everything works perfectly!
Note the two triggers to start this automation, either a button press or the timer finishes.
Here’s the final automation:
alias: 'Master bedroom: Air filter 30 minutes (timer)'
description: ''
trigger:
- device_id: b251a3bee8687b95b2fff6d7
domain: deconz
platform: device
type: remote_button_short_press
subtype: turn_on
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.mbr_air_filter
id: timer_complete
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: timer_complete
sequence:
- type: turn_off
device_id: d8117da0fbe2652aa5d5c7
entity_id: switch.mbr_air_filter_on_off
domain: switch
- conditions:
- condition: state
entity_id: timer.mbr_air_filter
state: idle
sequence:
- type: turn_on
device_id: d8117da0fbe2652aa5d5c7
entity_id: switch.mbr_air_filter_on_off
domain: switch
- service: timer.start
data:
duration: '00:30:00'
target:
entity_id: timer.mbr_air_filter
- conditions:
- condition: state
entity_id: timer.mbr_air_filter
state: active
sequence:
- type: turn_off
device_id: d8117da0fbe2652aa5d5c7d
entity_id: switch.mbr_air_filter_on_off
domain: switch
- service: timer.cancel
target:
entity_id: timer.mbr_air_filter
default: []
mode: single