Use assignment expressions 31 (#58715)

This commit is contained in:
Marc Mueller 2021-10-30 16:29:07 +02:00 committed by GitHub
parent f7dea3aa1d
commit a48ddcadd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 27 additions and 58 deletions

View file

@ -124,8 +124,7 @@ class IntegrationSensor(RestoreEntity, SensorEntity):
async def async_added_to_hass(self):
"""Handle entity which will be added."""
await super().async_added_to_hass()
state = await self.async_get_last_state()
if state:
if state := await self.async_get_last_state():
try:
self._state = Decimal(state.state)
except (DecimalException, ValueError) as err: