1 """Base class for SUPLA channels."""
3 from __future__
import annotations
9 _LOGGER = logging.getLogger(__name__)
13 """Base class of a SUPLA Channel (an equivalent of HA's Entity)."""
15 def __init__(self, config, server, coordinator):
16 """Init from config, hookup[ server and coordinator."""
24 """Return channel data taken from coordinator."""
25 return self.coordinator.data.get(self.
channel_idchannel_id)
29 """Return a unique ID."""
30 uid = self.
channel_datachannel_data[
"iodevice"][
"gUIDString"].lower()
31 channel_number = self.
channel_datachannel_data[
"channelNumber"]
32 return f
"supla-{uid}-{channel_number}"
35 def name(self) -> str | None:
36 """Return the name of the device."""
41 """Return True if entity is available."""
46 return state.get(
"connected")
51 Actions are currently hardcoded in components.
52 SUPLA's API enables autodiscovery
55 "Executing action %s on channel %d, params: %s",
60 await self.
serverserver.execute_action(self.
channel_datachannel_data[
"id"], action, **add_pars)
63 await self.coordinator.async_request_refresh()
def async_action(self, action, **add_pars)
def __init__(self, config, server, coordinator)
web.Response get(self, web.Request request, str config_key)