Home Assistant Energy Integration

Hi, 

I am trying to integrate to the the new "Energy" component of Home Assistant but cannot find the sensor created/generated by my two IAMMETER meters for the grid import/export

The Home Assistant page says I should point you in the direction fo this page to update the way the sensors are created

https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics

Is this something on the road map to update the Home Assistant component

Thread Status
65
4855
15
22
4

Sort replies by:

also now eagerly awaiting this to work with the new home assistant energy monitoring. looks very simple 

Hi, I am trying to integrate to the the new "Energy" component of Home Assistant but cannot find the sensor created/generated by my two IAMMETER meters for the grid import/exportThe Home Assistant page says I should point you in the direction fo this page to update the way the sensors are createdhttps://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics





Is this something on the road map to update the Home Assistant component

Yes, it is simple.


please refer to https://www.iammeter.com/docs/homeassistant


And https://www.home-assistant.io/integrations/iammeter/


Is there any problem when you refer to these two documents?

also now eagerly awaiting this to work with the new home assistant energy monitoring. looks very simple 

Total on the wrong track there. Have a look at this blog to understand what I am on abaout, Its the new energy dashboard from Home Assistant and not the integration of IAMMETER

https://www.home-assistant.io/blog/2021/08/04/home-energy-management/

Basically IAMMETER needs to update the integration to suport the new energy dashboard

https://www.iammeter.com/docs/homeassistanthttps://www.home-assistant.io/integrations/iammeter/

