Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sensor): don't set last_reset for total_increasing sensor #20

Merged
merged 2 commits into from
Jul 20, 2024

Conversation

folke
Copy link
Contributor

@folke folke commented May 12, 2024

Sensors in Home Assistant with device class total_increasing should not set last_reset.

2024-05-12 09:08:49.037 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1037, in _update_entity_states
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1069, in __async_calculate_state
    if state_attributes := self.state_attributes:
                           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 446, in state_attributes
    raise ValueError(
ValueError: Entity sensor.heat_pump_house_partial_active_energy_delivered (<class 'custom_components.powertag_gateway.sensor.PowerTagPartialActiveEnergyDelivered'>) 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.

@folke
Copy link
Contributor Author

folke commented Jul 19, 2024

Any chance this can get merged?

@Breina
Copy link
Owner

Breina commented Jul 20, 2024

Sorry for leaving you hanging! This escaped my focus. :(

I'll merge, hold up

@Breina Breina merged commit 684c252 into Breina:master Jul 20, 2024
2 checks passed
@Breina
Copy link
Owner

Breina commented Jul 20, 2024

I'll release in a little bit, still a small thing I need to do for #15

@Breina
Copy link
Owner

Breina commented Jul 20, 2024

Also, thanks a lot for the fix! :)

@folke
Copy link
Contributor Author

folke commented Jul 20, 2024

ty!

@Breina
Copy link
Owner

Breina commented Jul 27, 2024

Release: https://github.com/Breina/PowerTagGateway/releases/tag/v0.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants