forked from Beaky2000/esphome-p1mini
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p1mini.yaml
325 lines (309 loc) · 8.85 KB
/
p1mini.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
substitutions:
device_name: p1reader
device_password: !secret p1mini_password
device_api_key: !secret p1mini_api_key
esphome:
name: ${device_name}
includes:
- p1mini.h
esp8266:
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
#use_address: p1reader.local
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "esp-${device_name}"
password: "${device_password}"
captive_portal:
# Enable logging
logger:
level: Debug
baud_rate: 0 # disable logging over uart
# Enable Home Assistant API
api:
#password: "${device_password}" ### Deprecated
encryption:
key: "${device_api_key}"
ota:
password: "${device_password}"
web_server:
port: 80
ota: false
# auth:
# username: admin
# password: "${device_password}"
switch:
- platform: gpio
id: p1_cts
pin:
number: D2
- platform: gpio
id: status_led
pin:
number: D4
inverted: true
- platform: restart
name: "Restart P1 reader"
binary_sensor:
- platform: gpio
id: secondary_p1_rts
pin:
number: D0
mode: INPUT_PULLDOWN
inverted: false
uart:
id: uart_bus
tx_pin:
number: TX
inverted: true
mode: OUTPUT_OPEN_DRAIN
rx_pin:
number: RX
inverted: true
mode: INPUT_PULLUP
baud_rate: 115200
rx_buffer_size: 512 # Probably not needed, but it is good to have some margin.
number:
- platform: template
name: "${device_name} update period"
id: p1_period
icon: "mdi:timer"
unit_of_measurement: s
optimistic: true
restore_value: true
min_value: 0
max_value: 120
step: 1
initial_value: 30 # Set to your desired update period (in seconds)
internal: false # Set to true to hide setting from Home Assistant etc.
sensor:
- platform: wifi_signal
name: "${device_name} WiFi Signal"
update_interval: 10s
- platform: custom
lambda: |-
auto meter_sensor = new P1Reader(
id(uart_bus),
id(p1_period),
id(p1_cts),
id(status_led),
id(secondary_p1_rts)
);
App.register_component(meter_sensor);
return {
meter_sensor->AddSensor( 1, 8, 0),
meter_sensor->AddSensor( 1, 8, 1),
meter_sensor->AddSensor( 1, 8, 2),
meter_sensor->AddSensor( 1, 8, 3),
meter_sensor->AddSensor( 1, 8, 4),
meter_sensor->AddSensor( 2, 8, 0),
meter_sensor->AddSensor( 2, 8, 1),
meter_sensor->AddSensor( 2, 8, 2),
meter_sensor->AddSensor( 2, 8, 3),
meter_sensor->AddSensor( 2, 8, 4),
meter_sensor->AddSensor( 3, 8, 0),
meter_sensor->AddSensor( 3, 8, 1),
meter_sensor->AddSensor( 3, 8, 2),
meter_sensor->AddSensor( 3, 8, 3),
meter_sensor->AddSensor( 3, 8, 4),
meter_sensor->AddSensor( 4, 8, 0),
meter_sensor->AddSensor( 4, 8, 1),
meter_sensor->AddSensor( 4, 8, 2),
meter_sensor->AddSensor( 4, 8, 3),
meter_sensor->AddSensor( 4, 8, 4),
meter_sensor->AddSensor( 1, 7, 0),
meter_sensor->AddSensor( 2, 7, 0),
meter_sensor->AddSensor( 3, 7, 0),
meter_sensor->AddSensor( 4, 7, 0),
meter_sensor->AddSensor(14, 7, 0),
meter_sensor->AddSensor(15, 7, 0),
meter_sensor->AddSensor(21, 7, 0),
meter_sensor->AddSensor(22, 7, 0),
meter_sensor->AddSensor(41, 7, 0),
meter_sensor->AddSensor(42, 7, 0),
meter_sensor->AddSensor(61, 7, 0),
meter_sensor->AddSensor(62, 7, 0),
meter_sensor->AddSensor(23, 7, 0),
meter_sensor->AddSensor(24, 7, 0),
meter_sensor->AddSensor(43, 7, 0),
meter_sensor->AddSensor(44, 7, 0),
meter_sensor->AddSensor(63, 7, 0),
meter_sensor->AddSensor(64, 7, 0),
meter_sensor->AddSensor(32, 7, 0),
meter_sensor->AddSensor(52, 7, 0),
meter_sensor->AddSensor(72, 7, 0),
meter_sensor->AddSensor(31, 7, 0),
meter_sensor->AddSensor(51, 7, 0),
meter_sensor->AddSensor(71, 7, 0)
};
sensors:
- name: "Cumulative Active Import"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Active Import rate 1"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Active Import rate 2"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Active Import rate 3"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Active Import rate 4"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Active Export"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Active Export rate 1"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Active Export rate 2"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Active Export rate 3"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Active Export rate 4"
unit_of_measurement: kWh
accuracy_decimals: 3
state_class: "total_increasing"
device_class: "energy"
- name: "Cumulative Reactive Import"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Cumulative Reactive Import rate 1"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Cumulative Reactive Import rate 2"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Cumulative Reactive Import rate 3"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Cumulative Reactive Import rate 4"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Cumulative Reactive Export"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Cumulative Reactive Export rate 1"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Cumulative Reactive Export rate 2"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Cumulative Reactive Export rate 3"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Cumulative Reactive Export rate 4"
unit_of_measurement: kvarh
accuracy_decimals: 3
- name: "Momentary Active Import"
unit_of_measurement: kW
accuracy_decimals: 3
- name: "Momentary Active Export"
unit_of_measurement: kW
accuracy_decimals: 3
- name: "Momentary Reactive Import"
unit_of_measurement: kvar
accuracy_decimals: 3
- name: "Momentary Reactive Export"
unit_of_measurement: kvar
accuracy_decimals: 3
- name: "Momentary net Frequency"
unit_of_measurement: Hz
filters:
- multiply: 1000
accuracy_decimals: 1
- name: "Momentary Active Power"
unit_of_measurement: W
filters:
- multiply: 1000
accuracy_decimals: 1
- name: "Momentary Active Import Phase 1"
unit_of_measurement: kW
accuracy_decimals: 3
- name: "Momentary Active Export Phase 1"
unit_of_measurement: kW
accuracy_decimals: 3
- name: "Momentary Active Import Phase 2"
unit_of_measurement: kW
accuracy_decimals: 3
- name: "Momentary Active Export Phase 2"
unit_of_measurement: kW
accuracy_decimals: 3
- name: "Momentary Active Import Phase 3"
unit_of_measurement: kW
accuracy_decimals: 3
- name: "Momentary Active Export Phase 3"
unit_of_measurement: kW
accuracy_decimals: 3
- name: "Momentary Reactive Import Phase 1"
unit_of_measurement: kvar
accuracy_decimals: 3
- name: "Momentary Reactive Export Phase 1"
unit_of_measurement: kvar
accuracy_decimals: 3
- name: "Momentary Reactive Import Phase 2"
unit_of_measurement: kvar
accuracy_decimals: 3
- name: "Momentary Reactive Export Phase 2"
unit_of_measurement: kvar
accuracy_decimals: 3
- name: "Momentary Reactive Import Phase 3"
unit_of_measurement: kvar
accuracy_decimals: 3
- name: "Momentary Reactive Export Phase 3"
unit_of_measurement: kvar
accuracy_decimals: 3
- name: "Voltage Phase 1"
unit_of_measurement: V
filters:
- multiply: 1000
accuracy_decimals: 1
- name: "Voltage Phase 2"
unit_of_measurement: V
filters:
- multiply: 1000
accuracy_decimals: 1
- name: "Voltage Phase 3"
unit_of_measurement: V
filters:
- multiply: 1000
accuracy_decimals: 1
- name: "Current Phase 1"
unit_of_measurement: A
filters:
- multiply: 1000
accuracy_decimals: 1
- name: "Current Phase 2"
unit_of_measurement: A
filters:
- multiply: 1000
accuracy_decimals: 1
- name: "Current Phase 3"
unit_of_measurement: A
filters:
- multiply: 1000
accuracy_decimals: 1