Daikin heat pump consumption (from BRP069A61 websocket) to a sensor for Energy?

I’ve found some pointers in this forum on how to read and write values to my Daikin Altherma air/water heat pump via the BRP069A61 LAN-adapters websocket interface but now I’m a bit confused how to properly get the consumption values to a sensor that can be used in hte new “Energy” feature.

The websocket response for the consumption is reported per 2-hour period (yesterday + today), per day (last week and this week) and per month (this year and last year).

The consumption is reported as three lists, where the 2-hour periods are reported as [“Yesterday 00:00 - 01:59”, “Yesterday 02:00 - 03:59”, …, “Yesterday 22:00 - 35:59”, “Today 00:00 - 01:59”, …, “Today 22:00 - 23:59”]. The same way for per-day (starting with last week’s Monday, ending with this week’s Sunday) and per-month (starting with last year’s January and ending with this year’s December.)

The ongoing period is incremented as time passes and the periods that have not been started yet are reported as “null”. Below is the relevant part of the response when reading the consumption for the water tank with the following lines of code (which I have found elsewhere on this forum).

from websocket import create_connection
import json, datetime, time, urllib
ws = create_connection("ws://IP-OF-MY-LAN-ADAPTER/mca")
ws.send("{\"m2m:rqp\":{\"op\":2,\"to\":\"/[0]/MNAE/2/Consumption/la\",\"fr\":\"/TarmoTest\",\"rqi\":\"xijub\"}}")
print(json.loads(ws.recv()))
{"Electrical":
  {
    "Heating":
    {
      "D":[0,0,1,0,0,0,0,0,1,0,0,1,0,2,0,0,0,0,null,null,null,null,null,null],
      "W":[2,4,4,2,3,3,2,3,2,null,null,null,null,null],
      "M":[null,null,null,null,null,null,null,null,null,null,2,109,140,110,119,114,96,83,75,27,null,null,null,null]
    }
  }
}

I’m thinking that I might have a script running on some computer and send the consumption values over MQTT since I’m already communicating other things to MQTT sensors in Home Assistant, but what would a proper way of getting the consumption to a sensor that can be used by “Energy”? I can send the ongoing periods (i.e. the last non-null value in the lists) and use that, but then I wouldn’t get any history… I’m not getting any cumulative consumption value.

Also, the values in the lists are rounded/truncated so the sum of the 2-hour periods for a day will not add up to the consumption for that day. The sae with days → month consumption.

If I knew how to make a custom integration I would not need MQTT obviously, but I don’t…

The full websockets response also inlcudes the following strings which seem to identify the current date and the periods: “12” = 12:00-13:59, the “2” at the end seems to be the day of the week (2 = Tuesday).
‘ct’: ‘20210810T120002Z’, ‘lt’: ‘20210810T120002Z’

@mrpetersson I am ver interested in the answer to your question too, did you figure it out already? And did you find a neat way to get temperate and other values into home assistant which you could share? I have been struggling for quite a while now and although I have been reading all the posts on this subject, it is too high level for me to be able to integrate my altherma with its lan adapter nicely into HASS.

Any help highly appreciated.

No I haven’t been digging more into this, I was hoping to get answers here myself.

I have noticed that there is a value in the respons that increases steadily but I don’t know if it is the cumulative consumption or just something about how many hours the heat pump has been running or something.

I’m thinking about writing a simple python script that periodically gets the websocket response and extracts som values to send through MQTT to Home Assistant.

Its a pity. I do have a working setup using Vera and node-red but hoped to get rid of that with HASS…

I am thinking integration might be possible using the

sensor:
  - platform: rest
    resource: ws://IP_ADDRESS/ENDPOINT

configuration options but I have no clue how to implement such a thing. Would love to experiment but would need some pointers on a example to get started.