weltmeyer / ha_sonnenbatterie

Homeassistant integration to show many stats of Sonnenbatterie
GNU General Public License v3.0
51 stars 24 forks source link

HA Energy Dashboard #14

Open weltmeyer opened 2 years ago

weltmeyer commented 2 years ago

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

WLammert commented 2 years ago

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

Thank you anyway, great plugin!

KlavsKlavsen commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@jezzaaa you are right. I hated that in math but its that simple its not w/h but wh 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 commented 9 months ago

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 commented 5 months ago

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