-
Notifications
You must be signed in to change notification settings - Fork 2
/
controllers.yaml
270 lines (265 loc) · 9.37 KB
/
controllers.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
268
269
270
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2023 Ilia Sotnikov
---
esphome:
# Required for proper resume handling and avoiding crash at startup when
# winter mode enabled
min_version: '2023.10.0'
sprinkler:
- id: lawn_sprinklers
main_switch:
name: "Lawn sprinklers"
icon: "mdi:sprinkler"
id: lawn_sprinklers_main_switch
on_turn_on:
- lambda: |-
#ifdef HAS_DISPLAY
if (${display_id}->is_ready()) {
${display_id}->show_page(${display_page_when_active});
}
${display_backlight_id}->turn_on();
#endif
- lambda: |-
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_on();
call.perform();
#endif
on_turn_off:
- !include
file: script_refill_tank.yaml
vars:
sprinkler: lawn_sprinklers
relay: ${peripherals_power_off_relay_id}
condition: >-
!id(disable_water_tank_refill).state
&& !id(water_tank_refill_after_each_valve).state
- lambda: |-
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_off();
call.perform();
#endif
- lambda: |-
#ifdef HAS_DISPLAY
${display_backlight_id}->turn_off();
#endif
auto_advance_switch: "Lawn sprinklers Auto Advance"
standby_switch:
name: "Pause lawn sprinklers"
id: lawn_sprinklers_standby_switch
internal: true
valve_overlap: ${valve_overlap}
pump_start_pump_delay: ${pump_start_pump_delay}
pump_stop_valve_delay: ${pump_stop_valve_delay}
valves:
- valve_switch:
name: "South lawn"
icon: "mdi:sprinkler"
on_turn_off: !include
file: script_refill_tank.yaml
vars:
sprinkler: lawn_sprinklers
relay: ${peripherals_power_off_relay_id}
condition: >-
!id(disable_water_tank_refill).state
&& id(water_tank_refill_after_each_valve).state
enable_switch: "Enable south lawn"
run_duration_number:
name: "South lawn run duration"
icon: "mdi:timer"
initial_value: ${run_duration_initial_value}
restore_value: true
unit_of_measurement: ${run_duration_uom}
valve_switch_id: relay_1
pump_switch_id: ${pump_relay_id}
- valve_switch:
name: "North lawn"
icon: "mdi:sprinkler"
on_turn_off: !include
file: script_refill_tank.yaml
vars:
sprinkler: lawn_sprinklers
relay: ${peripherals_power_off_relay_id}
condition: >-
!id(disable_water_tank_refill).state
&& id(water_tank_refill_after_each_valve).state
enable_switch: "Enable north lawn"
run_duration_number:
name: "North lawn run duration"
icon: "mdi:timer"
initial_value: ${run_duration_initial_value}
restore_value: true
unit_of_measurement: ${run_duration_uom}
valve_switch_id: relay_2
pump_switch_id: ${pump_relay_id}
- valve_switch:
name: "West lawn"
icon: "mdi:sprinkler"
on_turn_off: !include
file: script_refill_tank.yaml
vars:
sprinkler: lawn_sprinklers
relay: ${peripherals_power_off_relay_id}
condition: >-
!id(disable_water_tank_refill).state
&& id(water_tank_refill_after_each_valve).state
enable_switch: "Enable west lawn"
run_duration_number:
name: "West lawn run duration"
icon: "mdi:timer"
initial_value: ${run_duration_initial_value}
restore_value: true
unit_of_measurement: ${run_duration_uom}
valve_switch_id: relay_3
pump_switch_id: ${pump_relay_id}
- id: flowerbed_sprinklers
main_switch:
name: "Flowerbed sprinklers"
icon: "mdi:sprinkler"
id: flowerbed_sprinklers_main_switch
on_turn_on:
- lambda: |-
#ifdef HAS_DISPLAY
if (${display_id}->is_ready()) {
${display_id}->show_page(${display_page_when_active});
}
${display_backlight_id}->turn_on();
#endif
- lambda: |-
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_on();
call.perform();
#endif
on_turn_off:
- !include
file: script_refill_tank.yaml
vars:
sprinkler: flowerbed_sprinklers
relay: ${peripherals_power_off_relay_id}
condition: >-
!id(disable_water_tank_refill).state
&& !id(water_tank_refill_after_each_valve).state
- lambda: |-
#ifdef HAS_RGB_LED
auto call = ${led_id}->turn_off();
call.perform();
#endif
- lambda: |-
#ifdef HAS_DISPLAY
${display_backlight_id}->turn_off();
#endif
auto_advance_switch: "Flowerbed sprinklers Auto Advance"
standby_switch:
name: "Pause flowerbed sprinklers"
id: flowerbed_sprinklers_standby_switch
internal: true
valve_overlap: ${valve_overlap}
pump_start_pump_delay: ${pump_start_pump_delay}
pump_stop_valve_delay: ${pump_stop_valve_delay}
valves:
- valve_switch:
name: "South flowerbed"
icon: "mdi:sprinkler"
on_turn_off: !include
file: script_refill_tank.yaml
vars:
sprinkler: flowerbed_sprinklers
relay: ${peripherals_power_off_relay_id}
condition: >-
!id(disable_water_tank_refill).state
&& id(water_tank_refill_after_each_valve).state
enable_switch: "Enable south flowerbed"
run_duration_number:
name: "South flowerbed run duration"
icon: "mdi:timer"
initial_value: ${run_duration_initial_value}
restore_value: true
unit_of_measurement: ${run_duration_uom}
valve_switch_id: relay_4
pump_switch_id: ${pump_relay_id}
- valve_switch:
name: "West flowerbed"
icon: "mdi:sprinkler"
on_turn_off: !include
file: script_refill_tank.yaml
vars:
sprinkler: flowerbed_sprinklers
relay: ${peripherals_power_off_relay_id}
condition: >-
!id(disable_water_tank_refill).state
&& id(water_tank_refill_after_each_valve).state
enable_switch: "Enable west flowerbed"
run_duration_number:
name: "West flowerbed"
icon: "mdi:timer"
initial_value: ${run_duration_initial_value}
restore_value: true
unit_of_measurement: ${run_duration_uom}
valve_switch_id: relay_5
pump_switch_id: ${pump_relay_id}
switch:
- platform: template
id: disable_water_tank_refill
name: "Disable water tank refill"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: water_tank_refill_after_each_valve
name: "Water tank refill after each valve"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
- platform: template
id: winter_mode
name: "Winter mode"
icon: "mdi:snowflake"
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
turn_on_action:
- lambda: |-
// Shutdown active operations on controllers if any
id(lawn_sprinklers).shutdown();
id(flowerbed_sprinklers).shutdown();
// Put controllers into standby
id(lawn_sprinklers_standby_switch).turn_on();
id(flowerbed_sprinklers_standby_switch).turn_on();
#ifdef HAS_SCHEDULE
// Disable scheduled runs
lawn_sprinklers_disabled->turn_on();
flowerbed_sprinklers_disabled->turn_on();
#endif
// Turn off peripherals power (water level relay and alike)
id(${peripherals_power_off_relay_id}).turn_on();
turn_off_action:
- lambda: |-
// Move controllers out of standby mode
id(flowerbed_sprinklers_standby_switch).turn_off();
id(lawn_sprinklers_standby_switch).turn_off();
#ifdef HAS_SCHEDULE
// Enabled scheduled runs
lawn_sprinklers_disabled->turn_off();
flowerbed_sprinklers_disabled->turn_off();
#endif
// Enable peripherals power
id(${peripherals_power_off_relay_id}).turn_off();
// Update the state of the winter mode switch, so that any code checks
// for its state actually sees it disabled (during the trigger the
// `state` variable will still be `on` until trigger's code
// completes
id(winter_mode).publish_state(false);
# Re-publish the state of rain and water tank empty sensors, so that
# controllers reflect their actual state
- lambda: !include
file: script_rain_water_tank_sensors_action.yaml
vars:
triggered_by: winter_mode
button:
- platform: template
name: "Lawn sprinklers: shutdown"
on_press:
- sprinkler.shutdown: lawn_sprinklers
- platform: template
name: "Flowerbed sprinklers: shutdown"
on_press:
- sprinkler.shutdown: flowerbed_sprinklers