ha_sonnenbatterie icon indicating copy to clipboard operation
ha_sonnenbatterie copied to clipboard

HA Energy Dashboard

Open weltmeyer opened this issue 2 years ago • 12 comments

As this is asked very often:

The Home Assistant Energy Dashboard does not show the entities created by ha_sonnenbatterie. Thats because this addon does not show any energy(as Watt) values. (Except Battery, maybe...) We show you Power(!=Energy) values. Energy is Power Times Time (or as you may know it "WattHour" or KiloWattHour(kwh)) To make values from sonnenbatterie usable in your energy dashboard you have to somewhat "convert" the values.

As Energy is Power timeTime, you need to measure power that is pushed through your home for a certain time.

Example: You are using a fridge, which is drawing a constant 100W. After one hour your fridge used 100Wh, after 24h it used 2400Wh or 2.4kWh :)

To get to these values you can use the "Riemann integral(https://en.wikipedia.org/wiki/Riemann_integral)" which is an approximation of the used power times time(=energy).

Fortunately, home assistant has a tool for this: The "integration" integration(https://www.home-assistant.io/integrations/integration/)

An example for the energy consumption, calculated over time from the power sensor of the sonnenbatterie:

- platform: integration
source: sensor.sonnenbatterie_XXXXXX_meter_consumption_4_2_w_total
name: PowerConsumption
unit_prefix: k

This yaml creates a sensor for ConsumptionEnergy named "PowerConsumption" with unit kWh and usable in energy-dashboard

EDIT: correcteded units, thx2 @jezzaaa

weltmeyer avatar Feb 27 '22 22:02 weltmeyer

Ah, ok, maybe it's worth taking it into the main readme file ;-)

Thank you anyway, great plugin!

WLammert avatar Apr 08 '22 10:04 WLammert

One thing not mentioned here. The Rieman integration also wants to know which of 3 methods to use: Trapezoidal rule, Left Riemann Sum or Right Riemann Sum. I have assumed the default, Trapezoidal rule is to be used (we'll see if things work when its run a bit). ,

KlavsKlavsen avatar Dec 15 '22 15:12 KlavsKlavsen

I would advice to use 'left' as discussed on ha forums here: https://community.home-assistant.io/t/riemann-integral-calculates-wrong-values-with-electrical-devices/328174

this way, you dont sum the spike values you can have from you appliances over to the previous value. also, the sensor updates on change. this means you can assume the wattage was the same since last value until the sensor changed.

weltmeyer avatar Dec 15 '22 15:12 weltmeyer

Thanks for doing this integration. I don't yet have a battery, but I'm looking at Sonnen, and it would be really awesome to have this integrated with HA.

Because it may confuse people (and this is quite a common cause of confusion), I feel I should point out some errors in what you wrote:

As Energy is Power over Time, you need to measure power that is pushed through your home for a certain time.

No, energy is not power over time; it's the reverse: power is energy over time. Power is in Watts. Energy is in Watt-hours (Watts x hours), not Watts-per-hour (W/h). But yes, your conclusion is absolutely correct, we need to measure power AND time to get energy.

Example: You are using a fridge, which is drawing a constant 100W. After one hour your fridge used 100W/h, after 24h it used 2400Wh or 2.4kWh :)

The answers are correct, but the W/h unit is not. After one hour your fridge used 100Wh (not 100W/h). After 24h it used 2400Wh (24 * 100). If it was Watts/h then the calculation would be 100/24 = around 4.2W/h.

There's really no such thing as Watts-per-hour (or W/h or kW/h or MW/h). In this context, it's a meaningless unit. The correct unit is Watt-hours (Wh or kWh, etc).

jezzaaa avatar Mar 08 '23 22:03 jezzaaa

@jezzaaa you are right. I hated that in math but its that simple its not w/h but w*h so 100w * 1h=100 * w * 1 *h =100 * 1 * w * h .. sorry for my missung of "per" and the wrong unit maths. the outcome is still right looking only at the numbers ;)

I corrected my description and hope that fits better.

weltmeyer avatar Mar 08 '23 23:03 weltmeyer

Out of interest, are you able to share the full YAML code for the dashboard. I am still learning all of the YAML coding models and learning by working example is perfect for me.

Thanks.

justinmstark avatar Oct 04 '23 01:10 justinmstark

You need no YAML-Coding -> https://www.home-assistant.io/integrations/integration/

KAES3187 avatar Jan 12 '24 22:01 KAES3187

Hardware version = 9 Software version = 1.14.5 (stable) Model = hyb 9.53 9010 ND

Issue: I have edited my configuration.yaml to add the six sensors needed to add battery stats to the HA Energy dashboard. My configuration.yaml snippet is below. As an example, one of the template sensors is dependant on the sensor called "sonnenbatterie_200526_meter_consumption_4_2_w_total". When I check my HA entities, this does not exist. When I look across all 6 dependant sensors (in the snippet below), none of them exist (but I do have entities for the Sonnen battery, for example 'sensor.sonnenbatterie_200526_state_system_status'). I have tried using both the User, and Installer logon. Both result in the same missing source entities.

Any ideas/advice?

sensor:
  - platform: integration
    source: sensor.sonnenbatterie_200526_meter_consumption_4_2_w_total
    name: PowerConsumption
    round: 3
    unit_prefix: k
    unit_time: h
    method: left

  - platform: integration
    source: sensor.sonnenbatterie_200526_meter_production_4_1_w_total
    name: PowerProduction
    round: 3
    unit_prefix: k
    unit_time: h
    method: left

  - platform: integration
    source: sensor.sonnenbatterie_200526_state_grid_input
    name: GridInput
    round: 3
    unit_prefix: k
    unit_time: h
    method: left

  - platform: integration
    source: sensor.sonnenbatterie_200526_state_grid_output
    name: GridOutput
    round: 3
    unit_prefix: k
    unit_time: h
    method: left

  - platform: integration
    source: sensor.sonnenbatterie_200526_state_battery_input
    name: BatteryInput
    round: 3
    unit_prefix: k
    unit_time: h
    method: left

  - platform: integration
    source: sensor.sonnenbatterie_200526_state_battery_output
    name: BatteryOutput
    round: 3
    unit_prefix: k
    unit_time: h
    method: left

cjoha avatar Sep 04 '24 13:09 cjoha

With the latest firmware updates Sonnen has changed the numbering and thus the names of the variables. So instead of sensor.sonnenbatterie_200526_meter_production_4_1_w_total it's now sensor.sonnenbatterie_200526_meter_production_0_1_w_total and for sensor.sonnenbatterie_200526_meter_consumption_4_2_w_total you now have to use sensor.sonnenbatterie_200526_meter_consumption_1_2_w_total

RustyDust avatar Sep 04 '24 19:09 RustyDust

For the other ones that "don't exist" check that these aren't just disabled. Happened to me after the firmware upgrade with quite a lot of the sensors.

RustyDust avatar Sep 04 '24 19:09 RustyDust

Thats better! Let me re-enable the disabled sensors as well, and I'll confirm back here with the correct config if I see data coming in tomorrow.

cjoha avatar Sep 04 '24 20:09 cjoha

Why not use the integrated meter values kwh_imported? I have this available from my sonnenBatterie 8.0eco API endpoint /api/v2/powermeter and I would assume it is available for any later version too.

TheRealJohnWick42 avatar Sep 26 '24 18:09 TheRealJohnWick42