Harden sleep and late-night lighting automations

pull/1898/head
Carlo Costanzo 1 month ago
parent 773f58513f
commit c43d3a805a

@ -32,6 +32,7 @@ Event-driven automations that sit outside the self-contained packages. These tie
| [![YAML source: dark_rainy_day](https://img.shields.io/static/v1?label=YAML&message=dark_rainy_day&color=lightgrey&logo=github&logoColor=181717)](dark_rainy_day.yaml) | Weather-aware lighting helper that also confirms the occupied first floor is actually dim through Kitchen Show illuminance. |
| [![YAML source: dash_buttons](https://img.shields.io/static/v1?label=YAML&message=dash_buttons&color=lightgrey&logo=github&logoColor=181717)](dash_buttons.yaml) | Amazon Dash buttons repurposed as quick triggers. |
| [![YAML source: good_night](https://img.shields.io/static/v1?label=YAML&message=good_night&color=lightgrey&logo=github&logoColor=181717)](good_night.yaml) | Whole-house shutdown and lock-up routine. |
| [![YAML source: late_night_brightness_guard](https://img.shields.io/static/v1?label=YAML&message=late_night_brightness_guard&color=lightgrey&logo=github&logoColor=181717)](late_night_brightness_guard.yaml) | Scoped 20:00-06:00 brightness cap for direct user-activated living-room and outdoor front-light groups; nested scene and automation contexts are excluded. |
### Tips
- Use these as patterns if you are migrating UI-created automations out of `automations.yaml`.

@ -16,6 +16,11 @@
for: "00:05:00"
condition:
- condition: state
entity_id:
- binary_sensor.sleepnumber_carlo_carlo_is_in_bed
- binary_sensor.sleepnumber_carlo_stacey_is_in_bed
state: 'off'
- condition: state
entity_id: group.family
state: home

@ -6,6 +6,8 @@
# Good Night Routine - bedtime shutdown and bed presence actions
# Powers down interior accents when the household is in bed.
# -------------------------------------------------------------------
# Notes: SleepIQ recovery from `unavailable` is not treated as a bed entry;
# amp wake-up requires both bed sensors to report explicit `off`.
######################################################################
- alias: 'Good Night Trigger'
@ -21,6 +23,7 @@
entity_id:
- binary_sensor.sleepnumber_carlo_carlo_is_in_bed
- binary_sensor.sleepnumber_carlo_stacey_is_in_bed
from: 'off'
to: 'on'
condition:
@ -77,6 +80,7 @@
entity_id:
- binary_sensor.sleepnumber_carlo_carlo_is_in_bed
- binary_sensor.sleepnumber_carlo_stacey_is_in_bed
from: 'off'
to: 'on'
id: "in_bed"
- platform: state
@ -109,6 +113,11 @@
data:
value: 0
default:
- condition: state
entity_id:
- binary_sensor.sleepnumber_carlo_carlo_is_in_bed
- binary_sensor.sleepnumber_carlo_stacey_is_in_bed
state: 'off'
- service: homeassistant.turn_on
target:
entity_id: switch.lr_amp

@ -0,0 +1,46 @@
######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Late-Night Brightness Guard - cap manual room/exterior group turn-ons.
# Protects late-night viewing and entry lighting from full-brightness jumps.
# -------------------------------------------------------------------
# Related Issue: 1879
# Notes: Allowlist is limited to living-room groups and outdoor front lights.
# Notes: Only direct user-context activations are capped; nested scenes and automations skip.
# Notes: Tune max_brightness_pct here; the 25% cap is intentionally local.
######################################################################
- alias: 'Late-Night Brightness Guard'
id: late_night_brightness_guard
mode: parallel
max: 3
variables:
max_brightness_pct: 25
trigger:
- platform: state
entity_id:
- light.living_room_lights
- light.living_room_accents
- light.outdoor_front_lights
from: 'off'
to: 'on'
condition:
- condition: time
after: '20:00:00'
before: '06:00:00'
- condition: template
value_template: >-
{{ trigger.to_state is not none
and (trigger.to_state.context.user_id | default('', true) | string | trim) != ''
and (trigger.to_state.context.parent_id | default('', true) | string | trim) == '' }}
- condition: template
value_template: >-
{{ trigger.entity_id == 'light.outdoor_front_lights'
or not is_state('media_player.living_room_ultra', 'playing') }}
action:
- service: light.turn_on
target:
entity_id: '{{ trigger.entity_id }}'
data:
brightness_pct: '{{ max_brightness_pct }}'

@ -4,48 +4,11 @@
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Living Room Color Defaults - cool white by day, amber by evening
# Restores after entry/garage secure and when lights are turned on.
# Restores after entry/garage secure; manual late-night turns use the guard.
# -------------------------------------------------------------------
# Notes: Returns to defaults after entry points close; keeps prior off states.
######################################################################
- alias: 'Living Room Defaults on Turn-On'
id: living_room_defaults_on_turn_on
mode: single
trigger:
- platform: state
entity_id:
- light.living_room_lights
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: group.entry_points
state: 'off'
- condition: state
entity_id: group.garage_doors
state: 'closed'
action:
- choose:
- conditions:
- condition: state
entity_id: sun.sun
state: 'above_horizon'
sequence:
- service: light.turn_on
target:
entity_id: light.living_room_lights
data:
color_temp_kelvin: 5500
brightness: 255
default:
- service: light.turn_on
target:
entity_id: light.living_room_lights
data:
color_temp_kelvin: 2700
brightness: 200
- alias: 'Restore Living Room After Entry Secured'
id: restore_living_room_after_entry_secured
mode: single

Loading…
Cancel
Save

Powered by TurnKey Linux.