Skip to content

Commit 1e463a7

Browse files
authored
Fix Home Assistant 2025.10 compatibility (#1064)
1 parent 6fe54e2 commit 1e463a7

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

custom_components/spook/services.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
from pathlib import Path
99
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast, final
1010

11+
from awesomeversion import AwesomeVersion
1112
import voluptuous as vol
1213

14+
from homeassistant.const import __short_version__ as current_version
1315
from homeassistant.core import (
1416
HomeAssistant,
1517
Service,
@@ -261,14 +263,26 @@ async def async_setup(self) -> None:
261263

262264
# Load service schemas
263265
integration = await async_get_integration(self.hass, DOMAIN)
264-
self._service_schemas = cast(
265-
dict[str, Any],
266-
await self.hass.async_add_executor_job(
267-
_load_services_file,
268-
self.hass,
269-
integration,
270-
),
271-
)
266+
# Ensure compatibility with Home Assistant version
267+
# As of Home Assistant 2025.10, the _load_services_file function no
268+
# longer has the hass parameter.
269+
if AwesomeVersion(current_version) >= AwesomeVersion("2025.10"):
270+
self._service_schemas = cast(
271+
dict[str, Any],
272+
await self.hass.async_add_executor_job(
273+
_load_services_file,
274+
integration,
275+
),
276+
)
277+
else:
278+
self._service_schemas = cast(
279+
dict[str, Any],
280+
await self.hass.async_add_executor_job(
281+
_load_services_file,
282+
self.hass,
283+
integration,
284+
),
285+
)
272286

273287
modules: list[ModuleType] = []
274288

0 commit comments

Comments
 (0)