Energy Management in Home Assistant

I got really exited by this … i think its a great feature.
But, like others, other than my solar production (solaredge) none of the bespoke data ive managed to get to show in HA is working.

Mine is a mix of solaredge, pvoutput, emonCMS, and bespoke “integrations” with my iotawatt (using rest) and additonal pvoutput via a NodeRed flow publishing to MQTT.
I guess ive got some work to do to make that data behave in the way this expects.

Thanks guys, the Energy dashboard is great!

I’ve bought myself a SlimmeLezer and I already had a couple of TP-Link HS110 power plugs with power metering. With minimum effort all the information showed up at the dashboard.

Strange thing is that the Monitor of individual devices on the Energy dashboard shows a negative value. When I’m opening one, I see this:

Am I doing something wrong? I expected a 0.2 positive value here.
I guess the reset at 00:00 at night is responsible for that. How can I solve this?

It works with tasmota 9.5.0
However, with SetOption19 off.
Switch to off

An easy way to add feed in Energy Dashboard:

Go to Configuration > Entity: Select wich entity you want to add in Energy Dashboard
Customize the entity with:
state_class : measurement
device_class : energy
Other :
Attribute name = last_reset
Attribute Value = 1970-01-01T00:00:00+00:00

Check that the entity “Unit of measurement” is kWh.

Save
Return to Configuration> Energy and now you should find your feed in the list.

It’s same as append that in customize.yaml:
Example :

sensor.emoncms_energie_injectee:
  friendly_name: Energie Injectée
  state_class: measurement
  device_class: energy
  icon: mdi:home-export-outline
  unit_of_measurement: kWh
  last_reset: '1970-01-01T00:00:00+00:00'
9 Likes

Do you have to recalibrate the powerplugs when upgrading ? Mine are still 8.1.0.2. And I have 8 of them, plus a sonoff pow r2.

For HS110 when you add devices to individual devices, add total Consumption not Daily which reset every day and will give you negative value; watch there are 2 consumptiun for HS110, you need to add total.

4 Likes

well, still having issue’s

i added this :

homeassistant:
  customize_glob:
    sensor.*_energy:
      last_reset: '1970-01-01T00:00:00+00:00'
      device_class: energy
      state_class: measurement

and i have these setup:

utility_meter:
  netto_produce_daily_energy:
    source: sensor.netto_produce_energy
    cycle: daily
    tariffs:
      - peak
      - offpeak
  netto_produce_monthly_energy:
    source: sensor.netto_produce_energy
    cycle: monthly
    tariffs:
      - peak
      - offpeak
      
  netto_consume_daily_energy:
    source: sensor.netto_consume_energy
    cycle: daily
    tariffs:
      - peak
      - offpeak
  netto_consume_monthly_energy:
    source: sensor.netto_consume_energy
    cycle: monthly
    tariffs:
      - peak
      - offpeak

  util_energy:
    source: sensor.netto_produce_energy
    cycle: daily

not showing up in energy,

and when i do this:

template:
  - sensor:
    - name: test_energy
      state: "{{ states('sensor.p1_electricity_produced_peak_point') }}" 
      unit_of_measurement: 'kWh'
      state_class: measurement
      device_class: energy

its there, any idea why the sensors from UTILITY_SENSORS are not showing up?

regards

Change the last one to

template:
  - sensor:
    - name: test_energy
      state: "{{ states('sensor.p1_electricity_produced_peak_point') }}" 
      unit_of_measurement: 'kWh'
      state_class: measurement
      device_class: energy
      attributes:         
          last_reset: '1970-01-01T00:00:00+00:00'

1 Like

Thanks, but the last one is actually working,

The utility_meter: ones are not showing up at all.

That did the trick here, indeed use the normal tasmota integration with disable auto discovery where it popups by mqtt

I use the utility meter without tariffs and these are allowed to be selected in energy. Maybe try that ? ( Remove tariffs)

yes i did try that,

the only thing works is using the sensorname from the utility_meter device
like this:

template:
  - sensor:
    - name: growattbruto_energy
      state: "{{ states('sensor.growatt_b1') }}" 
      unit_of_measurement: 'kWh'
      state_class: measurement
      device_class: energy
      attributes:         
          last_reset: '1970-01-01T00:00:00+00:00'

but im having an other problem, now i configured everything in energy, let it work for 3 hours and no graphs.

i have 2 devices with consume and 2 devices that return energy to grid.
after 4 hours still no graph

