mirror of
https://github.com/home-assistant/core.git
synced 2025-11-13 13:00:11 +00:00
Do not restore unavailable state for august locks (#44722)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user