I have been tinkering about with my first automation, and got to a point where I have it working as expected.
The automation is a very common one where I have a motion sensor, and based on some conditions like time/illuminance, it’s going to turn the light on/off in a specific way.
This automation does that for my hallway downstairs. Now I want to create the ‘exact same’ automation but for my hallways on floor 1 and 2.
This would mean I’d have to change the motionsensor, light, and input_boolean helper.
What would be the ‘proper’ way of handling this? I could just duplicate it twice and replace it, but I feel like that is not a good way of going about this.
alias: Hal Motion
triggers:
- trigger: state
entity_id:
- binary_sensor.hal_motionsensor_occupancy
to: "on"
id: motion_on
- trigger: state
entity_id:
- binary_sensor.hal_motionsensor_occupancy
to: "off"
id: motion_off
for:
seconds: 45
conditions: []
actions:
- choose:
- conditions:
- condition: and
conditions:
- condition: trigger
id:
- motion_on
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.hal_motionsensor_illuminance
below: 3000
- condition: state
entity_id: input_boolean.fadinglight_hal
state: "on"
sequence:
- if:
- condition: time
after: "08:00:00"
before: "23:00:00"
then:
- action: light.turn_on
data:
color_temp: 400
brightness: 200
transition: 1
target:
device_id: 7ca63b6e63913d8ca702311ec3270954
else:
- action: light.turn_on
data:
color_temp: 400
brightness: 30
transition: 1
target:
device_id: 7ca63b6e63913d8ca702311ec3270954
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.fadinglight_hal
- conditions:
- condition: trigger
id:
- motion_off
sequence:
- action: light.turn_off
metadata: {}
data:
transition: 15
target:
device_id: 7ca63b6e63913d8ca702311ec3270954
- action: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.fadinglight_hal
mode: restart