Skip to content

Reverse engineering b516 energy statistics #490

Description

@filippz

Long story short - I've found a way to read gas/electricity consumption from my VUI 25/32 CS/1-5 (MF=Vaillant;ID=BAI00;SW=0807;HW=7603) and I need a little advice on what would be the best way to implement the support for it.

I was having an issue reading reading gas/electricity as I would get ERR: invalid position in decode when trying to read PrEnergyCountHc1/PrEnergyCountSum1 and all the rest of PrEnergyCount/PrEnergySum values. This seem to be common occurrence (for example: #437, john30/ebusd#620, john30/ebusd#1126,...) with one common "denominator": HW version of all those reports seem to be 7603

By looking at the communication between bai and ctlv2 I saw some unsupported commands/messages that pointed me to the right track with the following conclusions:

  • ctlv2 sends bai 30 commands each one for a single Wh value for:
    heating/hot water (2) x
    gas/electricity/total (3) x
    previous month/current month/previous year/current year/total (5)
  • commands are b516 with 100Xffff0Y0ZWVQQ as a payload where (with the kind help of @chrizzzp):
    X (period): 0=All, 1=Day, 2=Month, 3=Year
    Y (source): 1=Solar, 2=Environmental, 3=Electricity, 4=Gas, (9=unidentified heat pump-related)
    Z (usage): 0=All, 3=Heating, 4=Hot water, 5=Cooling
    W/V/QQ: - Month/Day/Year:
    • QQ denotes (half) year starting with 2000 increased by 2 for every year (increased by 1 for denoting last 5 months in a year) - ie 2000 = 00/01, 2001 = 02/03,...
      • ignored for All (X=0)
    • W denotes month increased by 2 for every month starting with 2 for first part of year (QQ is even) and 0 for last five months of the year (QQ is odd) - ie 2/4/6/8/a/c/e for months 1/2/3/4/5/6/7 (QQ is even) and 0/2/4/6/8 for months 8/9/10/11/12 (QQ is odd)
      • ignored for All (X=0) and Year (X=3)
      • for Month (X=1) increased by 1 in order to specify second part of the month (days 16-)
    • V denotes days starting with 1 for days 1-15 (1-f) when W is even, and 0 for days 16-31 (0-f) when W is odd
      • ignored for All (X=0), Year (X=3) and Month (X=2)
  • replies are 11 bytes long where the last 4 bytes are Wh value in EXP format

payload examples:

1001ffff03005732 - daily sum of electrical energy consumption on Feb 23, 2025
1002ffff02038031 - monthly environmental yield used for heating in Dec of 2024
1003ffff04040032 - 2025 gas consumption used for water heating
1000ffff01000000 - total solar yield of the system (since installation)

example command:

ebusctl hex 08b516081001ffff03005732

To support this, I've added:

  • an energye entry to _templates.csv:
    energye,EXP,,Wh,
  • 30 entries to bai.308523.inc like:
r,,EnergySumHcPreviousYear,,,,b516,1003ffff03000130,,,IGN:7;energye,,,
r,,FuelSumHcPreviousYear,,,,b516,1003ffff04030030,,,IGN:7;energye,,,
...

Since I use those in Home Assistan, I've had to add |fuel to the filter-name value and sensor,gas,total_increasing = fuel|,Wh$ line to type_switch-number in mqtt-hassio.cfg

Before I prepare a proper PR, I would like to hear some opinions if those entries make sense or there is a more logical approach? Should HW:7603 be addressed separately and PrEnergyCount/PrEnergySum moved outside bai.308523.inc or it can be in the same file (and filtered out with [HW=7603] or similar)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions