mirror of
https://github.com/home-assistant/core.git
synced 2026-07-08 23:34:22 +01:00
b9575ee881
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: balloob <1444314+balloob@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
20 lines
580 B
Python
20 lines
580 B
Python
"""House utility functions."""
|
|
|
|
from igloohome_api import DEVICE_TYPE_BRIDGE, GetDeviceInfoResponse
|
|
|
|
|
|
def get_linked_bridge(
|
|
device_id: str, devices: list[GetDeviceInfoResponse]
|
|
) -> str | None:
|
|
"""Return the ID of the bridge linked to the device.
|
|
|
|
Returns None if no bridge is linked.
|
|
"""
|
|
bridges = (bridge for bridge in devices if bridge.type == DEVICE_TYPE_BRIDGE)
|
|
for bridge in bridges:
|
|
if device_id in (
|
|
linked_device.deviceId for linked_device in bridge.linkedDevices
|
|
):
|
|
return bridge.deviceId
|
|
return None
|