Do not restore unavailable state for august locks (#44722)

This commit is contained in:
J. Nick Koston
2021-01-01 01:44:53 -10:00
committed by GitHub
parent 681f76b99d
commit 94825b3e15
4 changed files with 16 additions and 16 deletions

View File

@@ -4,7 +4,7 @@ import logging
from august.activity import ActivityType
from homeassistant.components.sensor import DEVICE_CLASS_BATTERY
from homeassistant.const import ATTR_ENTITY_PICTURE, PERCENTAGE
from homeassistant.const import ATTR_ENTITY_PICTURE, PERCENTAGE, STATE_UNAVAILABLE
from homeassistant.core import callback
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_registry import async_get_registry
@@ -157,8 +157,8 @@ class AugustOperatorSensor(AugustEntityMixin, RestoreEntity, Entity):
self._device_id, [ActivityType.LOCK_OPERATION]
)
self._available = True
if lock_activity is not None:
self._available = True
self._state = lock_activity.operated_by
self._operated_remote = lock_activity.operated_remote
self._operated_keypad = lock_activity.operated_keypad
@@ -193,7 +193,7 @@ class AugustOperatorSensor(AugustEntityMixin, RestoreEntity, Entity):
await super().async_added_to_hass()
last_state = await self.async_get_last_state()
if not last_state:
if not last_state or last_state.state == STATE_UNAVAILABLE:
return
self._state = last_state.state