Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made _resolve_device_id more robust when following via_devices #166

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions custom_components/e3dc_rscp/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,20 @@ def _resolve_device_id(hass: HomeAssistant, devid: str) -> E3DCCoordinator:
f"{SERVICE_SET_POWER_LIMITS}: Unkown device ID {devid}."
)

identifier: tuple(str, str)
uid: str | None = None

# Follow the via device and make it the new device if it is an E3DC
if dev.via_device_id is not None:
dev = dev_reg.async_get(dev.via_device_id)
if dev is None:
via_dev = dev_reg.async_get(dev.via_device_id)
if via_dev is None:
raise HomeAssistantError(
f"{SERVICE_SET_POWER_LIMITS}: Unkown device ID {devid}."
f"{SERVICE_SET_POWER_LIMITS}: Invalid via Device ID {devid}."
)

identifier: tuple(str, str) # = next(iter(dev.identifiers))
uid: str | None = None
for identifier in via_dev.identifiers:
domain: str = identifier[0]
if domain == DOMAIN:
dev = via_dev

for identifier in dev.identifiers:
domain: str = identifier[0]
Expand Down
Loading