Skip to content

AttributeError: 'Bodymiscale' object has no attribute '_last_time' on every Home Assistant restart #283

@b-uwe

Description

@b-uwe

Each time I restart Home Assistant I get the following error:

This error originated from a custom integration.

Logger: custom_components.bodymiscale
Source: helpers/entity_platform.py:657
integration: BodyMiScale (documentation, issues)
First occurred: 18:34:13 (1 occurrence)
Last logged: 18:34:13

Error adding entity bodymiscale.me for domain bodymiscale with platform bodymiscale
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 657, 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 979, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1369, in add_to_platform_finish
    self.async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1018, in async_write_ha_state
    self._async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1140, in _async_write_ha_state
    self.__async_calculate_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1082, in __async_calculate_state
    if state_attributes := self.state_attributes:
                           ^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/bodymiscale/__init__.py", line 221, in state_attributes
    ATTR_LAST_MEASUREMENT_TIME: self._last_time,
                                ^^^^^^^^^^^^^^^
AttributeError: 'Bodymiscale' object has no attribute '_last_time'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions