-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsmr_reader_custom_config
261 lines (246 loc) · 7 KB
/
dsmr_reader_custom_config
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
# Custom config for Marcel Zuidwijk his DSMR reader.
# used wifi secrets tomatch my config and secrets for API OTA passwords (added)
# using different names (from official docs) and kW(h) for everything (not Watt)
# added sum sensors to calc low and high tarif into 1 sensor per consumed / returend.
# added throtteling for some less important metrics like voltage and per phase prod (not total) to 10s instead of 1s updates.
---
substitutions:
device_name: p1_dsmr_zuidwijk
device_description: "DIY P1 module to read your smart meter - customized MvdB Version"
#external_components:
# - source: github://zuidwijk/dsmr
esphome:
name: ${device_name}
comment: "${device_description}"
platform: ESP8266
esp8266_restore_from_flash: true
board: d1_mini
name_add_mac_suffix: false
project:
name: zuidwijk.slimmelezer
version: "1.0"
on_boot:
then:
- if:
condition:
lambda: return id(has_key);
then:
- lambda: |-
std::string key(id(stored_decryption_key), 32);
id(dsmr_instance).set_decryption_key(key);
else:
- logger.log:
level: info
format: "Not using decryption key. If you need to set a key use Home Assistant service 'ESPHome: ${device_name}_set_dsmr_key'"
wifi:
ssid: !secret wifi_ssid_iot
password: !secret wifi_password_iot
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${device_name}
ap_timeout: 15s
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret esphome_local
services:
service: set_dsmr_key
variables:
private_key: string
then:
- logger.log:
format: Setting private key %s. Set to empty string to disable
args: [private_key.c_str()]
- globals.set:
id: has_key
value: !lambda "return private_key.length() == 32;"
- lambda: |-
if (private_key.length() == 32)
private_key.copy(id(stored_decryption_key), 32);
id(dsmr_instance).set_decryption_key(private_key);
ota:
password: !secret esphome_local
web_server:
port: 80
uart:
baud_rate: 115200
rx_pin: D7
globals:
- id: has_key
type: bool
restore_value: yes
initial_value: "false"
- id: stored_decryption_key
type: char[32]
restore_value: yes
dsmr:
id: dsmr_instance
sensor:
- platform: dsmr
energy_delivered_tariff1:
name: "Consumption Low Tarif"
id: "energy_delivered_t1"
state_class: total_increasing
unit_of_measurement: kWh
accuracy_decimals: 3
icon: "mdi:flash"
energy_delivered_tariff2:
name: "Consumption High Tarif"
id: "energy_delivered_t2"
state_class: total_increasing
unit_of_measurement: kWh
accuracy_decimals: 3
icon: "mdi:flash"
energy_returned_tariff1:
name: "Return Low Tarif"
id: "energy_returned_t1"
state_class: total_increasing
unit_of_measurement: kWh
accuracy_decimals: 3
icon: "mdi:flash-outline"
energy_returned_tariff2:
name: "Return High Tarif"
id: "energy_returned_t2"
state_class: total_increasing
unit_of_measurement: kWh
accuracy_decimals: 3
icon: "mdi:flash-outline"
power_delivered:
name: "Power Consumption"
unit_of_measurement: kW
accuracy_decimals: 3
icon: "mdi:flash"
power_returned:
name: "Power Production"
unit_of_measurement: kW
accuracy_decimals: 3
icon: "mdi:flash-outline"
electricity_failures:
name: "Power failures in any phase"
icon: mdi:alert
electricity_long_failures:
name: "Long power failures in any phase"
icon: mdi:alert
voltage_l1:
name: "Instant Voltage L1"
unit_of_measurement: V
accuracy_decimals: 1
icon: "mdi:flash"
filters:
- throttle: 10s
voltage_l2:
name: "Instant Voltage L2"
unit_of_measurement: V
accuracy_decimals: 1
icon: "mdi:flash"
filters:
- throttle: 10s
voltage_l3:
name: "Instant Voltage L3"
unit_of_measurement: V
accuracy_decimals: 1
icon: "mdi:flash"
filters:
- throttle: 10s
current_l1:
name: "Instant Current L1"
unit_of_measurement: A
accuracy_decimals: 0 #this is at Amp resolution according to specs. So no milli A.
icon: "mdi:current-ac"
current_l2:
name: "Instant Current L2"
unit_of_measurement: A
accuracy_decimals: 0 #this is at Amp resolution according to specs. So no milli A.
icon: "mdi:current-ac"
current_l3:
name: "Instant Current L3"
unit_of_measurement: A
accuracy_decimals: 0 #this is at Amp resolution according to specs. So no milli A.
icon: "mdi:current-ac"
power_delivered_l1:
name: "Power Consumption Phase L1"
unit_of_measurement: kW
accuracy_decimals: 3
filters:
- throttle: 10s
power_delivered_l2:
name: "Power Consumption Phase L2"
unit_of_measurement: kW
accuracy_decimals: 3
filters:
- throttle: 10s
power_delivered_l3:
name: "Power Consumption Phase L3"
unit_of_measurement: kW
accuracy_decimals: 3
filters:
- throttle: 10s
power_returned_l1:
name: "Power Production Phase L1"
unit_of_measurement: kW
accuracy_decimals: 3
filters:
- throttle: 10s
power_returned_l2:
name: "Power Production Phase L2"
unit_of_measurement: kW
accuracy_decimals: 3
filters:
- throttle: 10s
power_returned_l3:
name: "Power Production Phase L3"
unit_of_measurement: kW
accuracy_decimals: 3
filters:
- throttle: 10s
gas_delivered:
name: "Gas Consumption"
state_class: total_increasing
unit_of_measurement: m³
icon: "mdi:fire"
- platform: uptime
name: "Uptime"
- platform: wifi_signal
name: "Wi-Fi Signal"
update_interval: 60s
- platform: template
id: energy_delivered_total
name: "Consumption Total"
state_class: total_increasing
unit_of_measurement: "kWh"
lambda: |-
return ( id(energy_delivered_t1).state + id(energy_delivered_t2).state );
accuracy_decimals: 3
update_interval: 10s
icon: "mdi:flash"
- platform: template
id: energy_returned_total
name: "Return Total"
state_class: total_increasing
unit_of_measurement: "kWh"
lambda: |-
return ( id(energy_returned_t1).state + id(energy_returned_t2).state );
accuracy_decimals: 3
update_interval: 10s
icon: "mdi:flash-outline"
text_sensor:
- platform: dsmr
identification:
name: "DSMR Identification"
p1_version:
name: "DSMR Version"
p1_version_be:
name: "DSMR Version Belgium"
- platform: wifi_info
ip_address:
name: "IP Address"
ssid:
name: "Wi-Fi SSID"
bssid:
name: "Wi-Fi BSSID"
- platform: version
name: "ESPHome Version"
hide_timestamp: true