Skip to content

Add basic support for b516 energy statistics#504

Closed
filippz wants to merge 1 commit intojohn30:masterfrom
filippz:master
Closed

Add basic support for b516 energy statistics#504
filippz wants to merge 1 commit intojohn30:masterfrom
filippz:master

Conversation

@filippz
Copy link
Copy Markdown

@filippz filippz commented May 2, 2025

This PR introduces basic support for "b516" statistics present in some bai (possibly only present in HW: 7603) gas boilers and hmu heat pumps which don't support PrEnergyCount*/PrEnergySum* values.
Details are explained in the first post here: #490 (comment) and during the discussions there we came to an agreement that only 14 of most useful values are to be defined, although the script (https://gist.github.com/filippz/c0d04e4d607e27fc6b89d127db0ee941) can generate 10794 values based on our findings.

Testing and comments are welcome.

@chrizzzp
Copy link
Copy Markdown

chrizzzp commented May 3, 2025

One should add that the b516 energy statistics are also available from other (including non-heat-generation) circuits, e.g.

  • VRC720 regulator (confirmed for ID=CTLV2;SW=0514;HW=1104)
  • mixer units (confirmed for ID=VR_71;SW=0104;HW=0503)
  • hydraulic station (confirmed for ID=VWZ00;SW=0522;HW=5103)

Depending on the device functionality, these statistics will report in all cases the electrical power consumption of the individual device (general consumption, even if low compared to heating power consumptions).

In addition to that, the VRC720 regulator can also provide the b516 energy statistics for e.g. a solar circuit (if controlled by the regulator) and the b516 energy statistics of an hydraulic station (if equipped with backup heating device, e.g. immersion heater) will report electrical consumption for the backup heating device (hc/hwc) and total consumption (including also decive standby energy).

It is expected also other devices support the b516 statistics.

@filippz
Copy link
Copy Markdown
Author

filippz commented May 3, 2025

