parent
e79a383586
commit
67224ed4a3
@ -0,0 +1,118 @@
|
||||
######################################################################
|
||||
# @CCOSTAN - Follow Me on X
|
||||
# For more info visit https://www.vcloudinfo.com/click-here
|
||||
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
||||
# -------------------------------------------------------------------
|
||||
# Kitchen Sink Circadian Light - all-day white tuning
|
||||
# Turns on after morning bed exits, follows the sun, and shuts down at bedtime.
|
||||
# -------------------------------------------------------------------
|
||||
# Notes: Uses color temperature only to avoid inherited color scenes.
|
||||
######################################################################
|
||||
|
||||
- alias: "Kitchen Sink Circadian Daylight"
|
||||
id: 29d81314-d4c3-4e62-8c1d-9f7f68bc7148
|
||||
mode: restart
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id:
|
||||
- binary_sensor.sleepnumber_carlo_carlo_is_in_bed
|
||||
- binary_sensor.sleepnumber_carlo_stacey_is_in_bed
|
||||
from: "on"
|
||||
to: "off"
|
||||
for: "00:05:00"
|
||||
id: bed_exit
|
||||
- platform: state
|
||||
entity_id:
|
||||
- binary_sensor.sleepnumber_carlo_carlo_is_in_bed
|
||||
- binary_sensor.sleepnumber_carlo_stacey_is_in_bed
|
||||
from: "off"
|
||||
to: "on"
|
||||
for: "00:05:00"
|
||||
id: bed_in
|
||||
- platform: sun
|
||||
event: sunrise
|
||||
offset: "-00:30:00"
|
||||
id: tune
|
||||
- platform: sun
|
||||
event: sunrise
|
||||
offset: "+01:00:00"
|
||||
id: tune
|
||||
- platform: sun
|
||||
event: sunset
|
||||
offset: "-01:00:00"
|
||||
id: tune
|
||||
- platform: sun
|
||||
event: sunset
|
||||
offset: "+00:30:00"
|
||||
id: tune
|
||||
- platform: time_pattern
|
||||
minutes: "/30"
|
||||
id: tune
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
id: tune
|
||||
|
||||
action:
|
||||
- variables:
|
||||
bedtime_active: >-
|
||||
{% set carlo_done = is_state('binary_sensor.sleepnumber_carlo_carlo_is_in_bed', 'on')
|
||||
or is_state('person.carlo', 'not_home') %}
|
||||
{% set stacey_done = is_state('binary_sensor.sleepnumber_carlo_stacey_is_in_bed', 'on')
|
||||
or is_state('person.stacey', 'not_home') %}
|
||||
{% set evening = is_state('sun.sun', 'below_horizon') or now().hour >= 20 or now().hour < 4 %}
|
||||
{{ evening and carlo_done and stacey_done }}
|
||||
awake_home: >-
|
||||
{% set carlo_awake = is_state('person.carlo', 'home')
|
||||
and is_state('binary_sensor.sleepnumber_carlo_carlo_is_in_bed', 'off') %}
|
||||
{% set stacey_awake = is_state('person.stacey', 'home')
|
||||
and is_state('binary_sensor.sleepnumber_carlo_stacey_is_in_bed', 'off') %}
|
||||
{{ carlo_awake or stacey_awake }}
|
||||
target_kelvin: >-
|
||||
{% set elevation = state_attr('sun.sun', 'elevation') | float(-90) %}
|
||||
{% if elevation <= -2 %}
|
||||
2600
|
||||
{% elif elevation < 8 %}
|
||||
{{ (2600 + ((elevation + 2) / 10 * 500)) | round(0) | int }}
|
||||
{% elif elevation < 25 %}
|
||||
{{ (3100 + ((elevation - 8) / 17 * 500)) | round(0) | int }}
|
||||
{% else %}
|
||||
3600
|
||||
{% endif %}
|
||||
target_brightness: >-
|
||||
{% set elevation = state_attr('sun.sun', 'elevation') | float(-90) %}
|
||||
{% if elevation <= -2 %}
|
||||
60
|
||||
{% elif elevation < 8 %}
|
||||
75
|
||||
{% elif elevation < 25 %}
|
||||
88
|
||||
{% else %}
|
||||
100
|
||||
{% endif %}
|
||||
- variables:
|
||||
manage_sink: >-
|
||||
{{ is_state('group.family', 'home')
|
||||
and is_state('input_boolean.guest_mode', 'off')
|
||||
and ((awake_home | bool) or is_state('light.sink', 'on'))
|
||||
and (is_state('light.sink', 'on') or now().hour >= 4) }}
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{{ bedtime_active | bool }}"
|
||||
sequence:
|
||||
- service: light.turn_off
|
||||
target:
|
||||
entity_id: light.sink
|
||||
data:
|
||||
transition: 60
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{{ manage_sink | bool }}"
|
||||
sequence:
|
||||
- service: light.turn_on
|
||||
target:
|
||||
entity_id: light.sink
|
||||
data:
|
||||
brightness_pct: "{{ target_brightness | int }}"
|
||||
color_temp_kelvin: "{{ target_kelvin | int }}"
|
||||
transition: 120
|
||||
Loading…
Reference in new issue