Too bad that there is no support for template sensors currently.
I wanted to add the data for my inverters by polling the web API into a template sensor
I have two Solax power inverters. Sadly they have no local API’s (removed in newer firmware) and the workaround available only works with a pocket Wifi Adapter. I have pocket Lan adapters with both of them.
I will contact Solax support again to beg them to open up the local API’s again for integration in Home assistant.

That powercalc site TLS certificate has expired.

Your cumulative sensors may be differently named depending on your emonCMS setup so replace yours in the config @wyx087 (thank you btw!) provided. E.g. I have 3 x feeds that gather kWh totals:

image

  - sensor:
      - name: Consumption
        state: "{{ states('sensor.emoncms_import_kwh') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
      - name: Return to Grid
        state: "{{ states('sensor.emoncms_use_kwh') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
      - name: Solar Production
        state: "{{ states('sensor.emoncms_solar_kwh') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
2 Likes

I now also see this warning in the logs :frowning:

Logger: homeassistant.components.sensor.recorder
Source: components/sensor/recorder.py:196
Integration: Sensor (documentation, issues)
First occurred: 7 August 2021, 21:12:00 (4 occurrences)
Last logged: 7 August 2021, 21:12:00

sensor.totaal_verbruik_net_hoog_tarief_cost has unknown unit EUR
sensor.totaal_verbruik_net_laag_tarief_cost has unknown unit EUR
sensor.totaal_teruglevering_hoog_tarief_compensation has unknown unit EUR
sensor.totaal_teruglevering_laag_tarief_compensation has unknown unit EUR

And still no cost showing up in the energy dashboard.

Template sensors are supported, as long as you use ‘modern’ template sensors and not ‘legacy’ style template sensors.

3 Likes

Thanks for the detailed reply… lol it would have been a touch easier if you had included the template: line above -sensor: though :slight_smile: once I figured out that it was bloody obvious :smiley:

For those that need a complete picture to set up the emoncms and the HA energy visualiser
step1: configure the emoncms integration so it gets all feeds:
step2: configure sensors as per the template below:
step3: set the attributes of the new sensors so they meet the data source requirements for the energy panel see 9/Aug update at the bottom of this post.
step4: configure the energy visualiser via:
http://hassio.lan:8123/energy
or
http://hassio.lan:8123/config/energy
step5: wait

This is what I have in my configuration:yaml for my local emoncms install (a pi v1)

sensor:
  - platform: emoncms
    api_key: < I use the read-only api key you get this from the http://192.168.1.x/feed/api >
    url: http://192.168.1.x/emoncms
    id: 1

template:
  - sensor:
      - name: Consumption
        state: "{{ states('sensor.emoncms_import_kwh') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
        attributes:         
          last_reset: '1970-01-01T00:00:00+00:00'
      - name: Return to Grid
        state: "{{ states('sensor.emoncms_use_kwh') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
        attributes:         
          last_reset: '1970-01-01T00:00:00+00:00'
      - name: Solar Production
        state: "{{ states('sensor.emoncms_solar_kwh') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
        attributes:         
          last_reset: '1970-01-01T00:00:00+00:00'

If you have multiple platforms in your sensor config, make sure you aren’t silly like me and you don’t copy-paste into the wrong part of your configuration.yaml

The last step (once you restart) is to go into you home assistant - developer tools - states page
http://hassio.lan:8123/developer-tools/state (for me)

select each of the 3 new entities:
sensor.consumption
sensor.return_to_grid
sensor.solar-production

and carefully paste the text below into each of these in the “Set State Attributes” box:
last_reset: ‘1970-01-01T00:00:00+00:00’
last_reset_value_template: ‘1970-01-01T00:00:00+00:00’

Make sure you hit SET STATE each time because without doing that it will not show up to be selected in the energy configuration wizard.

a big thankyou to:
@mnestor
@Tockers
@wyx087

If I need to make any further changes, I will incorporate them here so us part-time Home-Asisstant users find it easy to implement the new energy view.

edit: updated 9/Aug to add this to each sensor, as it seems to get lost after a reboot or something?

        attributes:         
          last_reset: '1970-01-01T00:00:00+00:00'
4 Likes

My utility_meter sensors don’t show up in energy either.

Not sure if it’s completely appropriate to post this here but I noticed in the Forecast.Solar Integration there is no way or selecting options for my solar panel / inverter configuration.

I have 6.6kW of solar panels but a 5kW invertor (limited by government regulation) so my solar generation follows a different pattern to if it was 5kW of panels and 5kW invertor, since I can produce more energy during low light conditions compared to having only 5kW of panels, yet my maximum is limited to 5kW.

Any ideas how to work around this? Perhaps I need to email the developer of Forecast.Solar…

1 Like