I have a custom component that creates a number entity. I am supplying the native value, but in my devcontainer I get the error saying that is doesn’t have _attr_value. It only is a problem in my dev environment, seems to work just find on my main HA instance. Any idea why the native_value isn’t working properly? I have class initialized like this:
def __init__(self, coordinator, chlorinator, setpoint, command):
"""Initialize the sensor."""
super().__init__(coordinator)
self._chlorinator = chlorinator
self._type = setpoint
self._command = command
self._value = chlorinator[setpoint]
self._available = True
And my native value defined as so:
@property
def native_value(self):
"""value"""
return self._value
The error is:
2022-08-11 15:35:06 ERROR (MainThread) [homeassistant.components.number] Error adding entities for domain number with platform njspc_ha
Traceback (most recent call last):
File "/workspaces/core/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
await asyncio.gather(*tasks)
File "/workspaces/core/homeassistant/helpers/entity_platform.py", line 619, in _async_add_entity
await entity.add_to_platform_finish()
File "/workspaces/core/homeassistant/helpers/entity.py", line 810, in add_to_platform_finish
self.async_write_ha_state()
File "/workspaces/core/homeassistant/helpers/entity.py", line 533, in async_write_ha_state
self._async_write_ha_state()
File "/workspaces/core/homeassistant/helpers/entity.py", line 571, in _async_write_ha_state
state = self._stringify_state(available)
File "/workspaces/core/homeassistant/helpers/entity.py", line 539, in _stringify_state
if (state := self.state) is None:
File "/workspaces/core/homeassistant/components/number/__init__.py", line 170, in state
return self.value
File "/workspaces/core/homeassistant/components/number/__init__.py", line 175, in value
return self._attr_value
AttributeError: 'SWGNumber' object has no attribute '_attr_value'
2022-08-11 15:35:06 ERROR (MainThread) [homeassistant.components.number] Error while setting up njspc_ha platform for number
Traceback (most recent call last):
File "/workspaces/core/homeassistant/helpers/entity_platform.py", line 257, in _async_setup_platform
await asyncio.gather(*pending)
File "/workspaces/core/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
await asyncio.gather(*tasks)
File "/workspaces/core/homeassistant/helpers/entity_platform.py", line 619, in _async_add_entity
await entity.add_to_platform_finish()
File "/workspaces/core/homeassistant/helpers/entity.py", line 810, in add_to_platform_finish
self.async_write_ha_state()
File "/workspaces/core/homeassistant/helpers/entity.py", line 533, in async_write_ha_state
self._async_write_ha_state()
File "/workspaces/core/homeassistant/helpers/entity.py", line 571, in _async_write_ha_state
state = self._stringify_state(available)
File "/workspaces/core/homeassistant/helpers/entity.py", line 539, in _stringify_state
if (state := self.state) is None:
File "/workspaces/core/homeassistant/components/number/__init__.py", line 170, in state
return self.value
File "/workspaces/core/homeassistant/components/number/__init__.py", line 175, in value
return self._attr_value
AttributeError: 'SWGNumber' object has no attribute '_attr_value'