Energy Costs not calculated

Hi All,

The last few days my energy costs does not get calculated randomly.
This is for power and energy.
If I remove and re-add the tariff entity it works for another day.
Using the zonneplan tariff entities.

Any idea how to resolve this issue ?

Thanks,

Edwin

some logging as the problem still exists.

Logger: homeassistant.helpers.event
Source: helpers/event.py:293
First occurred: 3:31:03 AM (1644 occurrences)
Last logged: 8:16:46 AM

Error while dispatching event for sensor.toon_gas_used_cnt to <Job track state_changed event ['sensor.toon_gas_used_cnt'] HassJobType.Callback <function EnergyCostSensor.async_added_to_hass.<locals>.async_state_changed_listener at 0x7fb827a420c0>>
Error while dispatching event for sensor.toon_p1_power_prod_cnt_low to <Job track state_changed event ['sensor.toon_p1_power_prod_cnt_low'] HassJobType.Callback <function EnergyCostSensor.async_added_to_hass.<locals>.async_state_changed_listener at 0x7fb827a41f80>>
Error while dispatching event for sensor.toon_p1_power_prod_cnt_high to <Job track state_changed event ['sensor.toon_p1_power_prod_cnt_high'] HassJobType.Callback <function EnergyCostSensor.async_added_to_hass.<locals>.async_state_changed_listener at 0x7fb827a41e40>>
Error while dispatching event for sensor.toon_p1_power_use_cnt_low to <Job track state_changed event ['sensor.toon_p1_power_use_cnt_low'] HassJobType.Callback <function EnergyCostSensor.async_added_to_hass.<locals>.async_state_changed_listener at 0x7fb827a41d00>>
Error while dispatching event for sensor.toon_p1_power_use_cnt_high to <Job track state_changed event ['sensor.toon_p1_power_use_cnt_high'] HassJobType.Callback <function EnergyCostSensor.async_added_to_hass.<locals>.async_state_changed_listener at 0x7fb827a418a0>>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 293, in _async_dispatch_entity_id_event
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 659, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/energy/sensor.py", line 421, in async_state_changed_listener
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 743, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in _async_generate_attributes
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 749, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 634, in state
    raise ValueError(
ValueError: Sensor sensor.toon_gas_used_cnt_cost has device class 'monetary', state class 'total' unit 'EUR' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-finite value: 'nan'

Hi, I have the same issue with my electricity fixed supply charge sensors. I got the same issue as you did at the end of last month. Since then the sensor is not producing stable results and I get the error you get in my log. Did you find a way to resolve the issue?

my template sensor is:

- name: "Electricty Supply Charge"
  unit_of_measurement: "Wh"
  device_class: energy
  state_class: total_increasing
  state: >-
    {{ int(as_timestamp(now()) | timestamp_custom("%d")) + 1 - int(as_timestamp("2023-11-15") | timestamp_custom("%d")) }}

Hi, nope issue is still there.
I could switch to the data measurements from my energy provider but that’s not local but cloud. Also my energy dashboard would be messed up when switching sensors.
I’m not using any template just a hacs component to read my TOON (quby) smart thermostat with energy measurement abilities.