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

Fix "referencing a non existing via_device" when gateway_external_id is None #573

Merged
merged 2 commits into from
Feb 10, 2025
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
19 changes: 10 additions & 9 deletions custom_components/hilo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,17 +779,18 @@ def __init__(
"""Initialize."""
assert hilo.coordinator
super().__init__(hilo.coordinator)
device_info_args = {
"identifiers": {(DOMAIN, device.identifier)},
"manufacturer": device.manufacturer,
"model": device.model,
"name": device.name,
}
try:
gateway = device.gateway_external_id
device_info_args["via_device"] = (DOMAIN, device.gateway_external_id)
except AttributeError:
gateway = None
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device.identifier)},
manufacturer=device.manufacturer,
model=device.model,
name=device.name,
via_device=(DOMAIN, gateway),
)
# If a device doesn't have a gateway_external_id, it's most likely the gateway itself.
pass # Do nothing.
self._attr_device_info = DeviceInfo(**device_info_args)
try:
mac_address = dr.format_mac(device.sdi)
self._attr_device_info[ATTR_CONNECTIONS] = {
Expand Down