So I have several automations to allow motion senors to turn the lights on from 7AM. However we’re now finding that we are having to get up at irregular times every day and would like a way to update the automation using the Next alarm feature.
How would I incorporate the following:
{% if states.sensor.sm_g950f_next_alarm != "unavailable" %}
{% set time = state_attr('sensor.sm_g950f_next_alarm', 'Local Time') %}
{% set alarm = time[11:16] %}
{% else %}
{% set alarm = "07:00" %}
{% endif %}
Into this automation:
alias: Turn the hall lights on when motion is detected (Day)
description: ''
trigger:
- platform: state
entity_id: binary_sensor.hall_motion_sensor_motion
from: 'off'
to: 'on'
condition:
- condition: time
after: '07:00'
before: '09:00'
- type: is_illuminance
condition: device
device_id: 4788d34a5d88474583a0da0085b54ef2
entity_id: sensor.hall_motion_sensor_light_level
domain: sensor
below: 300
action:
- type: turn_on
device_id: af8b1afde8904daebfa56904cc198027
entity_id: light.dimmable_light_1
domain: light
brightness_pct: 70
- type: turn_on
device_id: 4b75b9aeb54942a491982c0ed6fa890a
entity_id: light.dimmable_light_3
domain: light
brightness_pct: 70
- type: turn_on
device_id: 0d2f0c7607934c9090f4b16551d94577
entity_id: light.dimmable_light_2
domain: light
brightness_pct: 70
- delay: '00:01:30'
- type: brightness_decrease
device_id: af8b1afde8904daebfa56904cc198027
entity_id: light.dimmable_light_1
domain: light
- type: brightness_decrease
device_id: 4b75b9aeb54942a491982c0ed6fa890a
entity_id: light.dimmable_light_3
domain: light
- type: brightness_decrease
device_id: 0d2f0c7607934c9090f4b16551d94577
entity_id: light.dimmable_light_2
domain: light
- delay: '00:00:30'
- type: turn_off
device_id: af8b1afde8904daebfa56904cc198027
entity_id: light.dimmable_light_1
domain: light
- type: turn_off
device_id: 4b75b9aeb54942a491982c0ed6fa890a
entity_id: light.dimmable_light_3
domain: light
- type: turn_off
device_id: 0d2f0c7607934c9090f4b16551d94577
entity_id: light.dimmable_light_2
domain: light
mode: restart
max: 10