diff --git a/homeassistant/components/unifi/sensor.py b/homeassistant/components/unifi/sensor.py index a669e4bc3b10..d2bc9f326d96 100644 --- a/homeassistant/components/unifi/sensor.py +++ b/homeassistant/components/unifi/sensor.py @@ -318,7 +318,8 @@ def async_device_wan_latency_discovery_fn( obj_id: str, ) -> bool: """Determine if an device have a latency monitor.""" - if (device := hub.api.devices[obj_id]) and device.uptime_stats: + device = hub.api.devices[obj_id] + if device.uptime_stats: return _device_wan_latency_monitor(wan, monitor_target, device) is not None return False @@ -424,10 +425,9 @@ def async_device_temperatures_discovery_fn( temperature_name: str, hub: UnifiHub, obj_id: str ) -> bool: """Determine if an device have a temperatures.""" - if (device := hub.api.devices[obj_id]) and device.temperatures: + if temperatures := hub.api.devices[obj_id].temperatures: return any( - temperature_name in temperature["name"] - for temperature in device.temperatures + temperature_name in temperature["name"] for temperature in temperatures ) return False