From 8c99abf822e5f0801bbd44478d4276010d709671 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 10 Nov 2026 11:16:10 +0100 Subject: [PATCH] Remove redundant device checks in UniFi Network sensors (#191807) --- homeassistant/components/unifi/sensor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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