Skip to content

Commit

Permalink
fix: mark sensor as added to HASS even if no existing state is found
Browse files Browse the repository at this point in the history
  • Loading branch information
argoyle committed Mar 15, 2022
1 parent 3d6fbd9 commit 1ac896f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions custom_components/ferroamp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,8 @@ async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
if not state:
return
self._attr_native_value = state.state
if state:
self._attr_native_value = state.state
self.hass.data[DOMAIN][DATA_DEVICES][self.config_id][self.device_id][self.unique_id] = self
self._added = True

Expand Down

0 comments on commit 1ac896f

Please sign in to comment.