-
Notifications
You must be signed in to change notification settings - Fork 30
/
wm-nodemcu-test.yaml
executable file
·421 lines (379 loc) · 13.2 KB
/
wm-nodemcu-test.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
415
416
417
418
419
420
421
---
## ------------------------------------------------------------------
## WMBUS NODEMCU V3 + CC1101 for Diehl IZAR RC 868 I R4 PL
## HARDWARE: NODEMCU V3 ESP8266 80MHz, 80KB RAM, 4MB Flash
##
## CC1101 TESTCASE FOR ALL WATERMETERS
##
## usage: 1. Using Homassistant API (discovery + devices)
## 2. Optional uses backup component
## 3. Optinal usese syslog component
##
## This version shows data from the all watermeters.
## Use this for frist test to find your watermeterID.
##
## DO NOT USE THIS CONFIGURATION FOR PRODUCTION
##
## WEBUI: http://water-meter-nmc.local
## Backup: http://water-meter-nmc.local/config.yaml
## curl -v 'http://water-meter-nmc.local/config.yaml' --digest -u USERNAME:PASSWORD -o config.yaml
## SYSLOG: tail -f /var/log/syslog | grep "water-meter"
##
## ------------------------------------------------------------------
substitutions:
## device settings
device_name_short: "water-meter-nmc"
device_description: "Wasserzähler NODEMCU V3 + CUL - CC1101, IZAR module (Diehl IZAR RC 868 I R4 PL (SzczepanLeon) - all Watermeters"
projectname: "Diehl IZAR RC 868.Watermeter"
appversion: "2.0.7"
## logger settings
log_level: "DEBUG" # not that logging need memory, so in production mode use "WARN"
log_wmbus: "DEBUG" # Loglevel for wmbus meters component
log_baudrate: "0" # 0 disable uart logger messages
# ----------------------------------------------------------------
# HARDWARE: NODEMCU V3 ESP8266 80MHz, 80KB RAM, 4MB Flash
# ----------------------------------------------------------------
esp8266:
board: nodemcuv2
restore_from_flash: true
## ----------------------------------------------------------------
## ESPHOME APPLICATION
## ----------------------------------------------------------------
esphome:
name: ${device_name_short}
comment: ${device_description}
# Automatically add the mac address to the name
# so you can use a single firmware for all devices
name_add_mac_suffix: false
project:
name: ${projectname}
version: ${appversion}
build_path: ./build/${device_name_short}
on_boot:
priority: -100.00
then:
- globals.set:
id: boot_counter
value: !lambda "return id(boot_counter)+=1;"
- logger.log:
level: INFO
tag: "system"
format: "BOOTMESSAGE:${device_name_short} API is connected, Device ready!"
- component.update: bootcounter
on_shutdown:
priority: 700
then:
- logger.log:
level: ERROR
tag: "system"
format: "BOOTMESSAGE:${device_name_short} is down!"
## ----------------------------------------------------------------
## External components
## ----------------------------------------------------------------
external_components:
# uses the latest version from SzczepanLeon
# https://github.com/SzczepanLeon/esphome-components
# You can make ESPHome check the repository every time by setting this option to 0s
- source: github://SzczepanLeon/esphome-components@main
refresh: 0s
components: [wmbus]
# use local component from
# https://github.com/zdzichu6969/esphome-components
- source:
type: local
path: custom_components
components: [backup]
# use local component from
# https://github.com/TheStaticTurtle/esphome_syslog
# - source:
# type: local
# path: custom_components
# components: [syslog]
## ---------------------------------------------------
## syslog service
## tail -f /var/log/syslog | grep "water-meter"
## ---------------------------------------------------
# syslog:
# ip_address: !secret syslog_server
# port: !secret syslog_port
# min_level: DEBUG
# enable_logger: true
# ----------------------------------------------------------------
# Save your ESPHome device configuration in firmware and and
# recover it if you lost source files.
# ----------------------------------------------------------------
backup:
auth:
username: !secret web_username
password: !secret web_password
force_update: false
## ----------------------------------------------------------------
## Global variables
## ----------------------------------------------------------------
globals:
- id: boot_counter
type: int
restore_value: yes
initial_value: "0"
## ---------------------------------------------------
## WIFI Settings 3 wifis
## ---------------------------------------------------
wifi:
id: wifi_nodemcu
networks:
- ssid: !secret ssid3_name
password: !secret ssid3_pswd
priority: 0
- ssid: !secret ssid1_name
password: !secret ssid1_pswd
priority: 1
- ssid: !secret ssid2_name
password: !secret ssid2_pswd
priority: 2
domain: !secret domain
## ---------------------------------------------------
## mDNS Component
## ---------------------------------------------------
mdns:
# if mDNS is disabled, they will no longer be able to automatically find your devices.
disabled: false
## ---------------------------------------------------
## The captive portal component in ESPHome is a
## fallback mechanism for when connecting to the
## configured WiFi fails.
## ---------------------------------------------------
captive_portal:
## ---------------------------------------------------
## LOGGER COMPONENT
## ---------------------------------------------------
logger:
id: appslogger
level: ${log_level}
baud_rate: ${log_baudrate}
logs:
wmbus: ${log_wmbus}
wMBus-lib: ${log_wmbus}
## ---------------------------------------------------
## OTA COMPONENT
## ---------------------------------------------------
ota:
password: !secret ota_pswd
safe_mode: false
on_begin:
then:
- logger.log:
format: "OTA Start"
tag: "OTA"
level: WARN
on_progress:
then:
- logger.log:
level: WARN
tag: "OTA"
format: "OTA progress %0.1f%%"
args: ["x"]
on_end:
then:
- logger.log:
format: "OTA End"
tag: "OTA"
level: WARN
on_error:
then:
- logger.log:
format: "OTA update error %d"
tag: "OTA"
level: ERROR
args: ["x"]
## ---------------------------------------------------
## COMPONENT WEBSERVER
## ---------------------------------------------------
web_server:
port: 80
version: 2
js_url: !secret webserver_jsurl
## ---------------------------------------------------
## Home Assistant API COMPONENT
## ---------------------------------------------------
api:
id: espapnuc
port: 6053
reboot_timeout: 0s
## ---------------------------------------------------
## SNTP COMPONENT
## ---------------------------------------------------
time:
- platform: sntp
id: time_sntp
timezone: Europe/Berlin
servers:
- 0.at.pool.ntp.org
- 0.pool.ntp.org
- 1.pool.ntp.org
on_time_sync:
then:
- logger.log:
tag: "system"
level: INFO
format: "Synchronized sntp clock"
## ------------------------------------------------------------------
## WMBUS CC1101 --> NODEMCU V3
## ------------------------------------------------------------------
##
##
## GDO0 MOSI
## 7 MISO 3
## o GD02 CLK 5 o CSN
## | 6 4 o | 8 ╭-------o 2 (GND)
## | o o | | o | ╭----o 1 (3.3V)
## | | | | | | | |
## ╭――x――o――o――x――x――x――o――o――o――o――x――x――x――o――o―╮
## | D1 D2 D5 D6 D7 D8 |
## | |
## - | ANT NODEMCU V3 | -- USB
## | |
## | |
## ╰――x――x――x――x――x――x――x――x――x――x――x――x――x――x――x―╯
##
##
##
## ------------------------------------------------------------------
wmbus:
mosi_pin: GPIO13 #D7 3: MOSI Attached to Hardware SPI controller MOSI SPI Interface
miso_pin: GPIO12 #D6 5: MISO Attached to Hardware SPI controller MISO SPI Interface
clk_pin: GPIO14 #D5 4: SCK Attached to Hardware SPI controller CLK
cs_pin: GPIO15 #D8 8: CSN Attached to Hardware SPI controller, Controls Boot Mode; CS SPI Interface 10k Pull-Down, boot fails if pulled high !!!
gdo0_pin: GPIO05 #D1 7: Clock output. High Impedance !
gdo2_pin: GPIO04 #D2 6: FIFO status signals. High Impedance !
# log_unknown (Optional): Show telegrams from not configured meters in log. Defaults to False
log_unknown: True
## ---------------------------------------------------
## SWITCHES
## ---------------------------------------------------
switch:
# reset boot counter value
- platform: template
name: "Device Reset Boot Counter"
turn_on_action:
then:
- lambda: |-
id(boot_counter) = 0;
id(bootcounter).publish_state(id(boot_counter));
- logger.log:
level: WARN
tag: "system"
format: "${device_name_short} reset boot counter o.k!"
- component.update: bootcounter
- platform: restart
name: "Device Restart"
id: restart_switch
# save device boot (develop only)
- platform: safe_mode
name: "Device Restart (Safe Mode)"
# reset the device to factory reset (develop only)
- platform: factory_reset
name: "Device Restart Factory"
## ---------------------------------------------------
## SENSORS
## ---------------------------------------------------
sensor:
- platform: wmbus
# Meter ID (usually from sticker). Can be specified as decimal or hex.
# only hex is working for my watermeter !
# see: https://github.com/SzczepanLeon/esphome-components/issues/6
# edit watermeterid in the secrets file
# settings to add the watermeterid to the lqi, rssi and total_water_m3
meter_id: "0" # !secret watermeterId
type: izar
add_prefix: true
# The LQI value reported by the CC1101 is a 7 bit unsigned number with a range from 0 to 127.
# Note that a lower value indicates a better link.
# The LQI of a received packet will be bad (higher number) when there is lot of interference.
lqi:
id: wmbus_cc1101_lqi
name: "WLAN CC1101 LQI"
entity_category: "diagnostic"
unit_of_measurement: "lqi"
# The RSSI value reported by the CC1101 is a 8 bit signed number with an effective
# range from -138 dBm to -10.5 dBm when the CC1101 is operating around 868 MHz.
# RSSI stands for received signal strength (power) indication (in dBm).
# A higher value indicates higher power. (internal only)
rssi:
name: "WLAN CC1101 RSSI"
id: wmbus_cc1101_rssi
unit_of_measurement: "%"
entity_category: "diagnostic"
# waterdisplay - get the total watermter m3 from the wmbus telegram
total_water_m3:
name: "Watermeter Display"
id: "waterdisplay"
unit_of_measurement: "m³"
state_class: total_increasing
device_class: "water"
accuracy_decimals: 3
on_value:
then:
- lambda: |-
ESP_LOGI("wmbus", "Water Display value: %f", id(waterdisplay).state);
# water current month (wM-Bus v2.1.4)
current_month_total_water_l:
name: "Watermeter current month"
id: "watermonth"
accuracy_decimals: 2
unit_of_measurement: "L"
state_class: total_increasing
device_class: "water"
# get the last month total watermter m3 from the wmbus telegram (wM-Bus 2.1.10)
last_month_total_water_m3:
name: "Water last month"
id: "waterdisplay_lastmonth"
unit_of_measurement: "m³"
state_class: total_increasing
device_class: "water"
accuracy_decimals: 3
icon: mdi:counter
# get the battery life time (wM-Bus v2.1.4)
remaining_battery_life_y:
name: "Watermeter battery life"
id: "watermeter_batterie"
entity_category: "diagnostic"
icon: mdi:battery
# get the last transmit periode (wM-Bus v2.1.4)
transmit_period_s:
name: "Watermeter transmit periode"
id: "watermeter_last_reading"
entity_category: "diagnostic"
icon: mdi:timelapse
current_alarms:
id: "watermeter_current_alarms"
name: "Watermeter current alarm"
entity_category: "diagnostic"
icon: mdi:alarm-light
previous_alarms:
id: "watermeter_prev_alarms"
name: "Watermeter previous alarm"
entity_category: "diagnostic"
icon: mdi:alarm-light
# Wifi quality RSSI used by wifi_signal_db
- platform: wifi_signal
id: wifi_signal_db
update_interval: 60s
internal: true
disabled_by_default: true
# Wifi quality RSSI in percentage
# Received Signal Strength (RSSI) is a measure of incoherent (raw) RF power in a channel.
- platform: copy # Reports the WiFi signal strength in %
source_id: wifi_signal_db
name: "Device WLAN RSSI"
filters:
- lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
unit_of_measurement: "%"
entity_category: "diagnostic"
# device boot counter
- platform: template
name: Device Boot counter
id: bootcounter
accuracy_decimals: 0
state_class: "measurement"
entity_category: "diagnostic"
lambda: return (id(boot_counter));