DasLetzteEinhorn / AlphaESS_Monitor_Hass

Apache License 2.0
11 stars 1 forks source link

Integrating with HA energy monitoring #4

Open tbgoose opened 2 years ago

tbgoose commented 2 years ago

Hey guys

I ended up scrapping my old dockerised HA instance and going the debian supervisor route on my rpi4, so finally have this working as intended. It is awesome, although the values presented are not exactly matched to the alphaess website, so not sure if I have done something incorrectly or it is supposed to be like that.

Do you think it would be possible to leverage the information captured from the alphaess system and feed it into the new Energy monitoring side of HA? Theoretically we are already capturing all the data required to be able to utilise this, without the need for another device.

I have tried to create statistics from values like solar generation and house load, but they don't really provide me with useful information, and they do not show up in the available stats dropdown when trying to graph them. HA tells me to link you to this to see if that can be fixed, but I know this isn't an integration, so it might not be relevant.

I am trying to create daily totals for generation, battery feed/draw and grid feed/draw. The stats sensors I have created don't sum the daily data, they just keep adding data every time there is an update.

Cheers

tbgoose commented 2 years ago

I am making a bit of headway on this, I have converted my sensor data into energy data, and then that energy data into utility data.

However the data reported by my system is slightly different to yours. Any idea how to get a value for house load? Due to the fact that the I/O data is -/+ depending on direction of flow it is not easy (for me anyway) get totals of flow to and from the battery or grid.

pmeter_dc --> solar generation (matches AlphaESS portal) soc --> state of charge (matches AlphaESS portal) pbat --> battery I/O (matches AlphaESS portal) pmeter_l1+pmeter_l2+pmeter_l3 --> grid I/O sva --> ??? varac --> ??? vardc --> ??? preal_l1 --> ???

Cheers

{ "_id" : "XX", "createtime" : "2021-08-19 01:28:18", "uploadtime" : "2021-08-19 11:28:02", "sn" : "XX", "ppv1" : 0.0, "ppv2" : 0.0, "ppv3" : null, "preal_l1" : -2126.0, "preal_l2" : 0.0, "preal_l3" : 0.0, "pmeter_l1" : 0.0, "pmeter_l2" : 0.0, "pmeter_l3" : 0.0, "pmeter_dc" : 2785.0, "soc" : 51.6, "factory_flag" : 0, "pbat" : -1926.0, "sva" : -2131.0, "varac" : -590.0, "vardc" : 293.0, "ev1_power" : 0, "ev1_chgenergy_real" : 0.0, "ev1_mode" : 0, "ev2_power" : 0, "ev2_chgenergy_real" : 0.0, "ev2_mode" : 0, "ev3_power" : 0, "ev3_chgenergy_real" : 0.0, "ev3_mode" : 0, "ev4_power" : 0, "ev4_chgenergy_real" : 0.0, "ev4_mode" : 0, "poc_meter_l1" : 0.0, "poc_meter_l2" : 0.0, "poc_meter_l3" : 0.0

DasLetzteEinhorn commented 2 years ago

Hey @tbgoose, unfortunately, so far we have not found out where to get the value of the current load. Regarding the energy statistics, which are new in HA: I was thinking the same thing. As soon as we find time for this, we can update the addon.

tbgoose commented 2 years ago

Great, I'll get back in touch if I find out anything I think may help.

AlphaESS replied to me with the following response to calculating load - Load = Battery discharging Power + Grid meter + PV meter.

I replied asking which variable battery discharging power is? I think grid meter and PV meter are as you have them in the sensors.

On Tue, Aug 24, 2021 at 4:43 AM DasLetzteEinhorn @.***> wrote:

Hey @tbgoose https://github.com/tbgoose, unfortunately, so far we have not found out where to get the value of the current load. Regarding the energy statistics, which are new in HA: I was thinking the same thing. As soon as we find time for this, we can update the addon.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DasLetzteEinhorn/AlphaESS_Monitor_Hass/issues/4#issuecomment-904019679, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYXYKMACIV7YNAHVSUOPR3T6KJG3ANCNFSM5CF2YF2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

tbgoose commented 2 years ago

I think I have successfully integrated solar generation into HA energy now. You need your original sensor, plus two additional templates as below.

sensor:
 - platform: mqtt
    name: "Solar Generation"
    state_topic: "alphaess/XXXX"
    value_template: "{{ value_json.ppv1 + value_json.ppv2 + value_json.pmeter_dc }}"
    unit_of_measurement: "W"
    icon: mdi:solar-panel-large
  # Energy
sensor:
  - platform: integration
    source: sensor.solar_generation
    name: energy_solar_generation
    unit_prefix: k
    round: 2
utility_meter:
  daily_generation:
    source: sensor.energy_solar_generation
    name: Daily Generation
    cycle: daily

Can get Load in this way too, but I don't think I have cracked an accurate value for load yet.

This gives me an in the ballpark figure for load. But I don't know what the p_real value is... Was just testing if it was the Battery discharging Power AlphaESS said I need to use.

  - platform: template
    sensors:
        house_load_actual:
        friendly_name: "House Load Actual"
        # icon: mdi:power-socket-au
        unit_of_measurement: "W"
        value_template: "{{ states('sensor.solar_house_p_real') | float + states('sensor.solar_grid_i_o_total') | float + states('sensor.solar_generation') | float }}"

For the grid side of the Energy monitoring we need to separate the incoming and outgoing grid values. I don't know how to do this. I guess you could use some maths to float all the values when negative to one template sensor, and another to do the same when positive to another sensor? This would be pretty rough though, as the addon doesn't update in real time. It would be quite inaccurate I think, and I guess at that point why bother besides having something there in the grid graphs.