def _create_switch(knx_module: XKNX, config: ConfigType) -> XknxSwitch: """Return a KNX switch to be used within XKNX.""" return XknxSwitch( knx_module, name=config[CONF_NAME], group_address=config[CONF_ADDRESS], group_address_state=config.get(SwitchSchema.CONF_STATE_ADDRESS), invert=config.get(SwitchSchema.CONF_INVERT), )
def async_add_entities_config(hass, config, async_add_entities): """Set up switch for KNX platform configured within platform.""" switch = XknxSwitch( hass.data[DATA_KNX].xknx, name=config[CONF_NAME], group_address=config[CONF_ADDRESS], group_address_state=config.get(CONF_STATE_ADDRESS), ) hass.data[DATA_KNX].xknx.devices.add(switch) async_add_entities([KNXSwitch(switch)])
def __init__(self, xknx: XKNX, config: ConfigType) -> None: """Initialize of KNX switch.""" super().__init__(device=XknxSwitch( xknx, name=config[CONF_NAME], group_address=config[KNX_ADDRESS], group_address_state=config.get(SwitchSchema.CONF_STATE_ADDRESS), respond_to_read=config[CONF_RESPOND_TO_READ], invert=config[SwitchSchema.CONF_INVERT], )) self._attr_unique_id = str(self._device.switch.group_address)
def __init__(self, xknx: XKNX, config: ConfigType) -> None: """Initialize of KNX switch.""" self._device: XknxSwitch super().__init__(device=XknxSwitch( xknx, name=config[CONF_NAME], group_address=config[KNX_ADDRESS], group_address_state=config.get(SwitchSchema.CONF_STATE_ADDRESS), invert=config[SwitchSchema.CONF_INVERT], )) self._unique_id = f"{self._device.switch.group_address}"