Glow / Hildebrand Display - Local MQTT Access - Template Help

@Townsmcp See this post with a workaround :slight_smile: Glow / Hildebrand Display - Local MQTT Access - Template Help - #17 by robertalexa

@JohnWH Generally anything that is deamed to be a general population fix was included in my original post under the Updates section where you can see when and what changed. I knpw this is not ideal, I am still working on a different implementation, just spare time was not on my side, but it will come soon.

Any fixes or debugging specific to users are just in the thread somewhere, although maybe i could include an FAQ in my original post

LE: i have included the template for the negative power issue in the original code as well.

1 Like

@JohnWH you could be on to something there - I have the same model/make smart meters, fitted by EDF - an Elster AS300P/ AM100R SMETS1 meter. I have requested Octopus replace both gas and electric meter as frequently they don’t get meter readings through (even though the data is on the DCC network and in Bright app) which means I get charged the standard variable rate. In the day time it’s a win for me because I’m on the Go tariff but overnight I get screwed when charging the car

If anyone is looking to use MQTT Discovery to pull all the sensors into one device then I have scripted this. So assuming you have the MQTT side of things all up and running

  • Copy code to notepad
  • find and replace REDACTED with the MAC address of your IHD (without the colons)
  • Create a new automation in HA
  • Click the button to edit YAML
  • Copy and paste that code that now includes the MAC of your IHD
  • Save automation (Giving it whatever name you want)
  • Run it
    This will create an electric and gas meter device and add all the sensors underneath. You still need to add the daily cost templates if you want them.
description: ""
mode: single
trigger: []
condition: []
action:
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_electricity_export/config
      payload: >-
        {
        "name": "Smart Meter Electricity: Export",
        "unique_id": "smart_meter_electricity_export",
        "state_topic": "glow/REDACTED/SENSOR/electricitymeter",
        "device_class": "energy",
        "unit_of_measurement": "kWh",
        "state_class": "total_increasing",
        "value_template": "{% raw %}{{ value_json['electricitymeter']['energy']['export']['cumulative'] }}{% endraw %}",
        "icon": "mdi:flash",
        "device": {
            "identifiers": "Smart Electricity Meter via IHD",
            "name": "smart_electricty_meter_REDACTED",
            "model": "Smart Electricity Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_electricity_import/config
      payload: >-
        {
        "name": "Smart Meter Electricity: Import",
        "unique_id": "smart_meter_electricity_import",
        "state_topic": "glow/REDACTED/SENSOR/electricitymeter",
        "device_class": "energy",
        "unit_of_measurement": "kWh",
        "state_class": "total_increasing",
        "value_template": "{% raw %}        {% if value_json['electricitymeter']['energy']['import']['cumulative'] == 0 %}          {{ states('sensor.smart_meter_electricity_import') }}        {% else %}          {{ value_json['electricitymeter']['energy']['import']['cumulative'] }}        {% endif %}{% endraw %}",
        "icon": "mdi:flash",
        "device": {
            "identifiers": "Smart Electricity Meter via IHD",
            "name": "smart_electricty_meter_REDACTED",
            "model": "Smart Electricity Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_electricity_import_today/config
      payload: >-
        {
        "name": "Smart Meter Electricity: Import (Today)",
        "unique_id": "smart_meter_electricity_import_today",
        "state_topic": "glow/REDACTED/SENSOR/electricitymeter",
        "device_class": "energy",
        "unit_of_measurement": "kWh",
        "state_class": "measurement",
        "value_template": "{% raw %}        {% if value_json['electricitymeter']['energy']['import']['day'] == 0           and now() > now().replace(hour=0).replace(minute=1).replace(second=0).replace(microsecond=0) %}          {{ states('sensor.smart_meter_electricity_import_today') }}        {% else %}          {{ value_json['electricitymeter']['energy']['import']['day'] }}        {% endif %}{% endraw %}",
        "icon": "mdi:flash",
        "device": {
            "identifiers": "Smart Electricity Meter via IHD",
            "name": "smart_electricty_meter_REDACTED",
            "model": "Smart Electricity Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_electricity_import_week/config
      payload: >-
        {
        "name": "Smart Meter Electricity: Import (This week)",
        "unique_id": "smart_meter_electricity_import_week",
        "state_topic": "glow/REDACTED/SENSOR/electricitymeter",
        "device_class": "energy",
        "unit_of_measurement": "kWh",
        "state_class": "measurement",
        "value_template": "{% raw %}{{ value_json['electricitymeter']['energy']['import']['week'] }}{% endraw %}",
        "icon": "mdi:flash",
        "device": {
            "identifiers": "Smart Electricity Meter via IHD",
            "name": "smart_electricty_meter_REDACTED",
            "model": "Smart Electricity Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_electricity_import_month/config
      payload: >-
        {
        "name": "Smart Meter Electricity: Import (This month)",
        "unique_id": "smart_meter_electricity_import_month",
        "state_topic": "glow/REDACTED/SENSOR/electricitymeter",
        "device_class": "energy",
        "unit_of_measurement": "kWh",
        "state_class": "measurement",
        "value_template": "{% raw %}{{ value_json['electricitymeter']['energy']['import']['month'] }}{% endraw %}",
        "icon": "mdi:flash",
        "device": {
            "identifiers": "Smart Electricity Meter via IHD",
            "name": "smart_electricty_meter_REDACTED",
            "model": "Smart Electricity Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        } 
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_electricity_import_unit_rate/config
      payload: >-
        {
        "name": "Smart Meter Electricity: Import Unit Rate",
        "unique_id": "smart_meter_electricity_import_unit_rate",
        "state_topic": "glow/REDACTED/SENSOR/electricitymeter",
        "device_class": "monetary",
        "unit_of_measurement": "GBP/kWh",
        "state_class": "measurement",
        "value_template": "{% raw %}{{ value_json['electricitymeter']['energy']['import']['price']['unitrate'] }}{% endraw %}",
        "icon": "mdi:cash",
        "device": {
            "identifiers": "Smart Electricity Meter via IHD",
            "name": "smart_electricty_meter_REDACTED",
            "model": "Smart Electricity Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_electricity_import_standing_charge/config
      payload: >-
        {
        "name": "Smart Meter Electricity: Import Standing Charge",
        "unique_id": "smart_meter_electricity_import_standing_charge",
        "state_topic": "glow/REDACTED/SENSOR/electricitymeter",
        "device_class": "monetary",
        "unit_of_measurement": "GBP",
        "state_class": "measurement",
        "value_template": "{% raw %}{{ value_json['electricitymeter']['energy']['import']['price']['standingcharge'] }}{% endraw %}",
        "icon": "mdi:cash",
        "device": {
            "identifiers": "Smart Electricity Meter via IHD",
            "name": "smart_electricty_meter_REDACTED",
            "model": "Smart Electricity Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_electricity_power/config
      payload: >-
        {
        "name": "Smart Meter Electricity: Power",
        "unique_id": "smart_meter_electricity_power",
        "state_topic": "glow/REDACTED/SENSOR/electricitymeter",
        "device_class": "power",
        "unit_of_measurement": "kW",
        "state_class": "measurement",
        "value_template": "{% raw %}        {% if value_json['electricitymeter']['power']['value'] < 0 %}          {{ states('sensor.smart_meter_electricity_power') }}        {% else %}          {{ value_json['electricitymeter']['power']['value'] }}        {% endif %}{% endraw %}",
        "icon": "mdi:flash",
        "device": {
            "identifiers": "Smart Electricity Meter via IHD",
            "name": "smart_electricty_meter_REDACTED",
            "model": "Smart Electricity Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_gas_import/config
      payload: >-
        {
        "name": "Smart Meter Gas: Import",
        "unique_id": "smart_meter_gas_import",
        "state_topic": "glow/REDACTED/SENSOR/gasmeter",
        "device_class": "energy",
        "unit_of_measurement": "kWh",
        "state_class": "total_increasing",
        "value_template": "{% raw %}        {% if value_json['gasmeter']['energy']['import']['cumulative'] == 0 %}          {{ states('sensor.smart_meter_gas_import') }}        {% else %}          {{ value_json['gasmeter']['energy']['import']['cumulative'] }}        {% endif %}{% endraw %}",
        "icon": "mdi:fire",
        "device": {
            "identifiers": "Smart Gas Meter via IHD",
            "name": "smart_gas_meter_REDACTED",
            "model": "Smart Gas Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_gas_import_today/config
      payload: >-
        {
        "name": "Smart Meter Gas: Import (Today)",
        "unique_id": "smart_meter_gas_import_today",
        "state_topic": "glow/REDACTED/SENSOR/gasmeter",
        "device_class": "energy",
        "unit_of_measurement": "kWh",
        "state_class": "measurement",
        "value_template": "{% raw %}        {% if value_json['gasmeter']['energy']['import']['day'] == 0           and now() > now().replace(hour=0).replace(minute=1).replace(second=0).replace(microsecond=0) %}          {{ states('sensor.smart_meter_gas_import_today') }}        {% else %}          {{ value_json['gasmeter']['energy']['import']['day'] }}        {% endif %}{% endraw %}",
        "icon": "mdi:fire",
        "device": {
            "identifiers": "Smart Gas Meter via IHD",
            "name": "smart_gas_meter_REDACTED",
            "model": "Smart Gas Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_gas_import_week/config
      payload: >-
        {
        "name": "Smart Meter Gas: Import (This week)",
        "unique_id": "smart_meter_gas_import_week",
        "state_topic": "glow/REDACTED/SENSOR/gasmeter",
        "device_class": "energy",
        "unit_of_measurement": "kWh",
        "state_class": "measurement",
        "value_template": "{% raw %}{{ value_json['gasmeter']['energy']['import']['week'] }}{% endraw %}",
        "icon": "mdi:fire",
        "device": {
            "identifiers": "Smart Gas Meter via IHD",
            "name": "smart_gas_meter_REDACTED",
            "model": "Smart Gas Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_gas_import_month/config
      payload: >-
        {
        "name": "Smart Meter Gas: Import (This month)",
        "unique_id": "smart_meter_gas_import_month",
        "state_topic": "glow/REDACTED/SENSOR/gasmeter",
        "device_class": "energy",
        "unit_of_measurement": "kWh",
        "state_class": "measurement",
        "value_template": "{% raw %}{{ value_json['gasmeter']['energy']['import']['month'] }}{% endraw %}",
        "icon": "mdi:fire",
        "device": {
            "identifiers": "Smart Gas Meter via IHD",
            "name": "smart_gas_meter_REDACTED",
            "model": "Smart Gas Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_gas_import_unit_rate/config
      payload: >-
        {
        "name": "Smart Meter Gas: Import Unit Rate",
        "unique_id": "smart_meter_gas_import_unit_rate",
        "state_topic": "glow/REDACTED/SENSOR/gasmeter",
        "device_class": "monetary",
        "unit_of_measurement": "GBP/kWh",
        "state_class": "measurement",
        "value_template": "{% raw %}{{ value_json['gasmeter']['energy']['import']['price']['unitrate'] }}{% endraw %}",
        "icon": "mdi:cash",
        "device": {
            "identifiers": "Smart Gas Meter via IHD",
            "name": "smart_gas_meter_REDACTED",
            "model": "Smart Gas Meter via IHD",
            "manufacturer": "Hildebrand"
        }
        }
      retain: true
  - service: mqtt.publish
    data:
      topic: homeassistant/sensor/smart_meter_gas_import_standing_charge/config
      payload: >-
        {
        "name": "Smart Meter Gas: Import Standing Charge",
        "unique_id": "smart_meter_gas_import_standing_charge",
        "state_topic": "glow/REDACTED/SENSOR/gasmeter",
        "device_class": "monetary",
        "unit_of_measurement": "GBP",
        "state_class": "measurement",
        "value_template": "{% raw %}{{ value_json['gasmeter']['energy']['import']['price']['standingcharge'] }}{% endraw %}",
        "icon": "mdi:cash",
        "device": {
            "identifiers": "Smart Gas Meter via IHD",
            "name": "smart_gas_meter_REDACTED",
            "model": "Smart Gas Meter via IHD",
            "manufacturer": "Hildebrand"
        }		
        }
      retain: true
2 Likes

Did you manage to get a resolution to the kWh/1000 error? i.e. updated firmware from British Gas? I am struggling to get anything from them other than “wait 7-14 days and the problem will resolve itself”, which, of course, it won’t.
Is there a particular team to talk to for example?
Thanks

I have just seen an interesting post regarding how local mqtt gets updated the following day after DCC back populating Missing / Odd data in HA · Discussion #278 · HandyHat/ha-hildebrandglow-dcc · GitHub

I wonder if there is anything that can be done to correct previous day HA figures @robertalexa ?

Post content:
‘I having been discussing the CAD with Jane Wilson at Glowmarkt as I wanted more info before buying. If you are using local MQTT (ie. not Cloud MQTT), then you should get instantaneous power (updates every 10 seconds) and energy consumption for each minute and half hour period calculated locally by the CAD. This half hourly data presumably is what is used by HA. If you have Solar PV and Generation exceeds consumption, then the data will be negative for instantaneous export, per minute and per half hour. Some meters only give cumulative export. Then overnight, Bright will download from the DCC the actual half hourly figures for the previous day and overwrite the figures held in the CAD. I don’t believe HA is updated to show the revised figures, not sure how it would do that as it works in realtime. So on the current day, the CAD and HA will align but when looking back at the previous day, the CAD and the Bright App will align but might not align with the figures previously stored in HA. Also, when the overnight correction occurs, any negative figures (Export to grid) will become zero.

So, if you are using cloud MQTT instead of local then the gap would match the Bright App. But if you are using Local MQTT, then the gap can only be produced locally and not by Bright/DCC so that looks like the CAD has lost connection with the meter. It would be interesting to see if it does it again.‘

I switched this to a blueprint which saves you any copy and pasting.
This will prompt you for your MAC address and generate a script to run to create all the devices / entities

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.
(add_hildebrand.yaml · GitHub)

As well as adding all the sensors this will group them into devices

2 Likes

I moved from EDF to the Octopus Tracker tariff, looks like Octopus doesn’t update their tariffs in the meters so even having local MQTT access, the meter has the wrong prices which doesn’t help. I am gathering the rate data from 00:00 straight from Octopus (the standing charges are not updated often so I pull it every day), create sensors and replaced the sensors that use MQTT, it’s been working well. You can see that it’s the same model as @robertalexa, I just adapted to this case.
For anyone that wants to use it:

sensor:
  - platform: rest
    resource: https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/
    name: "Octopus Gas Today's Price"
    value_template: "{{ (value_json['single_register_gas_tariffs']['_C']['direct_debit_monthly'].standard_unit_rate_inc_vat/100) | round (5) }}"
    unit_of_measurement: 'GBP/kWh'
    scan_interval: 600
  - platform: rest
    resource: https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/
    name: "Octopus Electricity Today's Price"
    value_template: "{{ (value_json['single_register_electricity_tariffs']['_C']['direct_debit_monthly'].standard_unit_rate_inc_vat/100) | round (5) }}"
    unit_of_measurement: 'GBP/kWh'
    scan_interval: 600
  - platform: rest
    resource: https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/
    name: "Octopus Gas Standing Charge Price"
    value_template: "{{ (value_json['single_register_gas_tariffs']['_C']['direct_debit_monthly'].standing_charge_inc_vat/100) | round (5) }}"
    unit_of_measurement: 'GBP/kWh'
    scan_interval: 86400
  - platform: rest
    resource: https://api.octopus.energy/v1/products/SILVER-FLEX-22-11-25/
    name: "Octopus Electricity Standing Charge Price"
    value_template: "{{ (value_json['single_register_electricity_tariffs']['_C']['direct_debit_monthly'].standing_charge_inc_vat/100) | round (5) }}"
    unit_of_measurement: 'GBP/kWh'
    scan_interval: 86400

The _C here is the region, you can which one is yours here:

Then:

template:
  sensor:
    - name: "Smart Meter Electricity: Cost (Today) Octopus"
      unique_id: smart_meter_electricity_cost_today_octopus
      device_class: monetary
      unit_of_measurement: "GBP"
      state_class: "total_increasing"
      icon: mdi:cash
      state: "{{ (
          states('sensor.smart_meter_electricity_import_today') | float
          * states('sensor.octopus_electricity_today_s_price') | float
          + states('sensor.octopus_electricity_standing_charge_price') | float
        ) | round(2) }}"
    - name: "Smart Meter Gas: Cost (Today) Octopus"
      unique_id: smart_meter_gas_cost_today_octopus
      device_class: monetary
      unit_of_measurement: "GBP"
      state_class: "total_increasing"
      icon: mdi:cash
      state: "{{ (
          states('sensor.smart_meter_gas_import_today') | float
          * states('sensor.octopus_gas_today_s_price') | float
          + states('sensor.octopus_gas_standing_charge_price') | float
        ) | round(2) }}"

Then just change the energy dashboard to use these sensors instead.

2 Likes

2023-02-11_09-11-56
Not sure if this is just me but the Electricity and Gas Circles are showing the daily total and not the current consumtion.

Hi,

Excuse my ignorance but if I run your automation after I have already created the sensors in config yaml does it duplicate them, or realise they already exist and not add them again?
I already have the sensors working, I would like them to be grouped under their devices, would this happen if I ran your automation with the result just being the grouping?

Thanks

As long as the sensors have the same IDs they should update. I think it should be ok. Would be interested to know for sure

FYI I noticed in my logs that there were warning messages on some incorrect “state class” for “device class” for these entities:

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:503
Integration: Sensor (documentation, issues)
First occurred: February 8, 2023 at 7:49:07 AM (7 occurrences)
Last logged: February 8, 2023 at 7:49:44 AM

    Entity sensor.smart_meter_electricity_import_this_week (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total', 'total_increasing'; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
    Entity sensor.smart_meter_electricity_import_this_month (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total', 'total_increasing'; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
    Entity sensor.smart_meter_electricity_import_unit_rate (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using state class 'measurement' which is impossible considering device class ('monetary') it is using; expected None or one of 'total'; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
    Entity sensor.smart_meter_electricity_import_standing_charge (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using state class 'measurement' which is impossible considering device class ('monetary') it is using; expected None or one of 'total'; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22

I’m guessing the set of valid “state class” for each “device class” has changed recently, so in my config I changed ‘energy’/‘measurement’ to ‘energy’/‘total_increasing’ and ‘monetary’/‘measurement’ to ‘monetary’/None (remove “state_class”) based on the documentation here:

1 Like

Hi @robertalexa. Thank you for saving me hours, your posted yaml is awesome.

Just to point out, and it has nothing to do with your input, but the energy-date-selection card does not work in a dashboard outside the energy tab. Well for me it doesn’t.
If you select “Compare Data” it doesn’t do anything but in the Energy tab it shows today against yesterday for example… And the comparison is quite useful.

Is this working well for you, @alexhk90 ? I ask as I have changed mine and I have been seeing negative values on the cost in HA since yesterday,just wondering if it’s related to that.

Yes; it’s been working for me, with no obvious difference in behaviour since making the changes last week (on Feb 9, if I remember correctly):

Thanks! Those numbers are fine to me as well but the sources look broken, very weird.

That is very weird - those numbers under “Sources” in the “Energy” dashboard are still OK for me:

I assume those are configured to be calculated using the “Import Unit Rate” entities - do you see them go negative at any time? Or maybe the “Import Standing Charge” given that it’s negative even at zero usage?

1 Like

That’s what’s weird, I have all of them positive and not giving me any negative or 0 value, the calculation per day is showing the correct amount (and the sources amount of power also, 0.3kw is correct there too) and that’s why I am at a loss to what could be happening seeing the last thing I changed was the device_class and state_class but yours is correct so I haven’t got an idea why (yet).

I checked my configuration.yaml again and it turns out I had missed some of the entities, in particular these two which could explain why I didn’t see any change:

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:503
Integration: Sensor (documentation, issues)
First occurred: 1:34:13 AM (3 occurrences)
Last logged: 1:34:50 AM

    Entity sensor.smart_meter_electricity_cost_today (<class 'homeassistant.components.template.sensor.SensorTemplate'>) is using state class 'total_increasing' which is impossible considering device class ('monetary') it is using; expected None or one of 'total'; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+template%22
    Entity sensor.smart_meter_electricity_import_today (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using state class 'measurement' which is impossible considering device class ('energy') it is using; expected None or one of 'total', 'total_increasing'; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22

I’ve updated them similarly now and will check over the next few days and let you know if I see the same negative cost values on the Energy dashboard.

I’m seeing the zero cost value myself now - seems the Energy dashboard doesn’t like the updated state class:

Changing that entity’s “state_class” back to “measurement” removes that warning and will presumably fix it, but I do now see another warning:

For reference, these validations for the entities used by the Energy dashboard seem to come from here:

And the log warnings I noticed are relatively new, only introduced a month or so ago:

Perhaps it was a false positive and these warnings need some refining.

In short, I think best to stick with the original configuration from @robertalexa at the start of this thread for now - trying to fix these log warnings probably causes more hassle than it’s worth. :upside_down_face:

@alexhk90 what state_class did you change it to? I had to change from measurement to ‘total_increasing’ as this sensor is NOT to be recording the given point in time energy usage; we want to track consumption. The following is my code, works perfectly for energy dashboard

mqtt:
  sensor:  
    - name: "Smart Meter Electricity: Import (Today)"
      unique_id: 6e1691a4-0c3d-43a3-9e3f-4726d0009994
      state_topic: !secret smart_ihd_state_topic_electric
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
#      state_class: "measurement"
      value_template: >
        {% if value_json['electricitymeter']['energy']['import']['day'] == 0 
          and now() > now().replace(hour=0).replace(minute=1).replace(second=0).replace(microsecond=0) %}
          {{ states('sensor.smart_meter_electricity_import_today') }}
        {% else %}
          {{ value_json['electricitymeter']['energy']['import']['day'] }}
        {% endif %}
      icon: "mdi:flash"
    - name: "Smart Meter Gas: Import (Today)"
      unique_id: "smart_meter_gas_import_today"
      state_topic: !secret smart_ihd_state_topic_gas
      device_class: "energy"
      unit_of_measurement: "kWh"
      state_class: "total_increasing"
#      state_class: "measurement"
      value_template: >
        {% if value_json['gasmeter']['energy']['import']['day'] == 0
          and now() > now().replace(hour=0).replace(minute=1).replace(second=0).replace(microsecond=0) %}
          {{ states('sensor.smart_meter_gas_import_today') }}
        {% else %}
          {{ value_json['gasmeter']['energy']['import']['day'] }}
        {% endif %}
      icon: "mdi:fire"

See here https://community.home-assistant.io/t/energy-dashboard-last-reset-missing/406733/2 which states:
The state class for “energy” entities should be “total_increasing” (energy consumed since the last reset), “measurement” is suitable for “power” entities expressed in W…