1 """Support for IHC switches."""
3 from __future__
import annotations
7 from ihcsdk.ihccontroller
import IHCController
14 from .const
import CONF_OFF_ID, CONF_ON_ID, DOMAIN, IHC_CONTROLLER
15 from .entity
import IHCEntity
16 from .util
import async_pulse, async_set_bool
22 add_entities: AddEntitiesCallback,
23 discovery_info: DiscoveryInfoType |
None =
None,
25 """Set up the IHC switch 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)
40 ihc_controller, controller_id, name, ihc_id, ihc_off_id, ihc_on_id, product
42 devices.append(switch)
47 """Representation of an IHC switch."""
51 ihc_controller: IHCController,
59 """Initialize the IHC switch."""
60 super().
__init__(ihc_controller, controller_id, name, ihc_id, product)
65 """Turn the switch on."""
72 """Turn the device off."""
79 """Handle IHC resource change."""
None __init__(self, IHCController ihc_controller, str controller_id, str name, int ihc_id, int ihc_off_id, int ihc_on_id, product=None)
None async_turn_on(self, **Any kwargs)
None async_turn_off(self, **Any kwargs)
def on_ihc_change(self, ihc_id, value)
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_bool(HomeAssistant hass, IHCController ihc_controller, int ihc_id, bool value)