Seems IAMMETER dont have a clue what we are on about :(

also now eagerly awaiting this to work with the new home assistant energy monitoring. looks very simple 

No its not simple


It, not the integration, thats easy to do. Its the sensors etc that IAMMETER integration is creating


Basically IAMMETER needs to update the integration to suport the new energy dashboard sensor

Yes, it is simple.please refer to https://www.iammeter.com/docs/homeassistantAnd https://www.home-assistant.io/integrations/iammeter/Is there any problem when you refer to these two documents?

it is simple from the perspective of code upgrading.
In fact, we have always tried to upgrade our HA integration.
But every time we submit PR to it, it is hard to get any replies after the first manual review.

Like this https://github.com/home-assistant/core/pull/49735
We can not merge any code in HA since about 8 months ago, even we have always modified our code according to the suggestion of HA maintainer at the first time.

We do not know what had happened.







No its not simpleIt, not the integration, thats easy to do. Its the sensors etc that IAMMETER integration is creatingBasically IAMMETER needs to update the integration to suport the new energy dashboard sensor


We do not know when we can merge our integration successful to HA, before that we will try to find a compromised method to use IAMMETER product in the energy component of HA.
When we find the method ,we will post it here.


Will see if we as the community can get some motion on it

it is simple from the perspective of code upgrading.In fact, we have always tried to upgrade our HA integration.But every time we submit PR to it, it is hard to get any replies after the first manual review.Like this https://github.com/home-assistant/core/pull/49735We can not merge any code in HA since about 8 months ago, even we have always modified our code according to the suggestion of HA maintainer at the first time.We do not know what had happened.

Using the utility_meter route seems the best way at the moment.

Once I setup the below I can add my import/export to the HA Energy dashboard


sensor:
- platform: iammeter
host: xxx.xxx.xxx.xxx
name: meter

utility_meter:
energy_import_daily:
name: Daily Import Energy
source: sensor.meter_importenergy
cycle: daily
energy_export_daily:
name: TOCK Daily Export Energy
source: sensor.meter_exportgrid
cycle: daily

We do not know when we can merge our integration successful to HA, before that we will try to find a compromised method to use IAMMETER product in the energy component of HA.When we find the method ,we will post it here.

I have now found a more convenient way to add the following code in configuration.yaml:

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

I'd like to warn about strange warnings in supervisor's log when you add above lines in config.yaml. There are warnings about unknown unit of measurement. Whole thins works ok, but these warnings are present at each restart...


Please only add sensor.*_importenergy and sensor.*_exportgrid, if you want to add these voltage, current, power, frequency, pf, please refer to https://developers.home-assistant.io/docs/core/entity/sensor/#long -term-statistics Modify device classes,for example:

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

I suspect there will be a whole heap of updating to be done on this integration from those coding at/for HA.  As an example, there's currently no elegant way to incorporate a battery into that integration.  When I've tried it just subtracts or adds the battery flow from solar or grid energy flow.  Ie at night time, when the powerwall is supplying the house with power, HA calls that a grid import or solar goes negative.  The energy flow has to show somewhere and currently there's no battery option.

If using 3 phase, this needs an extra asterisk before it will appear as a Home Assistant energy source - sensor.*_importenergy*:

I have now found a more convenient way to add the following code in configuration.yaml:homeassistant:  customize_glob:    sensor.*_importenergy:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: energy      state_class: measurement        sensor.*_exportgrid:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: energy      state_class: measurement 

Yes, we indeed want to upgrade our integration either.
But as I said in above thread, it is very difficult to merge new integration code in HA from the last year (there will be not any feedback after the first reviewer any more), we also do not know how do do now.


Like this https://github.com/home-assistant/core/pull/49735

I suspect there will be a whole heap of updating to be done on this integration from those coding at/for HA.  As an example, there's currently no elegant way to incorporate a battery into that integration.  When I've tried it just subtracts or adds the battery flow from solar or grid energy flow.  Ie at night time, when the powerwall is supplying the house with power, HA calls that a grid import or solar goes negative.  The energy flow has to show somewhere and currently ther

homeassistant:

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

If using 3 phase, this needs an extra asterisk before it will appear as a Home Assistant energy source - sensor.*_importenergy*:

Hello
apparently no longer works on version 2021.9

state_class must be put: total_increasing


at least since I made the change I no longer have the error message

hello

since HA 2020.09

the data modification no longer works

i tried to remplace measurement by total_increasing  but inconclusive

since HA 2021.09

add the following code in configuration.yaml:

homeassistant:

  customize_glob:
    sensor.*_importenergy*:
      last_reset: '1970-01-01T00:00:00+00:00'
      device_class: DEVICE_CLASS_ENERGY

      state_class: total_increasing

    sensor.*_exportgrid*:
      last_reset: '1970-01-01T00:00:00+00:00'
      device_class: DEVICE_CLASS_ENERGY

      state_class: total_increasing

"When we find the method ,we will post it here."


Hello,


is there any news about this? Any official implementation of IAMMETER products for the new "Energy" section in Home Assistant?

It's weird that Home Assistant makes it hard to update your integration: if there is something the community can do, let us know.


Regards,

Ben

We do not know when we can merge our integration successful to HA, before that we will try to find a compromised method to use IAMMETER product in the energy component of HA.When we find the method ,we will post it here.

Hi Ben:

Of course, my colleague had already found the solution, please refer to this above post.


"When we find the method ,we will post it here."Hello,is there any news about this? Any official implementation of IAMMETER products for the new "Energy" section in Home Assistant?It's weird that Home Assistant makes it hard to update your integration: if there is something the community can do, let us know.Regards,Ben

Hello everyone


I have a problem with my data, Some day I have completely crazy values, do you know where this could come from?
Thank you

The reason for the sudden increase of homeassistant statistics should be that the homeassistant may get 0 when the meter is started. If your meter has an older firmware version, you can upgrade to the latest firmware. This problem has been resolved in the new firmware (For WEM3080 series , only the firmware version of 1.70.x and later can be upgraded to this version. Please do not upgrade your firmware if the version is earlier than 1.70.1.), firmware address and upgrade notes: https://imeter.club /topic/11
If your meter's firmware version is less than 1.70.1, of course, there is a solution, by changing the configuration of homeassistant to shield the situation that the power suddenly becomes 0:

sensor:
- platform: template
sensors:
newname_importenergy_a:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_importenergy_a') | int > 0 %}
{{ states('sensor.wem3080t_importenergy_a') }}
{% endif %}
newname_exportgrid_a:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_exportgrid_a') | int > 0 %}
{{ states('sensor.wem3080t_exportgrid_a') }}
{% endif %}
newname_importenergy_b:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_importenergy_b') | int > 0 %}
{{ states('sensor.wem3080t_importenergy_b') }}
{% endif %}
newname_exportgrid_b:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_exportgrid_b') | int > 0 %}
{{ states('sensor.wem3080t_exportgrid_b') }}
{% endif %}
newname_importenergy_c:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_importenergy_c') | int > 0 %}
{{ states('sensor.wem3080t_importenergy_c') }}
{% endif %}
newname_exportgrid_c:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_exportgrid_c') | int > 0 %}
{{ states('sensor.wem3080t_exportgrid_c') }}
{% endif %}

Hello everyoneI have a problem with my data, Some day I have completely crazy values, do you know where this could come from?Thank you

Thank you, I updated it, I am waiting for the results

The reason for the sudden increase of homeassistant statistics should be that the homeassistant may get 0 when the meter is started. If your meter has an older firmware version, you can upgrade to the latest firmware. This problem has been resolved in the new firmware (For WEM3080 series , only the firmware version of 1.70.x and later can be upgraded to this version. Please do not upgrade your firmware if the version is earlier than 1.70.1.), firmware address and upgrade notes: https://imet

Thanks Miwifi,

 It works fine! Do you know how I can remove data errors? Thank you

The reason for the sudden increase of homeassistant statistics should be that the homeassistant may get 0 when the meter is started. If your meter has an older firmware version, you can upgrade to the latest firmware. This problem has been resolved in the new firmware (For WEM3080 series , only the firmware version of 1.70.x and later can be upgraded to this version. Please do not upgrade your firmware if the version is earlier than 1.70.1.), firmware address and upgrade notes: https://imet

It may be stored in config/.storage/core.restore_state
Or in the statistics* data table of the mysql database
I'm not sure

Hello.


I have wem3080t with Home Assistant 2021.11.4.


In my config I have:

homeassistant:
customize_glob:
sensor.*_importenergy*:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: DEVICE_CLASS_ENERGY

state_class: total_increasing

sensor.*_exportgrid*:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: DEVICE_CLASS_ENERGY

state_class: total_increasing


sensor:
- platform: iammeter
host: 192.168.1.50
name: meter




But, when I try to add to the energy tab there is no source on the list :( . Of course the entity list is fine, ant I can find the meter, so it is working, but can't add to the energy tab...


I missed something?


Thanks


You can use the following configuration, the new version of homeassistant seems to have been changed,

homeassistant:
customize_glob:
sensor.*_importenergy*:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.*_exportgrid*:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing

Hello.I have wem3080t with Home Assistant 2021.11.4.In my config I have:homeassistant:  customize_glob:    sensor.*_importenergy*:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: DEVICE_CLASS_ENERGY      state_class: total_increasing    sensor.*_exportgrid*:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: DEVICE_CLASS_ENERGY      state_class: total_increasing  sensor:  - platform: iammeter    host: 192.168.1.50    name: meterBut, when I try to add to the energy ta

Thank you very much. Now it looks good!

You can use the following configuration, the new version of homeassistant seems to have been changed,homeassistant:  customize_glob:    sensor.*_importenergy*:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: energy      state_class: total_increasing    sensor.*_exportgrid*:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: energy      state_class: total_increasing

I can integrate the sensors into HA Energy Dashboard OK, see below. That is using the "customize_glob:    sensor.*_importenergy*" notes above from miwyf:

customize_glob:

sensor.*_importenergy*:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.*_exportgrid*:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing

That works well:



But as soon as I try and assign a cost to the sources:



HA recorder notes errors and fails to track them:

2022-01-08 11:45:10 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.iammeter3_importenergy_a_cost has unit AUD which is unsupported for device_class energy


So the balances always stay at $0.00.


Is anyone tracking costs in HA, and how are they assigning costs/kWh?

I've had to specify without wildcards, as the wildcards catch the cost/compensation entities created by HA.

No $ values yet, but the recorder/statistics errors have disappeared, so I'm assuming this is a step in the right direction at least.

customize_glob:
sensor.iammeter3_importenergy_c:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.iammeter3_importenergy_b:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.iammeter3_importenergy_a:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.iammeter1_importenergy:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.iammeter1_exportgrid:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing

I can integrate the sensors into HA Energy Dashboard OK, see below. That is using the "customize_glob:    sensor.*_importenergy*" notes above from miwyf:customize_glob:    sensor.*_importenergy*:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: energy      state_class: total_increasing    sensor.*_exportgrid*:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: energy      state_class: total_increasingThat works well:But as soon as I try and assign


Try upgrading to the latest version? I found no problems here.

I'm running latest version.

Specifying the customize_glob to be exactly per sensors makes it work: e.g. sensor.iammeter3_importenergy_c. leaving with the wildcard afterwards is applying the "device_class: energy" to all entities which match the wildcard... which includes the cost / consumption ones created by HA when I add cost to the energy source. Your setup may be different, but this *will* catch some people - suggest you place a caveat on the definition, or change it so it does not catch them.

in fact, we have always tried to upgrade our HA integration since 2020,we also want to support the new features of home assistant , such as energy management.
But it is very difficult for us to merge any new code in HA now.
The PR can never get any response for more than half a year.
like this
https://github.com/home-assistant/core/pull/49735
we are still waiting for the reviewer of HA will come back in one day. 

I'm running latest version.Specifying the customize_glob to be exactly per sensors makes it work: e.g. sensor.iammeter3_importenergy_c. leaving with the wildcard afterwards is applying the "device_class: energy" to all entities which match the wildcard... which includes the cost / consumption ones created by HA when I add cost to the energy source. Your setup may be different, but this *will* catch some people - suggest you place a caveat on the definition, or change it so it does not catch them

Hi folks, update on my Home Assistant integration efforts. Note as this site does not have a code plain text view, any YAML is not properly indented.

First learning - customize_glob wildcard problems

For me, using the suggested customize_glob with wildcards for the sensors (e.g. sensor.*_importenergy*) caused problems with statistics.

The resultant entities were usable in Energy Dashboard, and everything looked OK at first. But when I added a cost to the entity in Energy Dashboard config it created an entity which also was 'caught' by the customize_glob - so for sensor.iammeter1_importenergy entity, I then got  sensor.iammeter1_importenergy_cost. The customize_glob "sensor.*_importenergy*" then forced sensor.iammeter1_importenergy_cost to have "device_class: energy" and "state_class: total_increasing". As it had a unit of AUD, this failed to work, and recorder did not accumulate statistics for the cost entities. This was visible as an error in Developer Tools / Statistics.

So I changed to specify each sensor in full, not with a glob:

customize:
sensor.iammeter3_importenergy_c:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.iammeter3_importenergy_b:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.iammeter3_importenergy_a:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.iammeter1_importenergy:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing
sensor.iammeter1_exportgrid:
last_reset: '1970-01-01T00:00:00+00:00'
device_class: energy
state_class: total_increasing

Once I had done that, the financial entities were no longer being forced to incorrect classes, and recorder accepted them for stats, and the $ worked. 

Second learning - adding power entities for recorder/statistics

I wanted to track power produced/imported. So I added the following to the customize: section:

sensor.iammeter1_power:
device_class: power
state_class: measurement
sensor.iammeter3_power_a:
device_class: power
state_class: measurement
sensor.iammeter3_power_b:
device_class: power
state_class: measurement

Once I did that, recorder accepted these entities for proper historical statistics, meaning I can now track max, min, mean etc. for power. Note that state_class measurement do not have last_reset.

Third learning - setting up for non-Dashboard power/energy tracking

Home Assistant Energy Management does not yet track power... and I wanted to recreate the views available from the iammeter website. Using the instructions at https://community.home-assistant.io/t/monitor-your-solar-pv-system-in-home-assistant-energy-dashboard-vs-energy-management/342710 I set up all of the entities (sensors and utility_meters) to use the Apex Chart integration. Initially these were as recommended in that tutorial, e.g.:

- platform: template 
     sensors:
        grid_consumption_energy:
           unit_of_measurement: 'kWh'
           value_template: "{{ states('sensor.solar_importenergy_b') }}"

...however I ran into problems. For statistics to work nicely you need to set device_class and state_class. Using the newer sensor format, I then got this:

template:
   - sensor:
      - name: "Grid consumption energy (general tariff)"
         unit_of_measurement: 'kWh'
         device_class: energy
         state_class: total
         state: {{ states('sensor.iammeter1_importenergy')|float }}

That appeared to be working OK, but... :) noooo...

Every so often the Iammeter's go 'offline' for a few seconds. When they did, the utility_meters would see a zero value. Utility_meters based on entities with a state_class of total or total_increasing see a zero value as an instruction to reset to what the underlying sensor says. It is so if you replace the meter, it picks up what the new base value is. Problem is, that these resets to zero were causing the utility_meters to pick up the non-zero value of the Iammeter. In one instance I had 4 glitches in a couple of minutes which saw my utility_meter go from a couple of kWh to 1,100kWh in about 30 seconds. 

So you need to add an availability check. This means the sensor goes to "unavailable" instead of zero, and prevents the resets. 

What I ended up with, laid out for readability:

  - sensor:
     - name: "Grid consumption energy (general tariff)"
        unit_of_measurement: 'kWh'
        device_class: energy
        state_class: total
        state: >-
           {{
              states('sensor.iammeter1_importenergy')|float
           }}
        unique_id: 2452716747549
        availability: >-
          {{
             is_number(states('sensor.iammeter1_importenergy'))
          }}

That was all yesterday... and I now have it working properly, although I had to make an adjustment this morning, so the maths are not exactly correct on this screenshot:

there is a solution, by changing the configuration of homeassistant to shield the situation that the power suddenly becomes 0:

sensor:
- platform: template
sensors:
newname_importenergy_a:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_importenergy_a') | int > 0 %}
{{ states('sensor.wem3080t_importenergy_a') }}
{% endif %}
newname_exportgrid_a:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_exportgrid_a') | int > 0 %}
{{ states('sensor.wem3080t_exportgrid_a') }}
{% endif %}
newname_importenergy_b:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_importenergy_b') | int > 0 %}
{{ states('sensor.wem3080t_importenergy_b') }}
{% endif %}
newname_exportgrid_b:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_exportgrid_b') | int > 0 %}
{{ states('sensor.wem3080t_exportgrid_b') }}
{% endif %}
newname_importenergy_c:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_importenergy_c') | int > 0 %}
{{ states('sensor.wem3080t_importenergy_c') }}
{% endif %}
newname_exportgrid_c:
unit_of_measurement: 'kWh'
value_template: >
{% if states('sensor.wem3080t_exportgrid_c') | int > 0 %}
{{ states('sensor.wem3080t_exportgrid_c') }}
{% endif %}

Yep... using "availability:" checks to see if the source entity is available (i.e. it's a number, but which could include zero) before publishing the sensor:

availability: >-
          {{
             is_number(states('sensor.iammeter1_importenergy'))
          }}

Your check tests to see if it is available AND greater than zero:

value_template: >
{% if states('sensor.wem3080t_exportgrid_c') | int > 0 %}
{{ states('sensor.wem3080t_exportgrid_c') }}
{% endif %}

In the new sensor format, your one could be written:

- sensor:
     - name: "Grid consumption energy (general tariff)"
        unit_of_measurement: 'kWh'
        device_class: energy
        state_class: total
        state: >-
           {% if states('sensor.iammeter1_importenergy') | int > 0 %}
             {{
                states('sensor.iammeter1_importenergy') | float
             }}
           {% endif %}

Both accomplish the same thing I think... I'll test to see. 

What I am finding is that the utility_meter approach is resulting in slightly incorrect readings, mainly on the imported energy one... where the Energy Dashboard is spot on. I'm going to test and see if the different availability tests change that.



Here is an example of what I mean about inaccurate readings.



I tracked the Iammeter sensors over 24h, and they match almost 100% with what Energy Dashboard shows. But the utility_meters have a small variation - in the example above it's 3% under.

The config for those is:

  - sensor:
       - name: "Grid consumption energy (general tariff)"
          unit_of_measurement: 'kWh'
          device_class: energy
          state_class: total
          state: >-
             {{
                states('sensor.iammeter1_importenergy')|float
             }}
          availability: >-
             {{
                is_number(states('sensor.iammeter1_importenergy'))
             }}

...and its utility_meter:

grid_consumption_general_energy_daily:
      source: sensor.grid_consumption_energy_general_tariff
      cycle: daily

For some reason it is under-recording.

I found a useful tip on the HA github for utility_meters relying on sensors that sometimes go unavailable, and have edited the sensors as follows:

  - sensor:
      - name: "Grid consumption energy (general tariff)"
         unit_of_measurement: 'kWh'
         device_class: energy
         state_class: total_increasing
         state: >-
            {% if states('sensor.iammeter1_importenergy') in ['unavailable', 'unknown', 'none', 0] %}
               {{
                   states('sensor.grid_consumption_energy_general_tariff')|float
               }}
                  {% else %}
               {{
                  states('sensor.iammeter1_importenergy')|float
               }}
            {% endif %}

I like this because it catches all of the things the iammeter sensor should never be: unavailable, unknown, none or 0... and if that is the case, it just uses the existing value. I'll see how this goes.

...and with those sensor definitions behind the utility_meters, today for the first time all of the utility meters read EXACTLY the same as Energy Dashboard.

This is very good, we are also actively communicating the method of passing pr, hope hass can pass pr as soon as possible

I found a useful tip on the HA github for utility_meters relying on sensors that sometimes go unavailable, and have edited the sensors as follows:  - sensor:      - name: "Grid consumption energy (general tariff)"         unit_of_measurement: 'kWh'         device_class: energy         state_class: total_increasing         state: >-            {%

The HomeAssistant updates this last week have resulted in an issue when my HA reboots - the template sensors sample a non-zero value on the total_increasing iammeter values on the way up/down, resulting in the Utility Meters resetting (adding) the previous total value.

I've made the following tweak to my config, and will see how it goes (I've added the ELIF < current value section)


  - sensor:
      - name: "Grid consumption energy (general tariff)"
        unit_of_measurement: 'kWh'
        device_class: energy
        state_class: total_increasing
        state: >-
           {% if states('sensor.iammeter1_importenergy') in ['unavailable', 'unknown', 'none', 0] %}
              {{
                  states('sensor.grid_consumption_energy_general_tariff')|float
              }}
           {% elif states('sensor.iammeter1_importenergy')|float < states('sensor.grid_consumption_energy_general_tariff')|float %}
              {{
                  states('sensor.grid_consumption_energy_general_tariff')|float
              }}
           {% else %}
              {{
                  states('sensor.iammeter1_importenergy')|float
              }}
          {% endif %}


Only other thing I am thinking is whether I need to build in a small amount of +/-, i.e. make it "less than current value * 98%" or similar to give it some room to vary slightly with tolerances.

This is very good, we are also actively communicating the method of passing pr, hope hass can pass pr as soon as possible

Your method is getting better and better. Of course, adding a tolerance value is also a good method. Thank you for sharing so that we have more ways to solve this problem.

The HomeAssistant updates this last week have resulted in an issue when my HA reboots - the template sensors sample a non-zero value on the total_increasing iammeter values on the way up/down, resulting in the Utility Meters resetting (adding) the previous total value.I've made the following tweak to my config, and will see how it goes (I've added the ELIF < current value section)  - sensor:      - name: "Grid consumption energy (general tariff)"       

Thanks - I am sure I read somewhere (can't find it just now) that total_increasing has a tolerance threshold for slight reductions, so I am running with this methodology to define sensors for my Iammeter inputs, which I then use in my own custom Energy Dashboard (not the Home Assistant one)


  - sensor:
     - name: "Grid consumption energy (general tariff)"
        unit_of_measurement: 'kWh'
        device_class: energy
        state_class: total_increasing
        state: >-
           {% if states('sensor.iammeter1_importenergy') in ['unavailable', 'unknown', 'none', 0] %}
              {{
                  states('sensor.grid_consumption_energy_general_tariff')|float
              }}
           {% elif states('sensor.iammeter1_importenergy')|float < (states('sensor.grid_consumption_energy_general_tariff')|float * 98/100) %}
              {{
                 states('sensor.grid_consumption_energy_general_tariff')|float
              }}
          {% else %}
             {{
                states('sensor.iammeter1_importenergy')|float
             }}
          {% endif %}

where do I add customize_glob?


since HA 2021.09add the following code in configuration.yaml:homeassistant:  customize_glob:    sensor.*_importenergy*:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: DEVICE_CLASS_ENERGY      state_class: total_increasing    sensor.*_exportgrid*:      last_reset: '1970-01-01T00:00:00+00:00'      device_class: DEVICE_CLASS_ENERGY      state_class: total_increasing
Looks like you are new here. Register for free, learn and contribute.