Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HA Energy Dashboard #14

Closed
weltmeyer opened this issue Feb 27, 2022 · 13 comments
Closed

HA Energy Dashboard #14

weltmeyer opened this issue Feb 27, 2022 · 13 comments
Labels
documentation Improvements or additions to documentation

Comments

@weltmeyer
Copy link
Owner

weltmeyer commented Feb 27, 2022

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 weltmeyer added the documentation Improvements or additions to documentation label Feb 27, 2022
@weltmeyer weltmeyer pinned this issue Feb 27, 2022
@WLammert
Copy link

WLammert commented Apr 8, 2022

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

Thank you anyway, great plugin!

@KlavsKlavsen
Copy link

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).
,

@weltmeyer
Copy link
Owner Author

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.

@jezzaaa
Copy link

jezzaaa commented Mar 8, 2023

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).

@weltmeyer
Copy link
Owner Author

weltmeyer commented Mar 8, 2023

@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.

@justinmstark
Copy link

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.

@KAES3187
Copy link

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

@cjoha
Copy link

cjoha commented Sep 4, 2024

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

@RustyDust
Copy link
Collaborator

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
Copy link
Collaborator

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.

@cjoha
Copy link

cjoha commented Sep 4, 2024

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.

@TheRealJohnWick42
Copy link

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.

@RustyDust
Copy link
Collaborator

Closing since it's pinned for reference anyway ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

9 participants