1 """Support for IHC lights."""
3 from __future__
import annotations
7 from ihcsdk.ihccontroller
import IHCController
14 from .const
import CONF_DIMMABLE, CONF_OFF_ID, CONF_ON_ID, DOMAIN, IHC_CONTROLLER
15 from .entity
import IHCEntity
16 from .util
import async_pulse, async_set_bool, async_set_int
22 add_entities: AddEntitiesCallback,
23 discovery_info: DiscoveryInfoType |
None =
None,
25 """Set up the IHC lights platform."""
26 if discovery_info
is None:
29 for name, device
in discovery_info.items():
30 ihc_id = device[
"ihc_id"]
31 product_cfg = device[
"product_cfg"]
32 product = device[
"product"]
34 controller_id = device[
"ctrl_id"]
35 ihc_controller: IHCController = hass.data[DOMAIN][controller_id][IHC_CONTROLLER]
36 ihc_off_id = product_cfg.get(CONF_OFF_ID)
37 ihc_on_id = product_cfg.get(CONF_ON_ID)
38 dimmable = product_cfg[CONF_DIMMABLE]
54 """Representation of a IHC light.
56 For dimmable lights, the associated IHC resource should be a light
57 level (integer). For non dimmable light the IHC resource should be
58 an on/off (boolean) resource
63 ihc_controller: IHCController,
72 """Initialize the light."""
73 super().
__init__(ihc_controller, controller_id, name, ihc_id, product)
88 """Return the brightness of this light between 0..255."""
93 """Return true if light is on."""
97 """Turn the light on."""
98 if ATTR_BRIGHTNESS
in kwargs:
99 brightness = kwargs[ATTR_BRIGHTNESS]
100 elif (brightness := self.
_brightness_brightness) == 0:
113 """Turn the light off."""
122 """Handle IHC notifications."""
123 if isinstance(value, bool):
125 self.
_state_state = value != 0
128 self.
_state_state = value > 0
def on_ihc_change(self, ihc_id, value)
None async_turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None __init__(self, IHCController ihc_controller, str controller_id, str name, int ihc_id, int ihc_off_id, int ihc_on_id, dimmable=False, product=None)
_attr_supported_color_modes
None schedule_update_ha_state(self, bool force_refresh=False)
None add_entities(AsusWrtRouter router, AddEntitiesCallback async_add_entities, set[str] tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)
None async_pulse(HomeAssistant hass, IHCController ihc_controller, int ihc_id)
asyncio.Future[bool] async_set_int(HomeAssistant hass, IHCController ihc_controller, int ihc_id, int value)
asyncio.Future[bool] async_set_bool(HomeAssistant hass, IHCController ihc_controller, int ihc_id, bool value)