fix api
This commit is contained in:
parent
2e259892bf
commit
8ef7d61ac7
@ -19,15 +19,15 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
async def async_get_zha_devices(hass):
|
async def async_get_zha_devices(hass):
|
||||||
"""Get ZHA devices."""
|
"""Get ZHA devices."""
|
||||||
if "zha" not in hass.data:
|
if not hasattr(hass.data.get("zha"), "core"):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
zha_gateway = hass.data["zha"].get("zha_gateway")
|
zha_gateway = hass.data["zha"].core.gateway
|
||||||
if not zha_gateway:
|
if not zha_gateway:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(str(device.ieee), f"{device.name} ({device.ieee})")
|
(str(device.ieee), f"{device.name} ({device.ieee})"
|
||||||
for device in zha_gateway.devices.values()
|
for device in zha_gateway.devices.values()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
5
init.py
5
init.py
@ -7,7 +7,6 @@ from typing import Any
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_IEEE
|
from homeassistant.const import CONF_IEEE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr
|
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -68,10 +67,10 @@ class LinkyTariffCoordinator(DataUpdateCoordinator):
|
|||||||
async def _async_update_data(self) -> dict[str, Any]:
|
async def _async_update_data(self) -> dict[str, Any]:
|
||||||
"""Fetch data from ZHA device."""
|
"""Fetch data from ZHA device."""
|
||||||
try:
|
try:
|
||||||
if "zha" not in self.hass.data:
|
if not hasattr(self.hass.data.get("zha"), "core"):
|
||||||
raise ValueError("ZHA integration not loaded")
|
raise ValueError("ZHA integration not loaded")
|
||||||
|
|
||||||
zha_gateway = self.hass.data["zha"].get("zha_gateway")
|
zha_gateway = self.hass.data["zha"].core.gateway
|
||||||
if not zha_gateway:
|
if not zha_gateway:
|
||||||
raise ValueError("ZHA gateway not available")
|
raise ValueError("ZHA gateway not available")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user