1 """Implementation of a base class for all IHC devices."""
5 from ihcsdk.ihccontroller
import IHCController
9 from .const
import CONF_INFO, DOMAIN
11 _LOGGER = logging.getLogger(__name__)
15 """Base class for all IHC devices.
17 All IHC devices have an associated IHC resource. IHCEntity handled the
18 registration of the IHC controller callback when the IHC resource changes.
19 Derived classes must implement the on_ihc_change method
22 _attr_should_poll =
False
26 ihc_controller: IHCController,
32 """Initialize IHC attributes."""
45 product_id = product[
"id"]
46 self.
device_iddevice_id = f
"{controller_id}_{product_id }"
50 self.
device_namedevice_name += f
" ({self.ihc_position})"
58 """Add callback for IHC changes."""
59 _LOGGER.debug(
"Adding IHC entity notify event: %s", self.
ihc_idihc_id)
64 """Return the device name."""
65 return self.
_name_name
69 """Return a unique ID."""
70 return f
"{self.controller_id}-{self.ihc_id}"
74 """Return the state attributes."""
78 "ihc_id": self.
ihc_idihc_id,
83 if len(self.
hasshass.data[DOMAIN]) > 1:
85 attributes[
"ihc_controller"] = self.
controller_idcontroller_id
89 """Handle IHC resource change.
91 Derived classes must overwrite this to do device specific stuff.
93 raise NotImplementedError
None __init__(self, IHCController ihc_controller, str controller_id, str name, int ihc_id, product=None)
def on_ihc_change(self, ihc_id, value)
def extra_state_attributes(self)
def async_added_to_hass(self)