Use assignment expressions 17 (#57963)

Co-authored-by: Tobias Sauerwein <cgtobi@users.noreply.github.com>
This commit is contained in:
Marc Mueller 2021-10-20 17:42:26 +02:00 committed by GitHub
parent 326a302c22
commit 9a58bfdf41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 30 additions and 56 deletions

View file

@ -305,12 +305,12 @@ class RfxtrxSensor(RfxtrxEntity, SensorEntity):
"""Restore device state."""
await super().async_added_to_hass()
if self._event is None:
old_state = await self.async_get_last_state()
if old_state is not None:
event = old_state.attributes.get(ATTR_EVENT)
if event:
self._apply_event(get_rfx_object(event))
if (
self._event is None
and (old_state := await self.async_get_last_state()) is not None
and (event := old_state.attributes.get(ATTR_EVENT))
):
self._apply_event(get_rfx_object(event))
@property
def native_value(self):