Hi,
was wondering if anyone has the feeds from Emoncms working in the new energy integration in Home Assistant. The energy integration seems quite “picky” in the energy format required.
Cheers
Gary
Refer my posts here:
I believe there are some updates about to arrive in HA 2021.9 for the Energy facility.
Thanks Muzza. (Thinks to self … must be an Aussie.)
I ended up pushing to HA via MQTT and using the integration platform in HA to get things working. My HA config is below.
- platform: mqtt
name: "Electric Use Immediate"
state_topic: "emon/current/use"
unique_id: "electric_use_immediate"
unit_of_measurement: "W"
device_class: "energy"
- platform: mqtt
name: "Electric Solar Immediate"
state_topic: "emon/current/solar"
unique_id: "electric_solar_immediate"
unit_of_measurement: "W"
device_class: "energy"
- platform: mqtt
name: "Electric Import Immediate"
state_topic: "emon/current/import"
unique_id: "electric_import_immediate"
unit_of_measurement: "W"
device_class: "energy"
- platform: template
sensors:
emoncms_import_normalized:
unit_of_measurement: "W"
value_template: >
{% if (states('sensor.electric_import_immediate') | float) >= 0 %}
{{ states('sensor.electric_import_immediate') | float }}
{% else -%}
0
{% endif %}
emoncms_export_normalized:
unit_of_measurement: "W"
value_template: >
{% if (states('sensor.electric_import_immediate') | float) < 0 %}
{{ (states('sensor.electric_import_immediate') | float) | abs }}
{% else -%}
0
{% endif %}
emoncms_solar_normalized:
unit_of_measurement: "W"
value_template: >
{% if is_state('sun.sun', 'above_horizon') %}
{{ states('sensor.electric_solar_immediate') | float }}
{% else -%}
0
{% endif %}
- platform: integration
source: sensor.electric_use_immediate
name: "Electric Use kWh"
method: left
unit_prefix: k
round: 2
- platform: integration
source: sensor.emoncms_solar_normalized
name: "Electric Solar kWh"
method: left
unit_prefix: k
round: 2
- platform: integration
source: sensor.emoncms_import_normalized
name: "Electric Import Running kWh"
method: left
unit_prefix: k
round: 2
- platform: integration
source: sensor.emoncms_export_normalized
name: "Electric Export Running kWh"
method: left
unit_prefix: k
round: 2
The gist of it: It takes the immediate usage (watts) from EmonCMS via MQTT. It splits the grid import into 2 HA sensors based on direction (import/export) so that it always stays positive. Then it runs the integration on each to get the running kWh for the energy monitoring.
For any one else trying to work this out - this is the link to the integration
Integration i.e. an HA Integration that does integration . Integration - Riemann sum integral - Home Assistant
Which integration option would you recommend when creating a daily electricity consumption helper, please? I’ve stumbled on many HA community posts recommending “Left”.
Should I be selecting Hours or Days for the Time unit, please?
No idea. not looked at this. Useful to know what you find…
Will set up a few and see how they compare.
Perhaps it would be better to use HA’s more recent Utility Meter helper.