enkama / hass-variables

Home Assistant variables component
90 stars 12 forks source link

AttributeError: 'NoneType' object has no attribute 'native_value' #33

Closed Snuffy2 closed 1 year ago

Snuffy2 commented 1 year ago

Showing on Sensor Restore in some situations.

2023-03-26 20:28:46.405 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up variable platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 717, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 806, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/variable/sensor.py", line 152, in async_added_to_hass
if state and (sensor.native_value != state.state):
AttributeError: 'NoneType' object has no attribute 'native_value'