From ae32d208d994be43e4eafdddf79b2357d2cd1754 Mon Sep 17 00:00:00 2001 From: Julius Mittenzwei Date: Thu, 15 Feb 2018 07:10:12 +0100 Subject: [PATCH] Cleanup of knx component (#12408) --- homeassistant/components/binary_sensor/knx.py | 3 --- homeassistant/components/climate/knx.py | 3 --- homeassistant/components/cover/knx.py | 3 --- homeassistant/components/knx.py | 1 - homeassistant/components/light/knx.py | 4 ---- homeassistant/components/notify/knx.py | 11 +++-------- homeassistant/components/sensor/knx.py | 3 --- homeassistant/components/switch/knx.py | 3 --- 8 files changed, 3 insertions(+), 28 deletions(-) diff --git a/homeassistant/components/binary_sensor/knx.py b/homeassistant/components/binary_sensor/knx.py index c01654a3663..82463264f88 100644 --- a/homeassistant/components/binary_sensor/knx.py +++ b/homeassistant/components/binary_sensor/knx.py @@ -56,9 +56,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up binary sensor(s) for KNX platform.""" - if DATA_KNX not in hass.data or not hass.data[DATA_KNX].initialized: - return - if discovery_info is not None: async_add_devices_discovery(hass, discovery_info, async_add_devices) else: diff --git a/homeassistant/components/climate/knx.py b/homeassistant/components/climate/knx.py index a78c277fa33..e9601f25564 100644 --- a/homeassistant/components/climate/knx.py +++ b/homeassistant/components/climate/knx.py @@ -64,9 +64,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up climate(s) for KNX platform.""" - if DATA_KNX not in hass.data or not hass.data[DATA_KNX].initialized: - return - if discovery_info is not None: async_add_devices_discovery(hass, discovery_info, async_add_devices) else: diff --git a/homeassistant/components/cover/knx.py b/homeassistant/components/cover/knx.py index a6cd1263a73..730a2b29a2e 100644 --- a/homeassistant/components/cover/knx.py +++ b/homeassistant/components/cover/knx.py @@ -53,9 +53,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up cover(s) for KNX platform.""" - if DATA_KNX not in hass.data or not hass.data[DATA_KNX].initialized: - return - if discovery_info is not None: async_add_devices_discovery(hass, discovery_info, async_add_devices) else: diff --git a/homeassistant/components/knx.py b/homeassistant/components/knx.py index 727d9a3fdbd..a90a5246759 100644 --- a/homeassistant/components/knx.py +++ b/homeassistant/components/knx.py @@ -120,7 +120,6 @@ class KNXModule(object): self.hass = hass self.config = config self.connected = False - self.initialized = True self.init_xknx() self.register_callbacks() diff --git a/homeassistant/components/light/knx.py b/homeassistant/components/light/knx.py index 7ee3d5c114f..020184b8501 100644 --- a/homeassistant/components/light/knx.py +++ b/homeassistant/components/light/knx.py @@ -40,10 +40,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up lights for KNX platform.""" - if DATA_KNX not in hass.data \ - or not hass.data[DATA_KNX].initialized: - return - if discovery_info is not None: async_add_devices_discovery(hass, discovery_info, async_add_devices) else: diff --git a/homeassistant/components/notify/knx.py b/homeassistant/components/notify/knx.py index d14d8dcf8ad..e6bb400d421 100644 --- a/homeassistant/components/notify/knx.py +++ b/homeassistant/components/notify/knx.py @@ -27,10 +27,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @asyncio.coroutine def async_get_service(hass, config, discovery_info=None): """Get the KNX notification service.""" - if DATA_KNX not in hass.data \ - or not hass.data[DATA_KNX].initialized: - return False - return async_get_service_discovery(hass, discovery_info) \ if discovery_info is not None else \ async_get_service_config(hass, config) @@ -44,7 +40,7 @@ def async_get_service_discovery(hass, discovery_info): device = hass.data[DATA_KNX].xknx.devices[device_name] notification_devices.append(device) return \ - KNXNotificationService(hass, notification_devices) \ + KNXNotificationService(notification_devices) \ if notification_devices else \ None @@ -58,15 +54,14 @@ def async_get_service_config(hass, config): name=config.get(CONF_NAME), group_address=config.get(CONF_ADDRESS)) hass.data[DATA_KNX].xknx.devices.add(notification) - return KNXNotificationService(hass, [notification, ]) + return KNXNotificationService([notification, ]) class KNXNotificationService(BaseNotificationService): """Implement demo notification service.""" - def __init__(self, hass, devices): + def __init__(self, devices): """Initialize the service.""" - self.hass = hass self.devices = devices @property diff --git a/homeassistant/components/sensor/knx.py b/homeassistant/components/sensor/knx.py index 70afa6fe1e1..bdceb729e89 100644 --- a/homeassistant/components/sensor/knx.py +++ b/homeassistant/components/sensor/knx.py @@ -31,9 +31,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up sensor(s) for KNX platform.""" - if DATA_KNX not in hass.data or not hass.data[DATA_KNX].initialized: - return - if discovery_info is not None: async_add_devices_discovery(hass, discovery_info, async_add_devices) else: diff --git a/homeassistant/components/switch/knx.py b/homeassistant/components/switch/knx.py index 01c08767ca0..86a9adf0495 100644 --- a/homeassistant/components/switch/knx.py +++ b/homeassistant/components/switch/knx.py @@ -30,9 +30,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ @asyncio.coroutine def async_setup_platform(hass, config, async_add_devices, discovery_info=None): """Set up switch(es) for KNX platform.""" - if DATA_KNX not in hass.data or not hass.data[DATA_KNX].initialized: - return - if discovery_info is not None: async_add_devices_discovery(hass, discovery_info, async_add_devices) else: