Oke, dit is het project tot nu toe, wat nog extra komt is een opentherm module en sketch zodat ik de thermostaat kan beïnvloeden. De modbus kan alles nu aansturen van de warmtepomp behalve de CV onderdelen want de toros heeft zelf geen idee van de temperatuur dat komt van de thermostaat.
Behalve dat is nu wel de toros te beïnvloeden op tapwater, je kan bv als er geen zon is de setpoint dynamisch verlagen zodat er geen tapwater gemaakt wordt en als de zon schijnt dit te verhogen. Werkt erg leuk
Dit is de electronica die gebruikt is, erg simpel, een esp32, een max485 bordje en een IR detector (ik heb er met 1 detector led) voor de kWH meter.
Als er geen communicatie is dan de aansluitingen A en B naar de modbus verwisselen. Ik moest ook uiteindelijk de 120ohm weerstand verwijderen, de bus had een te lage weerstand en slechte communicatie
Nu de ESPHome sketch;
Naast de modbus code gebruik ik ook een pulsmeter voor de kWh meter in de toros vision. Die code kan je natuurlijk verwijderen en heb je ook de extra bestanden niet nodig onder 'packages'
code:
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
| # Toros Vision warmtepomp interface via Modbus en kWh pulsmeter
esphome:
name: toros-modbuskwh
min_version: 2024.11.0
name_add_mac_suffix: false
platform: ESP32
board: nodemcu-32s #esp32dev
packages:
basis: !include ./components/basis.yaml
updates: !include ./components/updates.yaml
status: !include ./components/status_led.yaml
pulse: !include ./components/pulse_meter.yaml
substitutions:
# Define the GPIO pins
pulse_pin: GPIO5
status_led: GPIO2 #D4
friendly_name: WP Modbus kwh meter
# disable logging
logger:
baud_rate: 0
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
wifi:
ssid: "Access Point SSID"
password: "Access Point wachtwoord"
web_server:
uart:
tx_pin: GPIO17
rx_pin: GPIO16
baud_rate: 19200
modbus:
id: modbus1
flow_control_pin: GPIO4
modbus_controller:
- id: modbus_device
address: 0x1 ## address of the Modbus slave device on the bus
modbus_id: modbus1
setup_priority: -10
update_interval: 30s
# Number (slider) input voor WP settings zoals de tapwater temperatuur
# hiermee kan misschien ook de switch functie gebruikt worden met modbus control om later te toggelen tussen temps bij zon bv.
number:
- platform: modbus_controller #template
modbus_controller_id: modbus_device
name: "Gewenste Tapwater temp"
id: tapwater_setpoint_ha
address: 0x817A
register_type: holding
value_type: U_WORD
entity_category: config
icon: mdi:chart-bell-curve
min_value: 35
max_value: 55
step: 1
mode: slider #box
lambda: "return x; "
write_lambda: |-
return x;
- platform: modbus_controller #template
modbus_controller_id: modbus_device
name: "Tapwater ECO minimum"
id: tapwater_eco_setpoint_ha
address: 0x8264
register_type: holding
value_type: U_WORD
entity_category: config
icon: mdi:chart-bell-curve
min_value: 30
max_value: 45
step: 1
mode: slider #box
lambda: "return x; "
write_lambda: |-
return x;
- platform: modbus_controller #template
modbus_controller_id: modbus_device
name: "Tapwater Max daling temp:"
id: tapwater_hysterese_ha
address: 0x817B
register_type: holding
value_type: U_WORD
entity_category: config
icon: mdi:chart-bell-curve
min_value: 2
max_value: 12
step: 1
mode: slider #box
lambda: "return x; "
write_lambda: |-
return x;
sensor:
- platform: modbus_controller
modbus_controller_id: modbus_device
id: status
name: "Status WP"
address: 0x539E
register_type: holding
value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: modbus_device
id: zomer_winter_stand
name: "Zomer-winter-stand. 0 = winter"
address: 0x81E6
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: actual_error
name: "Actuale storing"
address: 0x0032
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: vergrendeld
name: "Vergrendeld"
address: 0x0032
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: lage_druk_schakelaar
name: "Lage druk schakelaar"
address: 0x30CE
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: hoge_druk_schakelaar
name: "Hoge druk schakelaar"
address: 0x30CE
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: max_t_cpr
name: "MaxT CPR"
address: 0xF12B
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: max_t_ee
name: "MaxT EE"
address: 0xF830
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: ec1
name: "EC1"
address: 0xF12A
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: ec2
name: "EC2"
address: 0xFA70
register_type: holding
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: afgiftesysteem
name: "Afgiftesysteem(min:sec)"
address: 0xF37C
register_type: holding
unit_of_measurement: "sec"
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: pompen
name: "Pompen(min:sec)"
address: 0xF37A
register_type: holding
unit_of_measurement: "sec"
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: warmtepomp
name: "Warmtepomp(sec)"
address: 0xF364
register_type: holding
unit_of_measurement: "sec"
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: cpr_aan_aan
name: "CPR AAN-AAN (min:sec)"
address: 0xF37E
register_type: holding
unit_of_measurement: "sec"
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: cpr_uit_aan
name: "CPR UIT_AAN (min:sec)"
address: 0xF380
register_type: holding
unit_of_measurement: "sec"
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: cpr_aan_uit
name: "CPR AAN-UIT(min:sec)"
address: 0xF382
register_type: holding
unit_of_measurement: "sec"
value_type: U_WORD
accuracy_decimals: 0
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: tbu_buiten_actueel
name: "Temp Buitensensor"
address: 0x35F7
register_type: holding
unit_of_measurement: "°C"
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: modbus_device
id: ttw_tapwater
name: "Tapwater actueel"
address: 0x3561
register_type: holding
unit_of_measurement: "°C"
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
- platform: modbus_controller
modbus_controller_id: modbus_device
id: tapwater_setpoint
name: "Tapwater Gewenst"
address: 0x817A
register_type: holding
unit_of_measurement: "°C"
value_type: U_WORD
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: modbus_device
id: tapwater_eco_setpoint
name: "Tapwater ECO minimum"
address: 0x8264
register_type: holding
unit_of_measurement: "°C"
value_type: U_WORD
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: modbus_device
id: tapwater_hysterese
name: "Tapwater Max Daling"
address: 0x817B
register_type: holding
unit_of_measurement: "°C"
value_type: U_WORD
accuracy_decimals: 1
- platform: template
id: tapwater_minimum_ha
name: "Tapwater minimum temp"
unit_of_measurement: "°C"
lambda: "return id(tapwater_setpoint_ha).state - id(tapwater_hysterese).state;"
- platform: modbus_controller
modbus_controller_id: modbus_device
id: mengpositie_klep
name: "Mengpositie klep (%)"
address: 0x1DB6
register_type: holding
unit_of_measurement: "%"
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 1.0
- platform: modbus_controller
modbus_controller_id: modbus_device
id: tbr_bron_wp_in
name: "TBR Bron WP IN"
address: 0x5AAB
register_type: holding
unit_of_measurement: "C"
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
# de kWh registers bevatten waardes voor 2 parameters. De highbit van het d_WORD is nodig en wordt via de lambda berekend
- platform: modbus_controller
modbus_controller_id: modbus_device
id: standby_kwh
name: "kWh Standby"
address: 0x5334
register_type: holding
unit_of_measurement: "kWh"
value_type: U_WORD
lambda: |-
uint16_t value = x;
uint16_t highbit = (value >> 8) & 0xFF;
return highbit;
- platform: modbus_controller
modbus_controller_id: modbus_device
id: tapwater_kwh
name: "kWh Tapwater"
address: 0x533B
register_type: holding
unit_of_measurement: "kWh"
value_type: U_WORD
lambda: |-
uint16_t value = x;
uint16_t highbit = (value >> 8) & 0xFF;
return highbit;
# warmte kWh zit in de lowbits van het register.
- platform: modbus_controller
modbus_controller_id: modbus_device
id: warmte_kwh
name: "kWh Warmte"
address: 0x5352
register_type: holding
unit_of_measurement: "kWh"
value_type: U_WORD
lambda: |-
uint16_t value = x;
uint16_t lowbit = value & 0xFF;
return lowbit;
- platform: modbus_controller
modbus_controller_id: modbus_device
id: actief_koel_kWh
name: "kWh Koel"
address: 0x5361
register_type: holding
unit_of_measurement: "kWh"
value_type: U_WORD
lambda: |-
uint16_t value = x;
uint16_t highbit = (value >> 8) & 0xFF;
return highbit;
- platform: modbus_controller
modbus_controller_id: modbus_device
id: passief_koel_kWh
name: "kWh Koel passief"
address: 0x535D
register_type: holding
unit_of_measurement: "kWh"
value_type: U_WORD
lambda: |-
uint16_t value = x;
uint16_t lowbit = value & 0xFF;
return lowbit;
- platform: modbus_controller
modbus_controller_id: modbus_device
id: totaal_kwh
name: "kWh Totaal"
address: 0x6557
register_type: holding
unit_of_measurement: "kWh"
value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: modbus_device
id: actief_tap_uren
name: "Actief Tap Uren"
address: 0x53C4
register_type: holding
unit_of_measurement: "uur"
value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: modbus_device
id: actief_CV_uren
name: "Actief CV Uren"
address: 0x5532
register_type: holding
unit_of_measurement: "uur"
value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: modbus_device
id: actief_koel_uren
name: "Actief Koel Uren"
address: 0x5597
register_type: holding
unit_of_measurement: "uur"
value_type: U_WORD
- platform: modbus_controller
modbus_controller_id: modbus_device
id: passief_koel_uren
name: "Passief Koel Uren"
address: 0x5567
register_type: holding
unit_of_measurement: "uur"
value_type: U_WORD
# Vertalen van waardes naar tekst
text_sensor:
- platform: modbus_controller
modbus_controller_id: modbus_device
name: "Status"
id: status_string
address: 0x539E
register_type: holding
lambda: |-
uint16_t value = id(status).state;
switch (value) {
case 1: return std::string("Stand-By");
case 2: return std::string("Passief Tapwater");
case 4: return std::string("Actief Tapwater voor");
case 8: return std::string("Passief CV");
case 16: return std::string("Actief CV voor");
case 32: return std::string("Passief Koelen");
case 64: return std::string("Regenereren");
case 256: return std::string("Noodbedrijf TapW");
case 512: return std::string("Noodbedrijf CV");
case 1028: return std::string("Actief TapWater");
case 1040: return std::string("Actief CV");
default: return std::string("Unknown");
}
return x;
- platform: modbus_controller
modbus_controller_id: modbus_device
name: "Seizoen"
id: seizoen_string
address: 0x81E6
register_type: holding
lambda: |-
uint16_t value = id(zomer_winter_stand).state;
switch (value) {
case 0: return std::string("Winter");
case 1: return std::string("Zomer");
default: return std::string("Unknown");
}
return x; |
Nu de extra packages;
basis: !include ./components/basis.yaml
updates: !include ./components/updates.yaml
status: !include ./components/status_led.yaml
pulse: !include ./components/pulse_meter.yaml
updates.yaml
code:
1
2
3
4
5
6
7
8
9
10
| # OTA configuration #
ota:
- platform: esphome
id: ota_esphome
- platform: http_request
id: ota_http_request
http_request:
timeout: 10s
verify_ssl: false |
status_led.yaml
code:
1
2
3
4
5
6
7
| light:
- platform: status_led
internal: true
id: led_red
pin:
number: ${status_led}
inverted: true |
basis.yaml
code:
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
| # Basic configuration #
button:
# Restart the ESP
- platform: restart
name: "Restart - WP kWh"
# Sensors for ESP version and WIFI information
text_sensor:
# # Installed version
# - platform: template
# name: "Glow - Installed version"
# id: glow_version
# icon: "mdi:label-outline"
# entity_category: diagnostic
# lambda: |-
# return {"${project_version}"};
# update_interval: 6h
# # ESPHome version
# - platform: version
# hide_timestamp: true
# name: '${friendly_name} - ESPHome Version'
# IP address and connected SSID
- platform: wifi_info
ip_address:
name: '${friendly_name} - IP Address'
icon: mdi:wifi
ssid:
name: '${friendly_name} - Connected SSID'
icon: mdi:wifi-strength-2
sensor:
# WiFi signal
- platform: wifi_signal
name: "${friendly_name} - WiFi Signal"
update_interval: 120s
# Enable time component to reset energy at midnight
# https://esphome.io/components/time/homeassistant.html
time:
- platform: homeassistant
id: homeassistant_time |
pulse_meter.yaml
code:
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
| # Pulse meter configuration #
# Enable Home Assistant API
api:
services:
- service: reset_total_energy
then:
- button.press:
id: button_reset_total
number:
# Set the pulse rate of the LED on your meter
- platform: template
id: select_pulse_rate
name: 'Puls rate - imp/kWh'
optimistic: true
mode: box
min_value: 100
max_value: 10000
step: 100
restore_value: yes
initial_value: 800
# Reset total energy to given value
- platform: template
id: select_reset_total
name: 'Reset Value - Total Energy kWh'
entity_category: config
optimistic: true
mode: box
min_value: 0
max_value: 1000000
step: 1
initial_value: 985 # energie oude WP stond op 617kWh . 985 @28 maart 2025
button:
# Reset the total energy entity
- platform: template
id: button_reset_total
name: "Reset - Total Energy"
on_press:
- pulse_meter.set_total_pulses:
id: sensor_energy_pulse_meter
value: !lambda "return id(select_reset_total).state * id(select_pulse_rate).state;"
sensor:
# Pulse meter
- platform: pulse_meter
id: sensor_energy_pulse_meter
name: '${friendly_name} - Power Consumption'
unit_of_measurement: W
state_class: measurement
device_class: power
icon: mdi:flash-outline
accuracy_decimals: 0
pin: ${pulse_pin}
internal_filter: 100ms # in theory 800 pulse per kwh, max around 6kWh peak would be 1.33 pulse per second. 1/1.33 = 730ms so starting with 100ms as filter
timeout: 1min
on_raw_value:
then:
- light.turn_off:
id: led_red
- delay: 0.2s
- light.turn_on:
id: led_red
filters:
# multiply value = (60 / imp value) * 1000
# - multiply: 60
- lambda: return x * ((60.0 / id(select_pulse_rate).state) * 1000.0);
# Update the sensor with an average every 10th second. See
- throttle_average: 5s
- filter_out: NaN
- timeout: 60s # sent value will be NaN
- timeout:
timeout: 60s
value: !lambda return 3;
- clamp:
min_value: 1
max_value: 5500 # max Wh usage, eliminate spikes
ignore_out_of_range: true
total:
id: sensor_total_energy
name: '${friendly_name} - Total Energy'
unit_of_measurement: kWh
icon: mdi:circle-slice-3
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
# multiply value = 1 / imp value
# - multiply: 0.001
- lambda: return x * (1.0 / id(select_pulse_rate).state);
# Update the sensor once per 0.1 kWh consumed, or every 5th minute, whichever happens sooner.
- delta: 0.01
- heartbeat: 60s
# Total day usage
- platform: total_daily_energy
id: sensor_total_daily_energy
name: '${friendly_name} - Daily Energy'
power_id: sensor_energy_pulse_meter
restore: true
unit_of_measurement: kWh
icon: mdi:circle-slice-3
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001 |
[
Voor 100% gewijzigd door
JoebarRC op 08-04-2025 12:48
]