I've added appropriate includes to 15.ctlv2.tsp, 26.vr_71.tsp and 76.vwz.tsp based on your experience.
We could try to split b516_inc.tsp into more logical files so we can include only appropriate values (for example Fuel* values make sense only in 08.bai.tsp) and do some conditional includes (for example as not all bai support b516 statistics and the ones that do don't support PrEnergy* values) but this PR aims to just add basic support and get more feedback about b516 supported devices.

@filippz
Copy link
Copy Markdown
Author

filippz commented May 3, 2025

I've removed SolarCoolingSystem based on this comment: #490 (comment)

@MarMarIV
Copy link
Copy Markdown

Any progress on this PR to merge changes?

@Kolbi
Copy link
Copy Markdown

Kolbi commented Mar 6, 2026

@john30 can you please have a look into it? And maybe merge?

@john30
Copy link
Copy Markdown
Owner

john30 commented Apr 5, 2026

@john30 can you please have a look into it? And maybe merge?

I'm on it, question here

john30 added a commit that referenced this pull request Apr 5, 2026
…and add 'Stat' prefix, add StatEnergySumYear with input params
@john30
Copy link
Copy Markdown
Owner

john30 commented Apr 5, 2026

would be great if someone could have a look at 91a3e2f

@john30
Copy link
Copy Markdown
Owner

john30 commented Apr 6, 2026

reworked+merged

@john30 john30 closed this Apr 6, 2026
@john30
Copy link
Copy Markdown
Owner

john30 commented Apr 6, 2026

would be great if someone could have a look at 91a3e2f

If no one else does: I'd prefer a compiled CSV for checking (sorry, no sufficient skills interpreting TSP yet).

ok here is the ctlv2 (since this is still the main source on the current HEAD commit):

15.ctlv2.csv

rename it to whatever you have

@chrizzzp
Copy link
Copy Markdown

chrizzzp commented Apr 7, 2026

@john30

Tested the above 15.ctlv2.csv (which generally works, see ebusd log below), but somehow the new b516 definitions with the 'Stat' prefix are not incorporated (neither appear in HA nor when read from ebusd via TCP client).

r -f StatEnergySumYear
ERR: element not found

All other (preceeding) definitions of the CSV seem to be OK (e.g. Errorhistory).

Any advice?

r,,,StatEnergySumYear,,,,b516,1003ffff,source,m,UCH,1=solar;2=environment;3=electricity;4=gas,,the energy source,usage,m,UCH,0=all;2=heat;4=water;5=cool,,the energy usage,ign2,m,UCH,=0,,,year,m,UCH,2,,the year as offset from 2000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatSolarEnergySum,,,,b516,1000ffff01000000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatSolarEnergySumHc,,,,b516,1000ffff01030000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatSolarEnergySumHwc,,,,b516,1000ffff01040000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatEnvironmentEnergySum,,,,b516,1000ffff02000000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatEnvironmentEnergySumHc,,,,b516,1000ffff02030000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatEnvironmentEnergySumHwc,,,,b516,1000ffff02040000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatEnvironmentEnergySumCool,,,,b516,1000ffff02050000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatElectricEnergySum,,,,b516,1000ffff03000000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatElectricEnergySumHc,,,,b516,1000ffff03030000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatElectricEnergySumHwc,,,,b516,1000ffff03040000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatElectricEnergySumCool,,,,b516,1000ffff03050000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatFuelSum,,,,b516,1000ffff04000000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatFuelSumHc,,,,b516,1000ffff04030000,ign,,IGN:7,,,,value,,EXP,1000,kWh,
r,,,StatFuelSumHwc,,,,b516,1000ffff04040000,ign,,IGN:7,,,,value,,EXP,1000,kWh,

ebusd log:


s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[16:27:17] INFO: eBUSd addon version 26.1.6
[16:27:17] INFO: ebusd --foreground --updatecheck=off --mqtthost=core-mosquitto --mqttport=1883 --mqttuser=<redacted> --mqttpass=<redacted> --mqttjson --mqttint=/config/mqtt-hassio.cfg --device=ens:192.168.188.95:9999 --scanconfig=none --log=all:notice --mqtttopic=ebusd --pollinterval=5 --latency=10 --accesslevel="*" --mqtthost=192.168.188.132 --mqttint=/config/test_config/mqtt-hassio_26.cfg --httpport=8889 --updatecheck=off --configpath=/config/test_config/ebus.github.io/en --mqttvar=filter-direction=r|u|^w,filter-name=  
2026-04-07 16:27:17.443 [device notice] transport opened
2026-04-07 16:27:17.443 [main notice] ebusd 26.1.26.1 started with auto scan on device: 192.168.188.95:9999, TCP, enhanced
2026-04-07 16:27:17.444 [bus notice] bus started with own address 31/36
2026-04-07 16:27:17.446 [device notice] reset, supports info
2026-04-07 16:27:17.449 [device notice] extra info: firmware 1.1[4c15].1[4c15], jumpers 0x07
2026-04-07 16:27:17.455 [bus notice] signal acquired
2026-04-07 16:27:17.522 [mqtt notice] connection established
2026-04-07 16:27:18.318 [bus notice] new master 71, master count 2
2026-04-07 16:27:18.377 [bus notice] new master 03, master count 3
2026-04-07 16:27:21.944 [bus notice] new master f1, master count 4
2026-04-07 16:27:21.987 [bus notice] new master 10, master count 5
...
2026-04-07 16:27:27.590 [bus notice] scan 08: ;Vaillant;HMU00;0902;5103
2026-04-07 16:27:27.590 [update notice] store 08 ident: done
2026-04-07 16:27:27.590 [update notice] sent scan-read scan.08  QQ=31: Vaillant;HMU00;0902;5103
2026-04-07 16:27:27.590 [bus notice] scan 08: ;Vaillant;HMU00;0902;5103
2026-04-07 16:27:27.590 [main notice] read common config file vaillant/general.csv
2026-04-07 16:27:27.591 [main notice] read common config file vaillant/scan.csv
2026-04-07 16:27:27.591 [main notice] read common config file vaillant/broadcast.csv
2026-04-07 16:27:27.594 [main notice] read scan config file vaillant/08.hmu.csv for ID "hmu00", SW0902, HW5103
2026-04-07 16:27:27.594 [main notice] found messages: 226 (0 conditional on 0 conditions, 0 poll, 29 update)
...
2026-04-07 16:27:30.309 [bus notice] scan 15: ;Vaillant;CTLV2;0514;1104
2026-04-07 16:27:30.309 [update notice] store 15 ident: done
2026-04-07 16:27:30.309 [update notice] sent scan-read scan.15  QQ=31: Vaillant;CTLV2;0514;1104
2026-04-07 16:27:30.309 [bus notice] scan 15: ;Vaillant;CTLV2;0514;1104
2026-04-07 16:27:30.588 [update notice] sent scan-read Scan.15 Id QQ=31: 
2026-04-07 16:27:30.728 [update notice] sent scan-read Scan.15 Id QQ=31: 
2026-04-07 16:27:30.868 [update notice] sent scan-read Scan.15 Id QQ=31: 21;21;35;0020200914;0953;009843;N8
2026-04-07 16:27:30.868 [bus notice] scan 15: ;21;21;35;0020200914;0953;009843;N8
2026-04-07 16:27:30.878 [main notice] read scan config file vaillant/15.ctlv2.csv for ID "ctlv2", SW0514, HW1104
2026-04-07 16:27:30.878 [main notice] found messages: 672 (0 conditional on 0 conditions, 0 poll, 29 update)

@john30
Copy link
Copy Markdown
Owner

john30 commented Apr 8, 2026

@chrizzzp
the log suggests that the newer file was not used at all

@chrizzzp
Copy link
Copy Markdown

chrizzzp commented Apr 8, 2026

@john30

Correct. Sorry, there was a typo in the config-path and a wrong CSV was used.

With the proper CSV the new b516 definitions (Stat*) work (albeit not all make sense for all circuits), with the exception of the
StatEnergySumYear definition.

r,,,StatEnergySumYear,,,,b516,1003ffff,source,m,UCH,1=solar;2=environment;3=electricity;4=gas,,the energy source,usage,m,UCH,0=all;2=heat;4=water;5=cool,,the energy usage,ign2,m,UCH,=0,,,year,m,UCH,2,,the year as offset from 2000,ign,,IGN:7,,,,value,,EXP,1000,kWh,

This will throw an error

r -f StatEnergySumYear
ERR: invalid numeric argument

I understand this definition is used to explain the message composition for b516 queries, but is it also funtional? How is this supposed to be used, e.g. via TCP client?

@john30
Copy link
Copy Markdown
Owner

john30 commented Apr 8, 2026

r,,,StatEnergySumYear,,,,b516,1003ffff,source,m,UCH,1=solar;2=environment;3=electricity;4=gas,,the energy source,usage,m,UCH,0=all;2=heat;4=water;5=cool,,the energy usage,ign2,m,UCH,=0,,,year,m,UCH,2,,the year as offset from 2000,ign,,IGN:7,,,,value,,EXP,1000,kWh,

I've added that one in order not to having to send some hex codes for getting any of the other values. if you want to use it, you need to hand in the source, usage, and the year, e.g. read -i "1;2;23" statenergysumyear for getting solar used for heating in 2023.

@chrizzzp
Copy link
Copy Markdown

chrizzzp commented Apr 8, 2026

@john30

r,,,StatEnergySumYear,,,,b516,1003ffff,source,m,UCH,1=solar;2=environment;3=electricity;4=gas,,the energy source,usage,m,UCH,0=all;2=heat;4=water;5=cool,,the energy usage,ign2,m,UCH,=0,,,year,m,UCH,2,,the year as offset from 2000,ign,,IGN:7,,,,value,,EXP,1000,kWh,

BTW usage should be: 0=all;3=heat;4=water;5=cool

I've added that one in order not to having to send some hex codes for getting any of the other values. if you want to use it, you need to hand in the source, usage, and the year, e.g. read -i "1;2;23" statenergysumyear for getting solar used for heating in 2023.

I see, a nice example for passing additional message parameters to the read command.
Unfortunately, it does not work.

r -i "1;2;23" StatEnergySumYear
ERR: end of input reached

The hex message would be:
15b516081003ffff0103002e

I'm still trying to understand the StatEnergySumYear definition. Does it include the zeros preceding 'source', 'usage' and 'year'?

@john30
Copy link
Copy Markdown
Owner

john30 commented Apr 9, 2026

BTW usage should be: 0=all;3=heat;4=water;5=cool

thanks for pointing that out!

I've added that one in order not to having to send some hex codes for getting any of the other values. if you want to use it, you need to hand in the source, usage, and the year, e.g. read -i "1;2;23" statenergysumyear for getting solar used for heating in 2023.

I see, a nice example for passing additional message parameters to the read command. Unfortunately, it does not work.

ah my bad, the input needs another ";", so it should be read -i "1;2;;23" statenergysumyear

I'm still trying to understand the StatEnergySumYear definition. Does it include the zeros preceding 'source', 'usage' and 'year'?

which zeroes do you mean?

john30 added a commit that referenced this pull request Apr 9, 2026
@chrizzzp
Copy link
Copy Markdown

chrizzzp commented Apr 10, 2026

ah my bad, the input needs another ";", so it should be read -i "1;2;;23" statenergysumyear

Thanks, now it works. I had to use the -f option when reading several energy values shortly after another.

I'm still trying to understand the StatEnergySumYear definition. Does it include the zeros preceding 'source', 'usage' and 'year'?

which zeroes do you mean?

Sorry, my fault, question is obsolete.
Albeit the UCH-coded values for 'source' and 'usage' are single digit in the command (read -i "1;2;;23" statenergysumyear), they are, of course, converted to two digit hex bytes (0x01 and 0x02, respectively) present in the hex message. So, no problem here (wouldn't have worked otherwise and could also be easily confirmed with f -h statenergysumyear).
I think I understood the message definition now.

BTW would adding a definition to retrieve the monthly energy sum in a similar fashion be possible? The third parameter byte (translated to 0x00 in the statenergysumyear hex message) would have to be set in combination with the fourth byte indicating the half-year. I don't see how to achieve this with a divider, as it was possible with the year byte for the annual energy sum. Would one then have to define discrete values for the month and for the year, which would result in quite complex definitions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants