@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…