hello all,
i have 4 working automations to automate a light. This week I saw the “choose” action in automation and I began to rewrite my automations to have only one per device. This works very well and I reduced the amount of my automation successfully.
But here I can’t get a working result. Maybe someone can help me.
Here are my working automations:
Turns on the light when motion is dedected
- id: '1640030477436'
alias: light 1 on
description: 'turn on light when
- motion sensor is on
- lx < 15'
trigger:
- platform: state
entity_id: binary_sensor.motion_1_ias_zone
to: 'on'
condition:
- condition: numeric_state
entity_id: sensor.motion_1_illuminance
below: '15'
action:
- type: turn_on
device_id: eac48738360242f203d80dd36a0672e3
entity_id: light.light_1
domain: light
mode: single
Turns off the light when no motion is dedected
- id: '1640030674098'
alias: light 1 off
description: 'turn off light when
- motion sensor is off
trigger:
- platform: state
entity_id: binary_sensor.motion_1_ias_zone
to: 'off'
for:
hours: 0
minutes: 1
seconds: 0
condition: []
action:
- type: turn_off
device_id: eac48738360242f203d80dd36a0672e3
entity_id: light.light_1
domain: light
mode: single
starts a timer when light will be turned on manually
- id: '1640959101730'
alias: light turned on manually
description: 'light turned on manually by pressing light switch
starts a timer of 10 sec'
trigger:
- platform: state
entity_id: light.light_1
to: 'on'
condition: []
action:
- service: timer.start
data:
duration: '0'
target:
entity_id: timer.light_1
mode: single
IAS zone from motion sensor to off when timer finished
- id: '1640959316077'
alias: light 1 timer
description: when timer is idle
- IAS Zone off, light will be turned off by automation
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.light_1
condition:
- condition: state
entity_id: binary_sensor.motion_1_ias_zone
state: 'off'
action:
- type: turn_off
device_id: eac48738360242f203d80dd36a0672e3
entity_id: light.light_1
domain: light
mode: single
what I want is to have one single automation like:
I’d say, copy the conditions of your 4 automations to the options’ conditions of your “choose” and have fun. You might want to consider adding a trigger ID to your triggers (in the new automation) and include that as a condition in the option. It’s not as complicated as it might feel.
If it doesn’t work as expected, check the trace to see what’s happening. If you can’t figure out what goes “wrong”, drop the yaml and I am (as are others) happy to help.
Ohh and just keep the old automations disabled as back-up for a while. If that step is too big, you could also decide to build the new automation and instead of having actual actions, just let them generate a log line, to check/confirm the working of it.
Hi,
I am just on my phone right now, so testing is hard for me.
But I have noticed in your code, that you are setting the duration of your timer to ‘0’.
I think trigger ids are your answer here. As @Recte says, assign a trigger id to each of the triggers, then in your actions > choose conditions, select ‘Trigger’ and input the trigger id (instead of using state conditions as you currently have).