Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 22 additions & 3 deletions custom_components/hilo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
CONF_USERNAME,
EVENT_HOMEASSISTANT_STOP,
Platform,
__short_version__ as current_version,
)
from homeassistant.core import Context, HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
Expand All @@ -34,6 +35,7 @@
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from packaging.version import Version
from pyhilo import API
from pyhilo.device import HiloDevice
from pyhilo.devices import Devices
Expand Down Expand Up @@ -157,11 +159,22 @@ def _async_migrate_gateway_device_identifier(
return

device_registry = dr.async_get(hass)
old_device = device_registry.async_get_device(identifiers={(DOMAIN, old_dsn)})
if Version(current_version) >= Version("2026.8"):
old_device = device_registry.async_get_device_by_identifier(
(DOMAIN, old_dsn, entry.entry_id)
)
else:
old_device = device_registry.async_get_device(identifiers={(DOMAIN, old_dsn)})

if old_device is None:
return # fresh install, or already migrated

new_device = device_registry.async_get_device(identifiers={(DOMAIN, new_mac)})
if Version(current_version) >= Version("2026.8"):
new_device = device_registry.async_get_device_by_identifier(
(DOMAIN, new_mac), entry.entry_id
)
else:
new_device = device_registry.async_get_device(identifiers={(DOMAIN, new_mac)})
if new_device is not None and new_device.id != old_device.id:
LOG.warning(
"Gateway device already registered under new identifier %s, skipping device migration",
Expand Down Expand Up @@ -781,7 +794,13 @@ async def _fetch_legacy_gateway_dsn(self, new_mac: str) -> str | None:
returns its old DSN-based identifier if it exists. If it doesn't,
it returns Noneto use the MAC address instead."""
device_registry = dr.async_get(self._hass)
for device in device_registry.devices:
devices = device_registry.devices
device_iter = (
devices
if Version(current_version) >= Version("2026.9")
else devices.values()
)
for device in device_iter:
if device.manufacturer != "Hilo" or device.model != "EQ000017":
continue
for domain, identifier in device.identifiers:
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Hilo",
"render_readme": true,
"homeassistant": "2024.7.0"
"homeassistant": "2025.8.0"
}