-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathweatherstation.yaml
414 lines (380 loc) · 10.6 KB
/
weatherstation.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
.script_flashing: !include &flashing libraries/scripts/flashing.yaml
substitutions:
name: weatherstation
friendly_name: "Weather Station"
esphome:
name: $name
platform: ESP32
board: pico32
on_boot:
priority: -10
then:
- script.execute: flashing
<<: !include network.yaml
captive_portal:
ota:
password: !secret password
api:
password: !secret password
sun:
latitude: !secret latitude
longitude: !secret longitude
logger:
i2c:
frequency: 100kHz
sda: GPIO26
scl: GPIO25
script:
- <<: *flashing
sensor:
- platform: pulse_meter
pin:
# Don't forget to add a pulling resistor, see README
number: GPIO34
mode: INPUT
id: wind_speed
unit_of_measurement: 'm/s'
name: "${friendly_name} wind speed"
icon: 'mdi:weather-windy'
internal_filter: 13us
timeout: 5s
filters:
- multiply: 0.005560619
- sliding_window_moving_average:
window_size: 20
send_every: 20
- platform: copy
name: '${friendly_name} wind speed average'
icon: 'mdi:weather-windy'
id: wind_speed_avg
source_id: wind_speed
unit_of_measurement: 'm/s'
filters:
- throttle_average: 5s
- platform: copy
name: '${friendly_name} wind speed (km/h)'
id: wind_speed_kmh
source_id: wind_speed
unit_of_measurement: 'km/h'
icon: 'mdi:weather-windy'
filters:
- multiply: 3.6
- platform: copy
name: '${friendly_name} wind speed average (km/h)'
icon: 'mdi:weather-windy'
id: wind_speed_kmh_avg
source_id: wind_speed_avg
unit_of_measurement: 'km/h'
filters:
- multiply: 3.6
on_value:
lambda: |-
if (x < 1) {
id(wind_scale_code).publish_state("0");
id(wind_scale).publish_state("Calm");
} else if (x >= 1 && x < 6) {
id(wind_scale_code).publish_state("1");
id(wind_scale).publish_state("Light Air");
} else if (x >= 6 && x < 12) {
id(wind_scale_code).publish_state("2");
id(wind_scale).publish_state("Light Breeze");
} else if (x >= 12 && x < 20) {
id(wind_scale_code).publish_state("3");
id(wind_scale).publish_state("Gentle Breeze");
} else if (x >= 20 && x < 29) {
id(wind_scale_code).publish_state("4");
id(wind_scale).publish_state("Moderate Breeze");
} else if (x >= 29 && x < 39) {
id(wind_scale_code).publish_state("5");
id(wind_scale).publish_state("Fresh Breeze");
} else if (x >= 39 && x < 50) {
id(wind_scale_code).publish_state("6");
id(wind_scale).publish_state("Strong Breeze");
} else if (x >= 50 && x < 62) {
id(wind_scale_code).publish_state("7");
id(wind_scale).publish_state("Near Gale");
} else if (x >= 62 && x < 75) {
id(wind_scale_code).publish_state("8");
id(wind_scale).publish_state("Gale");
} else if (x >= 75 && x < 89) {
id(wind_scale_code).publish_state("9");
id(wind_scale).publish_state("Severe Gale");
} else if (x >= 89 && x < 103) {
id(wind_scale_code).publish_state("10");
id(wind_scale).publish_state("Storm");
} else if (x >= 103 && x < 118) {
id(wind_scale_code).publish_state("11");
id(wind_scale).publish_state("Violent Storm");
} else if (x >= 118) {
id(wind_scale_code).publish_state("12");
id(wind_scale).publish_state("Hurricane Force");
} else {
ESP_LOGD("main", "It shouldn't happen (wind_speed_kmh_avg: %f)", x);
}
- platform: pulse_counter
pin:
# Don't forget to add a pulling resistor, see README
number: GPIO38
mode: INPUT
unit_of_measurement: 'mm'
name: "${friendly_name} rain gauge"
icon: 'mdi:weather-rainy'
id: rain_gauge
internal: true
count_mode:
rising_edge: DISABLE
falling_edge: INCREMENT
internal_filter: 13us
update_interval: 60s
filters:
# Each 0.011" (0.2794mm) of rain causes one momentary contact closure
- multiply: 0.2794
accuracy_decimals: 4
- platform: integration
name: "${friendly_name} rainfall per min"
id: rain_per_min
time_unit: min
unit_of_measurement: 'mm'
icon: 'mdi:weather-rainy'
sensor: rain_gauge
- platform: total_daily_energy
name: "${friendly_name} total daily rain"
power_id: rain_gauge
unit_of_measurement: 'mm'
icon: 'mdi:weather-rainy'
# x60 To convert to aggregated rain amount
filters:
- multiply: 60
- platform: bme280
address: 0x76
update_interval: 60s
iir_filter: 16x
temperature:
name: "${friendly_name} temperature"
id: bme280_temperature
oversampling: 16x
humidity:
name: "${friendly_name} humidity"
id: bme280_humidity
oversampling: 16x
pressure:
name: "${friendly_name} pressure"
id: bme280_pressure
oversampling: 16x
- platform: tsl2561
name: "${friendly_name} ambient Light"
address: 0x39
update_interval: 60s
integration_time: 14ms
gain: 1x
- platform: adc
pin: GPIO35
name: "${friendly_name} input voltage"
icon: mdi:car-battery
attenuation: 11db
accuracy_decimals: 2
filters:
- calibrate_linear:
- 3.24 -> 12.01
- 2.80 -> 10.78
- platform: adc
id: source_sensor
pin: GPIO37
name: ADC
attenuation: 11db
internal: true
update_interval: 5s
accuracy_decimals: 1
filters:
- multiply: 0.846153 # 3.9 -> 3.3V
- platform: ina219
address: 0x40
shunt_resistance: 0.1 ohm
current:
name: "${friendly_name} solar current"
power:
name: "${friendly_name} solar power"
id: solar_power
bus_voltage:
name: "${friendly_name} solar voltage"
icon: mdi:car-battery
shunt_voltage:
name: "${friendly_name} solar shunt voltage"
max_voltage: 26V
max_current: 3.2A
update_interval: 60s
- platform: total_daily_energy
name: "${friendly_name} total daily solar energy"
power_id: solar_power
unit_of_measurement: "Wh"
accuracy_decimals: 2
- platform: resistance
sensor: source_sensor
id: resistance_sensor
configuration: DOWNSTREAM
resistor: 10kOhm
internal: true
name: Resistance Sensor
reference_voltage: 3.9V
accuracy_decimals: 1
filters:
- median:
window_size: 7
send_every: 4
send_first_at: 3
#- heartbeat: 30s
on_value:
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 15000
below: 15500
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "N"
- sensor.template.publish:
id: wind_heading
state: 0.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 5000
below: 5500
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "NE"
- sensor.template.publish:
id: wind_heading
state: 45.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 350
below: 450
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "E"
- sensor.template.publish:
id: wind_heading
state: 90.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 1200
below: 1400
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "SE"
- sensor.template.publish:
id: wind_heading
state: 135.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 2400
below: 2500
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "S"
- sensor.template.publish:
id: wind_heading
state: 180.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 8900
below: 9200
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "SW"
- sensor.template.publish:
id: wind_heading
state: 225.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 37500
below: 38500
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "W"
- sensor.template.publish:
id: wind_heading
state: 270.0
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 24400
below: 25000
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "NW"
- sensor.template.publish:
id: wind_heading
state: 315.0
- platform: template
name: "${friendly_name} wind heading"
id: wind_heading
unit_of_measurement: "°"
- platform: sun
name: "${friendly_name} Sun elevation"
type: elevation
update_interval: 120s
- platform: sun
name: "${friendly_name} Sun azimuth"
type: azimuth
update_interval: 120s
text_sensor:
- platform: template
name: "${friendly_name} wind cardinal direction"
id: wind_dir_card
- platform: sun
name: "${friendly_name} next sunrise"
type: sunrise
update_interval: 4h
- platform: sun
name: "${friendly_name} next sunset"
type: sunset
update_interval: 4h
- platform: template
name: '${friendly_name} Beaufort wind scale'
icon: 'mdi:tailwind'
id: wind_scale
update_interval: never
- platform: template
name: '${friendly_name} Beaufort wind scale code'
icon: 'mdi:tailwind'
id: wind_scale_code
light:
- platform: fastled_clockless
chipset: WS2812
id: status_light
name: "${friendly_name} status light"
pin: GPIO2
num_leds: 1
rgb_order: GRB
restore_mode: ALWAYS_OFF
interval:
- interval: 60s
then:
- sensor.integration.reset: rain_per_min
# Enable time component to reset energy at midnight
time:
- platform: sntp
timezone: "Europe/Paris"