Remove redundant device checks in UniFi Network sensors (#191807)

This commit is contained in:
epenet
2026-11-10 10:16:10 +00:00
committed by GitHub
parent 29e7faceed
commit 8c99abf822
+4 -4
View File
@@ -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