diff --git a/homeassistant/components/knx.py b/homeassistant/components/knx.py index 3966b490f528f..d426e79ace9fe 100644 --- a/homeassistant/components/knx.py +++ b/homeassistant/components/knx.py @@ -27,6 +27,7 @@ CONF_KNX_FIRE_EVENT = "fire_event" CONF_KNX_FIRE_EVENT_FILTER = "fire_event_filter" CONF_KNX_STATE_UPDATER = "state_updater" +CONF_KNX_TIME_ADDRESS = "time_address" SERVICE_KNX_SEND = "send" SERVICE_KNX_ATTR_ADDRESS = "address" @@ -60,6 +61,7 @@ vol.All( cv.ensure_list, [cv.string]), + vol.Optional(CONF_KNX_TIME_ADDRESS): cv.string, vol.Optional(CONF_KNX_STATE_UPDATER, default=True): cv.boolean, }) }, extra=vol.ALLOW_EXTRA) @@ -97,6 +99,9 @@ def async_setup(hass, config): ATTR_DISCOVER_DEVICES: found_devices }, config)) + if CONF_KNX_TIME_ADDRESS in config[DOMAIN]: + _add_time_device(hass, config) + hass.services.async_register( DOMAIN, SERVICE_KNX_SEND, hass.data[DATA_KNX].service_send_to_knx_bus, @@ -105,6 +110,17 @@ def async_setup(hass, config): return True +def _add_time_device(hass, config): + """Create time broadcasting device and add it to xknx device queue.""" + import xknx + group_address_time = config[DOMAIN][CONF_KNX_TIME_ADDRESS] + time = xknx.devices.Time( + hass.data[DATA_KNX].xknx, + 'Time', + group_address=group_address_time) + hass.data[DATA_KNX].xknx.devices.add(time) + + def _get_devices(hass, discovery_type): return list( map(lambda device: device.name,