I have the following two automations, which are working fine, but I’d like to merge them as I’d like to make them into a blueprint.
alias: Turn off kitchen light on no motion
description: ""
triggers:
- entity_id: binary_sensor.kitchen_sensor_occupancy
from: "on"
to: "off"
for:
seconds: 5
trigger: state
conditions:
- condition: state
entity_id: light.kitchen_light
state: "on"
actions:
- target:
entity_id: light.kitchen_light
data:
brightness: "{{ (state_attr('light.kitchen_light', 'brightness')|float) / 2 }}"
transition: 3
action: light.turn_on
- wait_template: "{{ is_state('binary_sensor.kitchen_sensor_occupancy', 'on') }}"
timeout:
seconds: 15
- if:
- condition: template
value_template: "{{ wait.completed }}"
then:
- target:
entity_id: light.kitchen_light
data:
brightness: "{{ (state_attr('light.kitchen_light', 'brightness')|float) * 2 }}"
transition: 3
action: light.turn_on
else:
- target:
entity_id: light.kitchen_light
action: light.turn_off
mode: single
alias: Turn on kitchen light on motion
description: ""
mode: single
triggers:
- trigger: state
entity_id:
- binary_sensor.kitchen_sensor_occupancy
from: "off"
to: "on"
condition:
- condition: state
entity_id: light.kitchen_light
state: 'off'
action:
- service: light.turn_on
target:
entity_id: light.kitchen_light
I’ve seen a couple of examples of merging automations but none with this particular use case of conditions mixed with if-then-elses. Any help or pointers is appreciated.