mirror of
https://github.com/home-assistant/core.git
synced 2026-12-06 13:45:55 -04:00
Remove redundant device checks in UniFi Network sensors (#191807)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user