My favorite automation is the one I use to dim the bathroom lights at bedtime (11:00 pm) until sunrise. This way, if I get up in the middle of the night to go use the bathroom, I’m not blinded by the brightness of the lights, which are (5) 60w-equivalent dimmable LED bulbs.
Because I am using the GE 12724 dimmer, the switch won’t accept a value change unless the light actually is actually on. So the automations turn the light on to the desired brightness, wait 1 second, then turn it off. The wall switch simply recalls the last-used brightness setting by default. In order to make this work, I have the lights adjust to 1% (3/255) at 11:00 pm. At sunrise, they are restored to 100% (255/255). Both automations utilize an input boolean switch such that if the bathroom light is on, the automations will be delayed until 10 seconds after the light is turned off.
Here are my YAML files to make this work:
automations_bathroom_2300_light_off.yaml
alias: "bathroom_2300_light_off"
trigger:
platform: state
entity_id: light.bathroom_light_level_2_0
from: 'on'
to: 'off'
condition:
condition: and
conditions:
- condition: time
after: "23:00:00"
- condition: state
entity_id: input_boolean.bathroom_light_in_use
state: 'on'
action:
- service: homeassistant.turn_off
entity_id: input_boolean.bathroom_light_in_use
- service: logbook.log
data:
name: "Automation Triggered: "
message: "bathroom_2300_light_off"
automations_bathroom_2300_light_off.yaml
alias: "bathroom_2300_light_on"
trigger:
platform: time
after: "23:00:00"
condition:
condition: state
entity_id: light.bathroom_light_level_2_0
state: 'on'
action:
- service: homeassistant.turn_on
entity_id: input_boolean.bathroom_light_in_use
- service: logbook.log
data:
name: "Automation Triggered: "
message: "bathroom_2300_light_on"
automations_bathroom_2300_scene.yaml
alias: "bathroom_2300_scene"
trigger:
platform: time
after: "23:00:00"
condition:
condition: state
entity_id: light.bathroom_light_level_2_0
state: 'off'
action:
- service: scene.turn_on
entity_id: scene.scenes_bathroom_on_3
- delay: '00:00:01'
- service: scene.turn_on
entity_id: scene.scenes_bathroom_off
- service: logbook.log
data:
name: "Automation Triggered: "
message: "bathroom_2300_scene"
automations_bathroom_2300_scene_delayed.yaml
alias: "bathroom_2300_scene_delayed"
trigger:
platform: state
entity_id: input_boolean.bathroom_light_in_use
from: 'on'
to: 'off'
condition:
condition: time
after: "23:00:00"
action:
- delay: '00:00:10'
- service: scene.turn_on
entity_id: scene.scenes_bathroom_on_3
- delay: '00:00:01'
- service: scene.turn_on
entity_id: scene.scenes_bathroom_off
- service: logbook.log
data:
name: "Automation Triggered: "
message: "bathroom_2300_scene_delayed"
scenes_bathroom_off.yaml
- name: scenes_bathroom_off
entities:
light.bathroom_light_level_2_0:
state: 'off'
scenes_bathroom_on_3.yaml
- name: scenes_bathroom_on_3
entities:
light.bathroom_light_level_2_0:
state: 'on'
brightness: 3
scenes_bathroom_on_255.yaml
- name: scenes_bathroom_on_255
entities:
light.bathroom_light_level_2_0:
state: 'on'
brightness: 255