Home Assistant new Energy features

That would be great if you could :slight_smile:

This of course adds extra impetus to looking at getting the Emoncms Add-on going properly.

My biggest concern with the HA implementation would be the integrity of the long term data.


Would you mind sharing your emoncms config for the import_all_time feed?

Thanks in advance!!

Sure, hopefully this is what you are asking for:

In EmonCMS, go to Setup → Inputs and click the little spanner to add the circled part to your solar production (assuming your solar generation reads power in W or kW, not energy Wh or kWh) to get that Feed.

In EmonCMS, I have 3 power inputs: solar production, grid power (this one goes negative for export) and a house fuse-box (or consumer unit) consumption. Not directly measured is outdoor EV charging, but it can be easily calculated.

When you add a process, the blue description text box below tells you the output from that process, the output is then fed into the next process, this way you can do maths or logic. Very elegant solution to provide huge amount of flexibility, well done whoever designed it.

1 Like

I have used the standard feeds set up when I installed my emonPi for solar/consumption monitoring.
Took a while for info to start showing up, and I haven’t yet seen everything populate including solar production and widgets. Not sure if this is because I am not using the correct feeds…

  - 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

One thing I like about this new ENERGY integration in HomeAssistant is that it is very easy to see electricity tariff info and COSTS. I split grid imports into Peak/OffPeak Feeds in EmonCMS. This allows me to enter TWO consumption entities in the Grid Consumption section of the Energy Integration.

1 Like

… and for anyone following along … this is the input process …

I have one Schedule defined in EmonCMS called ‘Peak’ which looks like this:

Screen Shot 2021-08-08 at 13.51.31

As today is a Sunday (actually is a nice Winter Sunny Day :smiley: )
my ‘peak’ costs are currently zero.

Hope this helps other HA users out there. Regards


Thank you, having used openenergymonitor since 2013 its great to see others focusing on energy as well and it would be superb to have this functionality in my HA

how did this turn out as my feeds are also different and my data is all at 0 even the distribution on the right hand side

  - sensor:
      - name: HAEnergy Consumption
        state: "{{ states('sensor.emoncms_import_all_time') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
      - name: HAEnergy Return to Grid
        state: "{{ states('sensor.emoncms_export_all_time') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
      - name: HAEnergy Solar Production
        state: "{{ states('sensor.emoncms_SolarTotal') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy
      - name: HAEnergy EV Consumption
        state: "{{ states('sensor.emoncms_Power3EV') | float | round(2) }}"
        unit_of_measurement: "kWh"
        state_class: measurement
        device_class: energy

This is what I see from my emonpi (note I don’t have solar panels, so just consumption to capture)

On the HA side:

I don’t see anything populated in the energy dashboard…

Entity view:


2 posts were split to a new topic: MQTT connection errors

I’ve set this up, but either I am misreading this, or it is not quite as expected. I’m wondering whether HA expects both positive and negative values from “grid”


I think we might be in the same boat - I have Type 2 solar PV setup so it is calculating export off a negative figure. I didn’t think it through when I just assigned my 3 x standard kWh feeds to HA, which will never work. I need to find time to rethink the logic and then set up a new feed in emonCMS to provide an Export sensor to HA.

  • CT1 (power 1) = grid import (positive) / export (negative), and
  • CT2 (power 2) = solar generation,

Type 2 system: Site-consumption = Generation + Grid import (negative when exporting)

HA is expecting energy (kWh) figures in same style as always incrementing meter readings for:

  • Consumption
  • Export (return to grid)
  • Solar

If you have a single sensor reading positive for import and negative for export, you’ll need to do something like this to the input:

  1. *-1
  2. allow positive >0
  3. power to energy kWh (this is your export feed for HA)
  4. reset to original
  5. +solar
  6. power to energy kWh (this is your consumption feed for HA)

HA isn’t expecting negative figures. All 3 energy readings should be always increasing.

Thanks @wyx087, I assume I can flow this on from the existing input process? Only bit I can’t figure out is your first process step. Can you explain how to add a wildcard process or how would it appear in emoncms process list options?

Taking input ‘power 1’ and adding processes:

[quote=“Tockley, post:22, topic:18301”]
I need to find time to rethink the logic
[/quote]I might just wait for you to figure it out :slight_smile:

@Tockley the command you actually want is x -1 (where x = times and then minus one)

Back to HA though:
This is one of the things that pisses me off about HA, it does everything but the docco and how data flows is manipulated is significantly under-described.

I mean, there is NOWHERE to find out how the energy part is calculated, what it expects, etc.

:sweat_smile: :man_facepalming: of course, thanks.

No I think it was fine (and obvious in hindsight), my brain didn’t make the leap though

Apologies, that wasn’t clear. I thought I’d use mathematically correct character as input on computer. But obviously it doesn’t read correct and I forgot to check how it is displayed on EmonCMS.

Agree. The documentation for this new energy feature is waaaaaay less than their usual integration. I only figured out everything by very closely follow the thread on HA community. Even then, people had to guess how the dashboard is updated.

Would love the documentation about now too! :expressionless:
My data seems to have gone a bit haywire after making the corrections to my feeds from emoncms just for one period today… don’t suppose anyone has figured out how to remove/reset energy data?

I think the next day will give you correct data.

From what I can gather, the calculations are done after each hour, comparing current value against value from 1 hour ago. So check again tomorrow and everything will look correct.

But no idea how to reset apart from blow away your whole database. If you use MariaDB, you can try using phpMyAdmin add-on, then manually find & delete relevant entry.

1 Like