To follow up on this, I managed to resolve the warnings in the log by changing the state class to total and explicitly setting the last_reset to fix the negative cost values:
template:
sensor:
- name: "Smart Meter Electricity: Cost (Today)"
unique_id: smart_meter_electricity_cost_today
device_class: "monetary"
state_class: "total" # requires "last_reset" for use to track costs in energy dashboard
unit_of_measurement: "GBP"
icon: mdi:cash
state: "{{ (
states('sensor.smart_meter_electricity_import_today') | float
* states('sensor.smart_meter_electricity_import_unit_rate') | float
+ states('sensor.smart_meter_electricity_import_standing_charge') | float
) | round(2) }}"
attributes:
last_reset: "{{ today_at('00:00') }}" # required for use as "total" in energy dashboard
On why total is the right “state class” (rather than total_increasing), see the related discussion here: