Skip to content

Commit 19e99db

Browse files
authored
Merge pull request #24 from nobert/dont_restore_state
Remove faulty restore state code
2 parents b64ee70 + 2a674c0 commit 19e99db

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

custom_components/sensorpush/__init__.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -194,25 +194,10 @@ def _update_callback(self):
194194

195195
async def async_added_to_hass(self) -> None:
196196
await super().async_added_to_hass()
197-
197+
198198
# register callback when cached SensorPush data has been updated
199199
async_dispatcher_connect(self.hass, SIGNAL_SENSORPUSH_UPDATED, self._update_callback)
200200

201-
# on restart, attempt to restore previous state (see https://aarongodfrey.dev/programming/restoring-an-entity-in-home-assistant/)
202-
state = await self.async_get_last_state()
203-
if not state:
204-
return
205-
self._state = state.state
206-
207-
# restore any attributes (FIXME: why not restore ALL attributes?)
208-
for attribute in [ATTR_AGE, ATTR_OBSERVED_TIME, ATTR_BATTERY_VOLTAGE, ATTR_ALERT_MIN, ATTR_ALERT_MAX]:
209-
if attribute in state.attributes:
210-
value = state.attributes.get(attribute)
211-
if value:
212-
self._attrs[attribute] = value
213-
214-
LOG.debug(f"Restored sensor {self._name} previous state {self._state}: {self._attrs}")
215-
216201
async_dispatcher_connect(
217202
self.hass, DATA_UPDATED, self._schedule_immediate_update
218203
)

0 commit comments

Comments
 (0)