-
-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathkitchen_sink_circadian.yaml
More file actions
156 lines (154 loc) · 5.67 KB
/
Copy pathkitchen_sink_circadian.yaml
File metadata and controls
156 lines (154 loc) · 5.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
######################################################################
# @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.
# -------------------------------------------------------------------
# Related Issue: n/a
# Notes: Uses color temperature only to avoid inherited color scenes.
# TV playback keeps the sink off so media time does not re-light it.
# Notes: Office lamp switch off-gates the sink while active PC work is in progress.
# Notes: Kitchen Show illuminance gates only new automatic turn-ons. Once the
# sink is on, its normal circadian tuning continues without lux-based shutoff.
######################################################################
- 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: state
entity_id: media_player.living_room_ultra
to: "playing"
id: tv_playing
- platform: state
entity_id: switch.office_lamp_switch
to: "on"
id: working
- 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: numeric_state
entity_id: sensor.kitchen_show_ambient_light_2
below: 30
for: "00:05:00"
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 }}
tv_active: >-
{{ is_state('media_player.living_room_ultra', 'playing') }}
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 }}
working_active: >-
{{ is_state('switch.office_lamp_switch', 'on') }}
ambient_dark: >-
{% set lux = states('sensor.kitchen_show_ambient_light_2') %}
{{ lux in ['unknown', 'unavailable', 'none', '']
or lux | float(0) < 35 }}
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 not (tv_active | bool)
and not (working_active | bool)
and ((awake_home | bool) or is_state('light.sink', 'on'))
and (is_state('light.sink', 'on')
or ((ambient_dark | bool) and now().hour >= 4)) }}
- choose:
- conditions:
- condition: template
value_template: "{{ tv_active | bool or working_active | bool }}"
sequence:
- service: light.turn_off
target:
entity_id: light.sink
data:
transition: 60
- 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