This reverts commit a5a970709f.
This commit is contained in:
1 parent
a5a970709f
commit
1bbaa00976
12 files changed
+57
-55
No files matched your search
@@ -27,7 +27,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices,
|
||||
def async_setup_platform(hass, config, add_devices,
|
||||
discovery_info=None):
|
||||
"""Set up switch(es) for KNX platform."""
|
||||
if DATA_KNX not in hass.data \
|
||||
@@ -35,25 +35,25 @@ def async_setup_platform(hass, config, async_add_devices,
|
||||
return False
|
||||
|
||||
if discovery_info is not None:
|
||||
async_add_devices_discovery(hass, discovery_info, async_add_devices)
|
||||
async_add_devices_discovery(hass, discovery_info, add_devices)
|
||||
else:
|
||||
async_add_devices_config(hass, config, async_add_devices)
|
||||
async_add_devices_config(hass, config, add_devices)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@callback
|
||||
def async_add_devices_discovery(hass, discovery_info, async_add_devices):
|
||||
def async_add_devices_discovery(hass, discovery_info, add_devices):
|
||||
"""Set up switches for KNX platform configured via xknx.yaml."""
|
||||
entities = []
|
||||
for device_name in discovery_info[ATTR_DISCOVER_DEVICES]:
|
||||
device = hass.data[DATA_KNX].xknx.devices[device_name]
|
||||
entities.append(KNXSwitch(hass, device))
|
||||
async_add_devices(entities)
|
||||
add_devices(entities)
|
||||
|
||||
|
||||
@callback
|
||||
def async_add_devices_config(hass, config, async_add_devices):
|
||||
def async_add_devices_config(hass, config, add_devices):
|
||||
"""Set up switch for KNX platform configured within plattform."""
|
||||
import xknx
|
||||
switch = xknx.devices.Switch(
|
||||
@@ -62,7 +62,7 @@ def async_add_devices_config(hass, config, async_add_devices):
|
||||
group_address=config.get(CONF_ADDRESS),
|
||||
group_address_state=config.get(CONF_STATE_ADDRESS))
|
||||
hass.data[DATA_KNX].xknx.devices.add(switch)
|
||||
async_add_devices([KNXSwitch(hass, switch)])
|
||||
add_devices([KNXSwitch(hass, switch)])
|
||||
|
||||
|
||||
class KNXSwitch(SwitchDevice):
|
||||
|
||||
Reference in new issue
Block a user