Use assignment expressions 10 (#57791)
This commit is contained in:
parent
9be3278ffa
commit
12d1dfdaf9
10 changed files with 44 additions and 87 deletions
|
@ -53,8 +53,7 @@ async def _get_entity_and_device(
|
|||
hass.helpers.entity_registry.async_get_registry(),
|
||||
)
|
||||
|
||||
entity_entry = ent_reg.async_get(entity_id)
|
||||
if not entity_entry:
|
||||
if not (entity_entry := ent_reg.async_get(entity_id)):
|
||||
return None, None
|
||||
device_entry = dev_reg.devices.get(entity_entry.device_id)
|
||||
return entity_entry, device_entry
|
||||
|
@ -500,8 +499,7 @@ class GoogleEntity:
|
|||
}
|
||||
|
||||
# use aliases
|
||||
aliases = entity_config.get(CONF_ALIASES)
|
||||
if aliases:
|
||||
if aliases := entity_config.get(CONF_ALIASES):
|
||||
device["name"]["nicknames"] = [name] + aliases
|
||||
|
||||
if self.config.is_local_sdk_active and self.should_expose_local():
|
||||
|
@ -518,8 +516,7 @@ class GoogleEntity:
|
|||
for trt in traits:
|
||||
device["attributes"].update(trt.sync_attributes())
|
||||
|
||||
room = entity_config.get(CONF_ROOM_HINT)
|
||||
if room:
|
||||
if room := entity_config.get(CONF_ROOM_HINT):
|
||||
device["roomHint"] = room
|
||||
else:
|
||||
area = await _get_area(self.hass, entity_entry, device_entry)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue