-
Notifications
You must be signed in to change notification settings - Fork 24
/
irrigation.yaml
237 lines (230 loc) · 6.18 KB
/
irrigation.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
#This is the ESPHome script, it goes to the esphome folder
substitutions:
rel1_gpio: GPIO12
rel2_gpio: GPIO5
rel3_gpio: GPIO4
rel4_gpio: GPIO15
key1_gpio: GPIO0
key2_gpio: GPIO9
key3_gpio: GPIO10
key4_gpio: GPIO14
rx_gpio: GPIO3
tx_gpio: GPIO1
esphome:
name: irrigation
comment: Sonoff 4ch PRO controlling 4 irrigation solenoid valves. With Nextion NX3224T024 display.
platform: ESP8266
board: esp01_1m
uart:
rx_pin: $rx_gpio
tx_pin: $tx_gpio
baud_rate: 9600
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
password: !secret api_password
ota:
password: !secret ota_password
logger:
# Disable UART logging (pins GPIO1/3 are used for communication with the display)
baud_rate: 0
sensor:
- platform: homeassistant
id: rain_today
entity_id: sensor.rain_today
on_value:
then:
- lambda: 'id(nextion_display).set_component_text_printf("sprinkler.rain_today","%.0f",x);'
- platform: homeassistant
id: rain_3_days
entity_id: sensor.rain_3_days
on_value:
then:
- lambda: 'id(nextion_display).set_component_text_printf("sprinkler.rain_3_days","%.0f",x);'
- platform: homeassistant
id: irrigation_24h
entity_id: variable.irrigation_24h
on_value:
then:
- lambda: 'id(nextion_display).set_component_text("sprinkler.irrigation_24h",(x>0)?"yes":"");'
display:
- platform: nextion
id: nextion_display
update_interval: 5s
lambda: |-
if (id(relay1).state) {
auto remaining_time = id(controller).time_remaining_active_valve().value_or(0);
if (remaining_time != 0) {
it.set_component_text_printf("sprinkler.time1","%02d:%02d",remaining_time/60,remaining_time%60);
}
}
if (id(relay2).state) {
auto remaining_time = id(controller).time_remaining_active_valve().value_or(0);
if (remaining_time != 0) {
it.set_component_text_printf("sprinkler.time2","%02d:%02d",remaining_time/60,remaining_time%60);
}
}
if (id(relay3).state) {
auto remaining_time = id(controller).time_remaining_active_valve().value_or(0);
if (remaining_time != 0) {
it.set_component_text_printf("sprinkler.time3","%02d:%02d",remaining_time/60,remaining_time%60);
}
}
if (id(relay4).state) {
auto remaining_time = id(controller).time_remaining_active_valve().value_or(0);
if (remaining_time != 0) {
it.set_component_text_printf("sprinkler.time4","%02d:%02d",remaining_time/60,remaining_time%60);
}
}
binary_sensor:
- platform: nextion
page_id: 0
component_id: 9
id: program1
on_press:
then:
- lambda: 'ESP_LOGD("main", "Starting program: full garden");'
- sprinkler.start_full_cycle: controller
- platform: nextion
page_id: 0
id: program2
component_id: 10
on_press:
then:
- lambda: 'ESP_LOGD("main", "Starting program: valve 1 & 2");'
- sprinkler.queue_valve:
id: controller
valve_number: 0
run_duration: 900s
- sprinkler.queue_valve:
id: controller
valve_number: 1
run_duration: 900s
- sprinkler.start_from_queue: controller
- platform: gpio
id: key1
pin:
number: $key1_gpio
mode: INPUT_PULLUP
inverted: True
filters:
- delayed_on: 100ms
on_press:
then:
if:
condition:
switch.is_off: relay1
then:
sprinkler.start_single_valve:
id: controller
valve_number: 0
else:
sprinkler.shutdown: controller
- platform: gpio
id: key2
pin:
number: $key2_gpio
mode: INPUT_PULLUP
inverted: True
filters:
- delayed_on: 100ms
on_press:
then:
if:
condition:
switch.is_off: relay2
then:
sprinkler.start_single_valve:
id: controller
valve_number: 1
else:
sprinkler.shutdown: controller
- platform: gpio
id: key3
pin:
number: $key3_gpio
mode: INPUT_PULLUP
inverted: True
filters:
- delayed_on: 100ms
on_press:
then:
if:
condition:
switch.is_off: relay3
then:
sprinkler.start_single_valve:
id: controller
valve_number: 2
else:
sprinkler.shutdown: controller
- platform: gpio
id: key4
pin:
number: $key4_gpio
mode: INPUT_PULLUP
inverted: True
filters:
- delayed_on: 100ms
on_press:
then:
if:
condition:
switch.is_off: relay4
then:
sprinkler.start_single_valve:
id: controller
valve_number: 3
else:
sprinkler.shutdown: controller
switch:
- platform: gpio
id: relay1
pin: $rel1_gpio
restore_mode: RESTORE_DEFAULT_OFF
on_turn_off:
then:
- lambda: |-
id(nextion_display).set_component_text("sprinkler.time1","");
- platform: gpio
id: relay2
pin: $rel2_gpio
restore_mode: RESTORE_DEFAULT_OFF
on_turn_off:
then:
- lambda: |-
id(nextion_display).set_component_text("sprinkler.time2","");
- platform: gpio
id: relay3
pin: $rel3_gpio
restore_mode: RESTORE_DEFAULT_OFF
on_turn_off:
then:
- lambda: |-
id(nextion_display).set_component_text("sprinkler.time3","");
- platform: gpio
id: relay4
pin: $rel4_gpio
restore_mode: RESTORE_DEFAULT_OFF
on_turn_off:
then:
- lambda: |-
id(nextion_display).set_component_text("sprinkler.time4","");
sprinkler:
- id: controller
main_switch: "Irrigation"
auto_advance_switch: "Auto Advance"
valves:
- valve_switch: "Valve 1"
run_duration: 900s
valve_switch_id: relay1
- valve_switch: "Valve 2"
run_duration: 900s
valve_switch_id: relay2
- valve_switch: "Valve 3"
run_duration: 900s
valve_switch_id: relay3
- valve_switch: "Valve 4"
run_duration: 900s
valve_switch_id: relay4