Energy Management in Home Assistant

If anyone has an Actron Que air conditioner - Mike (the awesome developer of the addon) added the entity for compressor power - and now I have it as an Individual Device on my dashboard!

How do you split what comes in to the battery and out? I have the same sensor. its charging or draining. the only way to know if its a negative number

Template sensors. Examples above.

Anyone managed to get Sonoff POW readings into energy tab? Trying to solve it since few days now and can’t get it working anyhow.

This is how sonoff data is registered in my HA.

sensor:
- platform: template
  sensors:
    power_ups:
      friendly_name: UPS
      unit_of_measurement: W
      device_class: power
      value_template: "{{ state_attr('switch.sonoff_1000bda5e7', 'power') }}"    
    history1_ups:
      friendly_name: UPS today
      unit_of_measurement: kWh
      device_class: power
      value_template: "{{ state_attr('switch.sonoff_1000bda5e7', 'consumption').0 }}"

For energy tab purposes I understand we need to use power input so we leave consumption as it is and take power into Integration - Riemann sum integral:

- platform: integration   
  name: energy_spent_ups
  source: sensor.power_ups
  unit_prefix: k
  round: 2

Last but not least I customize it with tags found within this topic:

sensor.energy_spent_ups:
  state_class: measurement
  last_reset: '1970-01-01T00:00:00.000000+00:00'

And this is my energy tab with setup like this:

Strangest thing is that when I go to developer tools I see that usage is being monitored:
image
and even cost is being calculated:
image

Why for the heavens my energy tab won’t show anything from this?

I have set up recorder with includes (I have tons of sensors for which I dont need history written in DB)

recorder:
  commit_interval: 5
  purge_keep_days: 365
  include:
    entities:
      - sensor.energy_spent_ups
      - switch.sonoff_1000bda5e7
      - sensor.power_ups
      - sensor.history1_ups
      (...)

What am I missing?
This HA instance work nearly year now, I am updating it OTA constantly. Maybe Energy function needs to be enabled somehow in configuration or registered in recorder?

Why is my sensor cost resetting? As well the numbers do not match anymore?

The answer I think is How could HA know about your individual contract? From what I can tell CO2 signal is showing you what is generally happening on your grid. So for someone that is on a standard contract it should be accurate.
As an aside even with your green power contract you get the same power as your neighbour who may not have the same contract. I understand your electricity supplier just undertakes to buy the equivalent amount of green energy as you use - you may not actually get it though depending on when they are buying and when you are using. More info here Why green electricity contracts fail to deliver green electricity

2 Likes

Finally an answer, I can learn from. Thank you very much :wink:

So it looks like, my contract, as I assumed already, is a nice story on paper, a make-believe…

Good to know. Nothing in my circle of influence. In NL, al the resellers are the same :smiley:

1 Like

Does anyone know whether it is possible to add historical energy consumption to the database? I have been running Emoncms for about 7 years now and exporting it is quite easy, but importing it into energy management in home assistant is the big question mark…

3 Likes

@fversteegen
you have to play with sqlite database. Maybe you can backup your *.db and edit it with eg. “DB Browser for SQLite”

1 Like

For some reason some of my add-ons don’t work anymore, most important Node-Red won’t start it says the config file is missing. Any one else having these issues? If logs are required let me know.

…which brings me to another question:
After upgrading HA, I had to correct the sensor to state_class: total_increasing
Energy Management started collecting different sensor data (counter vs. difference).

In SQLite DB I found

Any ideas how to delete/correct these bars?
Thanks, Gerhard

1 Like

Device class should be energy not power for this one.

1 Like

Hi,

the new plugin is what I’ve be searching for since I installed HA.

I use the pulse counter (1) together with the “wiffi” integration (2).

this combination successfully generates counter and current consumption for each channel (wich is an impulse counter).

unfortunately I do not see these values in the energy management :frowning:

Can anyone tell how to manage this, or does anyone know how to update the wiffi integration? I would help testing :slight_smile:

Thanks in advance,
Florian

  1. PULSECOUNTER-Controller | STALL
  2. Wiffi - Home Assistant

What sensors do you have as a result of the wiffi integration, and what attributes do those entites have?

history1_ups is not used anywhere else beside some entity with listed daily usage from some devices and it works well so I dont intend to touch it. Anyway shortly after I wrote last post suddenly everything started to work (maaaagic).

Well, not everything, calculations are not being shown on energy tab, I dont know why, because as You can see its being calculated within cost entity:
image

Also - can we somehow color those usage bar graphs? 3 colors are difinitely not enough, I need around 12.

1 Like

Hi, I have graphs but cost is still stuck at zero. After changing currency in HA Settings - General to reflect my actual currency (CZK) and adjusting cost of energy to that currency, the Total Cost does not increase anymore. It is stuck at 0.00. The cost sensor state shows “unknown”.

I tried to remove and re-add my device (it’s a simple zigbee power plug) from energy monitoring, problem didn’t get fixed. Tried modifying the HA database as instructed by a HA developer with

UPDATE statistics_meta SET unit_of_measurement = “CZK” WHERE statistic_id = “sensor.energy_from_grid_cost”;
and
DELETE FROM statistics WHERE metadata_id = (SELECT id FROM statistics_meta WHERE statistic_id = “sensor.energy_from_grid_cost”);

(modified with my entities of course) but to no avail. Any more tips? Thanks.

Almost like the cost is only working for EUR and USD. I use CZK and it’s stuck at zero, same as yours.

Hi,

the wiffi plugin generates 2 entities or each channel (counter).

There are actually no attributes. It is just a value:


Do I need to add a manual sensor template into the configuration?

Thanks for the help, I’m pretty new in the topic.

I can confirm that the CZK currency works well.

1 Like

Glad to hear that. Did you have CZK set on General settings before 2021.8 (i.e. Before the Energy thing), or after? I only set it in 2021.8.8 as I have had no need for currency at all, but after changing it from EUR to CZK, cost (all costs) are stuck at 0.00 no matter what I do.

Best seen here: