Skip to content

total_increasing sensor with last_reset crashes entity creation (electricity_co2_emissions_daily) #4

Description

@baub26

The electricity_co2_emissions_daily sensor is created with state_class: total_increasing but also sets last_reset, which Home Assistant explicitly forbids for any state_class other than total. This raises a ValueError during entity creation, which appears to prevent subsequent sensors (cost, HP/HC breakdown) from being added in the same batch.

Traceback
Error adding entity sensor.hellowatt_PDL_electricity_co2_emissions_daily for domain sensor with platform hellowatt

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 725, in _async_add_entities
await self._async_add_entity(
entity, False, entity_registry, config_subentry_id
)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1104, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1446, in add_to_platform_finish
self.async_write_ha_state()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in async_write_ha_state
self._async_write_ha_state()
~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1213, in _async_write_ha_state
) = self.__async_calculate_state()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1121, in __async_calculate_state
if state_attributes := self.state_attributes:
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 473, in state_attributes
raise ValueError(
...<7 lines>...
)
ValueError: Entity sensor.hellowatt_PDL_electricity_co2_emissions_daily (<class 'custom_components.hellowatt.sensor.HelloWattSensor'>) with state_class total_increasing has set last_reset. Setting last_reset for entities with state_class other than 'total' is not supported. Please update your configuration if state_class is manually configured.

Impact observed

After setup, only these sensors were successfully created for my PDL:

electricity_daily
electricity_day_before
electricity_weekly
temperature
contract_provider / contract_offer (diagnostic)

None of the cost sensors (electricity_cost_daily, electricity_cost_consumption_daily, electricity_cost_subscription_daily) or the HP/HC breakdown sensors (electricity_peak_hours_daily, electricity_off_peak_hours_daily) were created, even though:

My contract is a dual-rate (HP/HC) contract with both prices configured on HelloWatt (0.176 €/kWh HP, 0.1361 €/kWh HC, 19.84 €/month subscription)
These fields are correctly displayed on the HelloWatt website/app for this PDL

I suspect the CO2 sensor crash interrupts the rest of the sensor batch creation for this PDL, since the sensors listed after electricity_co2_emissions_daily in the README's table (cost + HP/HC) are exactly the ones missing.

Suggested fix

In sensor.py, for electricity_co2_emissions_daily (and the gas equivalent gas_co2_emissions_daily if it has the same pattern): either change state_class to total to match the last_reset usage, or remove the last_reset assignment if total_increasing is intentional.

Environment
Home Assistant Core (latest, as of August 2026)
hellowatt_hass v1.0.0 (manual install, not via HACS)
Dual-rate (HP/HC) electricity contract, no gas contract

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions