Energy Management in Home Assistant

I am also facing similar situation.
I was perviously using wifi connection to Huwaei inverter itself, which was reading correctly without any abnormal spike readings. Only issue was weak wifi signals of inverter which lead to missing/gaps in reading.


Since I updated my dongle’s firmware to read from wifi dongle’s wifi (which is more stable without any dropouts). I am facing abnormal spikes in hundreds
It can happen with any of the three values.
All three have state_class:total_increasing increasing.

Hi, I have read every post possible to get en entity to choose from on the energy dashboard but even after getting all required attributes for the entity, I simply dont see any entity to choose. Can somebody tell me what am I still missing?
Screenshots attached:


I see a capital K for kWh and I think it might be particular about that?

1 Like

Man! you made my day. Sometimes our eyes just see what they want to see. I had scanned my attributes so many times to see a difference in case but couldn’t spot that. I changed that to “kWh” and I am able to see the entities now. Thanks buddy !!

Hi all.
Is it possible to take care of passive heat by sun (thougth windows) based on a Forecast.Solar sensor like :
Forecast.Solar -> sensor.power_production_now

This power as to be not include in total house power, and not in returning power.
It’s usefull for driving classic heater (on sun exposed room).
thanks.

The Victorians households can get the in-home display electricity monitor for free under the government program.

I got this KY-033 from sensor kit that i bought on aliexpress and connected it to the gpio and it works remarkably well for reading the disk revs in my old electric meter (should also work nicely for old gas meters) :wink:

1 Like

Hello, I have a strange issue with the kw calculation.

I use the platform integration to convert watt to kwh

  - platform: integration
    source: sensor.amp2_watt2_pos
    name: amp2_kw2_pos
    unit_prefix: k
    round: 2

Look at the jump in the kwh graph between 7 an 8. How is this possible ?

Maybe related. Since my current sensor is not correct in the low voltage range I suppress the value to 0 when sun is below horizon. I also limit the max value to the max value of the solar installation with the following state filter :

      state: >
        {% if states.sun.sun.state == "above_horizon" %}
          {% if states.sensor.amp2_watt2.state | float < 5290 %}
            {{states('sensor.amp2_watt2') | float | abs}}
          {% else %}
            3526.00
          {% endif %}
        {% else %}
          0.00
        {% endif %}

I am also off the grid completely and am using the energy feature. The graph is just skewed, because I configure my Inverter output as “grid consumption”, so it is now adding solar production and grid consumption as total consumption. I’m still working on the battery charge/usage data, so that might help clarify. How did you end up using this feature. It seems geared towards grid connected systems.

I fixed this with a template sensor
I also limit the spikes since in some rare occasions I have strange spikes above what is possible. Limit is set to 240v 40A = 9600w

template
  - sensor:
    - name: "amp2_watt1_pos"
      device_class: power
      state_class: measurement
      unit_of_measurement: "W"
      icon: mdi:alpha-w-circle-outline
      state: >
        {% if states.sensor.amp2_watt1.state | float >= 0 %}
          {% if states.sensor.amp2_watt1.state | float < 9600 %}
            {{states.sensor.amp2_watt1.state}}
          {% else %}
            9600
          {% endif %}
        {% else %}
          {% if states.sun.sun.state == "above_horizon" %}
            0.00
          {% else %}
            {% if states.sensor.amp2_watt1.state | float | abs <  9600 %}
              {{states.sensor.amp2_watt1.state | float | abs }}
            {% else %}
              9600
            {% endif %}
          {% endif %}
        {% endif %}
  - sensor:
    - name: "amp2_watt1_neg"
      device_class: power
      state_class: measurement
      unit_of_measurement: "W"
      icon: mdi:alpha-w-circle-outline
      state: >
        {% if states.sensor.amp2_watt1.state | float < 0 %}
          {% if states.sun.sun.state == "above_horizon" %}
            {% if states.sensor.amp2_watt1.state | float | abs <  9600 %}
              {{states.sensor.amp2_watt1.state | float | abs }}
            {% else %}
              9600.00
            {% endif %}
          {% else %}
            0.00
          {% endif %}
        {% else %}
          0.00
        {% endif %}

sensor
  - platform: integration
    source: sensor.amp2_watt1_pos
    name: amp2_kw1_pos
    unit_prefix: k
    round: 2
  - platform: integration
    source: sensor.amp2_watt1_neg
    name: amp2_kw1_neg
    unit_prefix: k
    round: 2

Amazig feature! Besides Solar panels I also own a (small) piece of a windmill (windshares), so I also “produce” wind-energy each day. I managed to be able to add these values to the energy graph, but it would be great if there was a special option for Wind. Now I have to add it within my home usage, which obviously isn’t correct. It would be great if I could add it at the spot of the green circle: produced outside my home, returned to the grid. Is this already possible, or perhaps a future option?

Perhaps off-topic but what kind of windmill do you have and how much energy does it produce on yearly basis?

How did you actually get this to work? I bought similar tcrt5000 ( https://www.amazon.de/dp/B07VP4JDTH ) modules, and it’s absolutely impossible to make them differentiate between anything else than completely black and white :confused:

Well it dust worked :slight_smile: , setting the sensitivity to low and it will register the reflection of the metal vs the paint.

1 Like

I read something about a bug in the integration function, you should add
method: left
to your configuration to correct this.

Thanks for this tip.
Found it somewhere on the energy discussion but it is not in the hassio documentation.
Thanks for this tip. Changed my config so will see tomorrow morning. Maybe even a day longer since I have the feeling it calculated the morning value for the entire night.
I added “method: left” at the end of every “- platform: integration”

It is not a bug. It is matter of proper implementation.

It is documented under the integration you’re using.

In case you have an appliance which produces spikey consumption (like an on/off electrical boiler) you should opt for the left method to get accurate readings.

So as Nick said: It’s not a bug. There are simply different ways to do numerical integration (mathematically).

PS: Please also consider editing your original post and format your config correctly (as code).

Thanks a lot. Found it and it is indeed a documented parameter. Must have overloocked it. This morning I still had the bump after the change. I have the feeling it took the first zero at the end of the last day and calculates based on the first value of the new day the left or right below predicted curve with those two values what is not correct . The left method will make it less worse but still not correct. It should have used the 0 from a few seconds before. I already had the feeling that homeassistant suppresses same values and only keeps the first. If this is correct this is an issue for this powercalculation. It should remember the first and the last same value over time.

For people with kWh sensor for gas consumption (eg. some UK smart meter integrations).

Use this code to generate m3 from kWh. You will then be able to add the new gas volume template sensor into your gas section of the energy dashboard.
Both the formula and calorific value comes from my statement. I looked back last few statements and took an average.

There’s also a gas tariff template sensor for calculating cost. It uses the same formula, because we are just converting the price by the same conversion factor.

template:
  # Home Energy sensors for HA Energy
      - name: Gas volume
        state: >
          {% set calorific = 39.1 %}
          {{ ( states('sensor.bulb_energy_meter_gas_meter')|float * (3.6 / calorific|float / 1.02264 / 2.83) ) | round(8)}}
        unit_of_measurement: "m³"
        state_class: total_increasing
        device_class: gas
  - sensor:
      - name: Gas Tariff
        unit_of_measurement: "GBP/m³"
        state: >
          {% set costPerKWh = 0.0406 %}
          {% set calorific = 39.1 %}
          {{ ( costPerKWh|float * (3.6 / calorific|float / 1.02264 / 2.83) ) | round(15)}}
1 Like