def _create_notify(knx_module: XKNX, config: ConfigType) -> XknxNotification: """Return a KNX notification to be used within XKNX.""" return XknxNotification( knx_module, name=config[CONF_NAME], group_address=config[CONF_ADDRESS], )
def async_get_service_config(hass, config): """Set up notification for KNX platform configured within platform.""" notification = XknxNotification( hass.data[DATA_XKNX].xknx, name=config[CONF_NAME], group_address=config[CONF_ADDRESS], ) hass.data[DATA_XKNX].xknx.devices.add(notification) return KNXNotificationService([notification])
async def async_get_service( hass: HomeAssistant, config: ConfigType, discovery_info: DiscoveryInfoType | None = None, ) -> KNXNotificationService | None: """Get the KNX notification service.""" if not discovery_info or not discovery_info["platform_config"]: return None platform_config = discovery_info["platform_config"] xknx: XKNX = hass.data[DOMAIN].xknx notification_devices = [] for device_config in platform_config: notification_devices.append( XknxNotification( xknx, name=device_config[CONF_NAME], group_address=device_config[KNX_ADDRESS], )) return (KNXNotificationService(notification_devices) if notification_devices else None)
async def async_get_service( hass: HomeAssistant, config: ConfigType, discovery_info: DiscoveryInfoType | None = None, ) -> KNXNotificationService | None: """Get the KNX notification service.""" if discovery_info is None: return None if platform_config := hass.data[DATA_KNX_CONFIG].get( NotifySchema.PLATFORM): xknx: XKNX = hass.data[DOMAIN].xknx notification_devices = [] for device_config in platform_config: notification_devices.append( XknxNotification( xknx, name=device_config[CONF_NAME], group_address=device_config[KNX_ADDRESS], )) return (KNXNotificationService(notification_devices) if notification_devices else None)