deepseek
This commit is contained in:
parent
aa2f511e2f
commit
9203a0562a
@ -1,49 +0,0 @@
|
||||
from datetime import timedelta
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from zigpy import types
|
||||
import logging
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class LinkyTarifCoordinator(DataUpdateCoordinator):
|
||||
def __init__(self, hass: HomeAssistant, ieee: str, interval: int):
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
name="Linky Tarif Coordinator",
|
||||
update_interval=timedelta(seconds=interval),
|
||||
)
|
||||
self._ieee = ieee
|
||||
|
||||
async def _async_update_data(self):
|
||||
try:
|
||||
zha_gateway = self.hass.data["zha"]
|
||||
app_ctrl = zha_gateway.application_controller
|
||||
except (AttributeError, KeyError) as e:
|
||||
raise UpdateFailed(f"ZHA Gateway not ready: {e}")
|
||||
|
||||
device = app_ctrl.get_device(types.EUI64.convert(self._ieee))
|
||||
if not device:
|
||||
raise UpdateFailed(f"Device with IEEE {self._ieee} not found")
|
||||
|
||||
endpoint = device.endpoints.get(1)
|
||||
if not endpoint:
|
||||
raise UpdateFailed("Endpoint 1 not found")
|
||||
|
||||
cluster = endpoint[0xFF66]
|
||||
if not cluster:
|
||||
raise UpdateFailed("Cluster 0xFF66 not found")
|
||||
|
||||
try:
|
||||
res = await cluster.read_attributes([0x0010])
|
||||
value = res.get(0x0010)
|
||||
return {
|
||||
"tariff": value,
|
||||
"last_update": self.hass.helpers.event.dt_util.utcnow().isoformat(),
|
||||
}
|
||||
except Exception as e:
|
||||
raise UpdateFailed(f"Error reading tariff: {e}")
|
||||
13
strings.json
13
strings.json
@ -1,13 +0,0 @@
|
||||
{
|
||||
"domain": "linky_tarif",
|
||||
"name": "Linky Tarif",
|
||||
"config_flow": {
|
||||
"title": "Linky Tarif",
|
||||
"description": "Monitors Linky energy meter tariff periods using ZHA.",
|
||||
"step": {
|
||||
"user": {
|
||||
"title": "Configure Linky Tarif"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user