-
Notifications
You must be signed in to change notification settings - Fork 0
/
close_cover_vSep24.yaml
267 lines (267 loc) · 9.97 KB
/
close_cover_vSep24.yaml
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
blueprint:
name: Sun Protection vSep24 Enhanced
description: Enhanced blueprint to control cover based on sun position, temperature, weather conditions, and seasonal adjustments.
domain: automation
input:
cover_entity:
name: Cover
selector:
entity:
domain: cover
sun_position_start:
name: Sun Azimuth Start
description: Start azimuth value to trigger cover control
selector:
entity:
domain: input_number
sun_position_end:
name: Sun Azimuth End
description: End azimuth value to trigger cover control
selector:
entity:
domain: input_number
sun_elevation_start:
name: Sun Elevation Start
description: Minimum elevation to trigger cover control
selector:
entity:
domain: input_number
weather:
name: Weather Service
selector:
entity:
domain: weather
sensor:
name: Outdoor Sensor
selector:
entity:
domain: sensor
outdoor_temp_low:
name: Low Temperature Threshold
description: Shutters will close if outdoor temp is above this value
selector:
entity:
domain: input_number
outdoor_temp_medium:
name: Medium Temperature Threshold
description: Second temperature threshold for cover control
selector:
entity:
domain: input_number
outdoor_temp_high:
name: High Temperature Threshold
description: Third temperature threshold for cover control
selector:
entity:
domain: input_number
alarm_to_override:
name: Alarm Override for Weekdays
description: Time after which automation is active on weekdays
selector:
entity:
domain: input_datetime
alarm_weekend_to_override:
name: Alarm Override for Weekends
description: Time after which automation is active on weekends
selector:
entity:
domain: input_datetime
home_temperature:
name: Indoor Temperature Sensor
description: Sensor to compare indoor and outdoor temperature
selector:
entity:
domain: sensor
homews_isinstalled:
name: Home Weather Station Installed
description: Boolean to indicate if home weather station is available
selector:
entity:
domain: input_boolean
homews_temperature:
name: Home Weather Station Outdoor Temperature
selector:
entity:
domain: sensor
homews_rainrate:
name: Home Weather Station Rain Rate
selector:
entity:
domain: sensor
rainrate_pouring:
name: Pouring Rain Rate Threshold
selector:
entity:
domain: input_number
rainrate_rainy:
name: Rainy Rain Rate Threshold
selector:
entity:
domain: input_number
season_selector:
name: Season Selector
description: Select the current season to adjust thresholds accordingly
selector:
entity:
domain: sensor
light_sensor:
name: Optional Light Sensor
description: (Optional) Light sensor to measure ambient light levels
selector:
entity:
domain: sensor
default: none
variables:
cover_e: !input cover_entity
weather_e: !input weather
sun_azimuth: "{{ state_attr('sun.sun', 'azimuth') | float }}"
sun_elevation: "{{ state_attr('sun.sun', 'elevation') | float }}"
is_sunny: "{{ states(weather_e) in ['partlycloudy', 'sunny'] }}"
is_rainy: "{{ states(weather_e) == 'rainy' }}"
is_pouring: "{{ states(weather_e) == 'pouring' }}"
indoor_temp: "{{ states[home_temperature].state | float }}"
outdoor_temp: |-
{% if is_state('input_boolean.homews_isinstalled', 'on') %}
{{ states[homews_temperature].state | float }}
{% else %}
{{ state_attr(weather_e, 'temperature') | float }}
{% endif %}
rain_rate: |-
{% if is_state('input_boolean.homews_isinstalled', 'on') %}
{{ states[homews_rainrate].state | float }}
{% else %}
0
{% endif %}
current_season: "{{ states(season_selector) }}"
ambient_light: |-
{% if light_sensor != 'none' and states(light_sensor) %}
{{ states(light_sensor).state | float }}
{% else %}
1000 # Default value if no light sensor is provided
{% endif %}
trigger:
- platform: time_pattern
minutes: /15
- platform: template
value_template: "{{ sun_elevation > states.sun_elevation_start | float }}"
- platform: state
entity_id:
- weather_e
- platform: state
entity_id: season_selector
condition:
- condition: or
conditions:
- condition: template
value_template: '{% set current_time = now().strftime("%H:%M") %} {{
current_time > states[alarm_to_override].state and now().weekday() in
(1, 2, 3, 4, 5) }}'
- condition: template
value_template: '{% set current_time = now().strftime("%H:%M") %} {{
current_time > states[alarm_weekend_to_override].state and
now().weekday() in (0, 6) }}'
- condition: sun
before: sunset
after: sunrise
action:
- variables:
adjusted_outdoor_temp_low: >-
{% if current_season == 'summer' %}
{{ states.outdoor_temp_low | float * 1.1 }} # Example: Increase threshold by 10%
{% else %}
{{ states.outdoor_temp_low | float }}
{% endif %}
adjusted_outdoor_temp_medium: |-
{% if current_season == 'summer' %}
{{ states.outdoor_temp_medium | float * 1.1 }}
{% else %}
{{ states.outdoor_temp_medium | float }}
{% endif %}
adjusted_outdoor_temp_high: |-
{% if current_season == 'summer' %}
{{ states.outdoor_temp_high | float * 1.1 }}
{% else %}
{{ states.outdoor_temp_high | float }}
{% endif %}
light_level_threshold: 500
- choose:
- conditions:
- condition: template
value_template: "{{ sun_azimuth > states.sun_position_start | float and sun_azimuth < states.sun_position_end | float and sun_elevation > states.sun_elevation_start | float }}"
- condition: template
value_template: "{{ is_sunny }}"
- condition: template
value_template: "{{ outdoor_temp >= adjusted_outdoor_temp_high and outdoor_temp
> indoor_temp }}"
- condition: template
value_template: "{{ ambient_light > light_level_threshold }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.fully_closed_position'] | float }}"
- conditions:
- condition: template
value_template: "{{ sun_azimuth > states.sun_position_start | float and sun_azimuth < states.sun_position_end | float and sun_elevation > states.sun_elevation_start | float }}"
- condition: template
value_template: "{{ is_sunny }}"
- condition: template
value_template: "{{ outdoor_temp >= adjusted_outdoor_temp_medium and outdoor_temp < adjusted_outdoor_temp_high and outdoor_temp > indoor_temp }}"
- condition: template
value_template: "{{ ambient_light > light_level_threshold }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.intermediate_position'] | float }}"
- conditions:
- condition: template
value_template: "{{ sun_azimuth > states.sun_position_start | float and sun_azimuth < states.sun_position_end | float and sun_elevation > states.sun_elevation_start | float }}"
- condition: template
value_template: "{{ is_sunny }}"
- condition: template
value_template: "{{ outdoor_temp >= adjusted_outdoor_temp_low and outdoor_temp < adjusted_outdoor_temp_medium and outdoor_temp > indoor_temp }}"
- condition: template
value_template: "{{ ambient_light > light_level_threshold }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.mid_afternoon_position'] | float }}"
- conditions:
- condition: template
value_template: "{{ is_rainy and rain_rate >= states.rainrate_rainy | float and rain_rate < states.rainrate_pouring | float }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.open_position_rainy'] | float }}"
- conditions:
- condition: template
value_template: "{{ is_pouring and rain_rate >= states.rainrate_pouring | float }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.fully_closed_position'] | float }}"
- conditions:
- condition: template
value_template: "{{ (sun_azimuth < states.sun_position_start | float or sun_azimuth > states.sun_position_end | float or sun_elevation < states.sun_elevation_start | float) }}"
- condition: template
value_template: "{{ ambient_light < light_level_threshold }}"
- condition: template
value_template: "{{ (outdoor_temp < indoor_temp and outdoor_temp <= states.outdoor_temp_low | float) }}"
sequence:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.open_position'] | float }}"
default:
- action: cover.set_cover_position
data_template:
entity_id: "{{ cover_e }}"
position: "{{ states['var.open_position'] | float }}"
- action: notify.notify
data_template:
title: Cover Automation Update
message: "Cover {{ cover_e }} moved to position {{ state_attr(cover_e, 'current_position') }}."