-
Notifications
You must be signed in to change notification settings - Fork 2
/
weatherstation-roof.yaml
333 lines (308 loc) · 9.5 KB
/
weatherstation-roof.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
esphome:
name: weatherstation-roof
platform: ESP32
board: esp32dev
substitutions:
loc: "Roof"
name: "Weather Station"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pw
fast_connect: on
power_save_mode: none
manual_ip:
static_ip: ###.###.###.###
gateway: ###.###.###.###
subnet: ###.###.###.###
ap:
ssid: ${name} Fallback
password: !secret fallback_pw
captive_portal:
logger:
#level: INFO
api:
encryption:
key: "###"
ota:
password: !secret api_pw
# ==============================================================================
# Sensors Configuration
# ==============================================================================
# ------------------------------------------------------------------------------
# Wind Speed
# ------------------------------------------------------------------------------
sensor:
- platform: pulse_meter
pin:
number: GPIO14
mode: INPUT_PULLUP
name: '${loc} Windspeed Meter'
icon: 'mdi:weather-windy'
id: wind_meter
device_class: "wind_speed"
state_class: "measurement"
unit_of_measurement: 'mph'
accuracy_decimals: 1
timeout: 2s # Default 5s
filters:
- multiply: 0.0124285 # 1.492mph per rotation so 1 / 60 / 2 * 1.491424
- throttle_average: 2s # Send average windspeed every 2 seconds, this
# seems to be the consensus on weather forums
# for recording this data.
# https://www.wxforum.net/index.php?topic=41489.0
# ------------------------------------------------------------------------------
# Rainfall
# ------------------------------------------------------------------------------
- platform: pulse_meter
pin:
number: GPIO32
mode: INPUT_PULLUP
name: "${loc} Rainfall Per Hour"
id: rain_meter
icon: "mdi:weather-rainy"
internal_filter: 500ms
timeout: 45min
device_class: "precipitation_intensity"
state_class: "total_increasing"
unit_of_measurement: "in/h"
accuracy_decimals: 2
filters:
- multiply: 1.224 # Calibration, 0.0204 * 60 for pulses/hour
total:
name: "${loc} Total Daily Rainfall"
id: total_daily_rainfall
icon: "mdi:beaker-outline"
device_class: "precipitation"
state_class: "total_increasing"
unit_of_measurement: "in"
accuracy_decimals: 4
filters:
- multiply: 0.0204 # Calibration
on_value:
then:
# Only increment total_rainfall_counter on rain (not on reset at midnight)
- lambda: |-
if (id(total_daily_rainfall).state != 0) {
id(total_rainfall_counter) += 1;
}
- sensor.template.publish:
id: total_rainfall
state: !lambda 'return id(total_rainfall_counter);'
- platform: template
name: "${loc} Total Rainfall"
id: total_rainfall
update_interval: never
unit_of_measurement: "in"
icon: "mdi:beaker-outline"
device_class: "precipitation"
state_class: "total_increasing"
accuracy_decimals: 4
# Will output total amount of rain over the uptime of the sensor
# but we use the count in Home Assistant to get statistics
filters:
- multiply: 0.0204
# ------------------------------------------------------------------------------
# Wind Direction
# ------------------------------------------------------------------------------
- platform: adc
id: adc_sensor
attenuation: 11db
pin: GPIO35
name: ADC
internal: true
update_interval: 5s
filters:
- offset: 0.023 # Calibration
accuracy_decimals: 3 ##IMPORTANT to get resolution for resistance sensor
### ADD WIND CARIDNAL DIRECTION
### Your values may differ!
# Direction -- Resistance -- ADC Voltage
# TODO:
# N -- 33KΩ -- 2.56v
# NE -- 8.2KΩ -- 1.5v
# E -- 1KΩ -- 0.30v
# SE -- 2.2KΩ -- 0.6v
# S -- 3.9KΩ -- 0.93v
# SW -- 16KΩ -- 2.05v
# W -- 120KΩ -- 3.07v
# NW -- 64.9KΩ -- 2.89v
- platform: resistance
sensor: adc_sensor
id: resistance_sensor
configuration: DOWNSTREAM
resistor: 10kOhm
internal: true
name: Resistance Sensor
accuracy_decimals: 1
on_value:
- if:
condition:
sensor.in_range:
id: resistance_sensor
above: 30000
below: 50000
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: 10000
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: 500
below: 1500
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: 1500
below: 3000
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: 3000
below: 5000
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: 10000
below: 30000
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: 110000
below: 140000
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: 50000
below: 80000
then:
- text_sensor.template.publish:
id: wind_dir_card
state: "NW"
- sensor.template.publish:
id: wind_heading
state: 315.0
- platform: template
name: "${loc} Wind Heading"
icon: 'mdi:compass-rose'
id: wind_heading
unit_of_measurement: "°"
accuracy_decimals: 0
update_interval: never
# ==============================================================================
# Misc Sensors
# ==============================================================================
- platform: wifi_signal
name: ${loc} Signal
update_interval: 60s
# Allows the rainfall to be changed or reset from the frontend if necessary.
- platform: homeassistant
id: total_daily_rainfall_adjustment
internal: true
entity_id: input_number.roof_total_daily_rainfall_adjustment
accuracy_decimals: 2
# ==============================================================================
# Text Sensors
# ==============================================================================
text_sensor:
- platform: template
name: "${loc} Wind Cardinal Direction"
icon: "mdi:windsock"
id: wind_dir_card
update_interval: never
# ==============================================================================
# Buttons Configuration
# ==============================================================================
button:
- platform: template
name: "${loc} Reset Total Daily Rainfall"
icon: "mdi:beaker-remove-outline"
on_press:
then:
- pulse_meter.set_total_pulses:
id: rain_meter
value: 0
- platform: template
name: "${loc} Apply Total Daily Rainfall Adjustment"
icon: "mdi:beaker-check-outline"
on_press:
then:
- logger.log:
format: "Adjustment: %.2f"
args: [ 'id(total_daily_rainfall_adjustment).state' ]
- pulse_meter.set_total_pulses:
id: rain_meter
value: !lambda 'return id(total_daily_rainfall_adjustment).state / 0.0204;' # rainfall/calibration to set this to total number of pulses
time:
- platform: homeassistant
id: esptime
on_time:
- seconds: 0
minutes: 0
hours: 0
then:
- pulse_meter.set_total_pulses:
id: rain_meter
value: 0
globals:
# Total runnning rainfall counter
- id: total_rainfall_counter
type: int
initial_value: '0'