renamed add_devices to async_add_devices according to hass naming scheme (#9485)

* renamed add_devices to async_add_devices according to hass naming scheme

* replaced some occurencies of async_add_entites to async_add_devices

* fixed unit test

* fixed unit test
This commit is contained in:
Julius Mittenzwei authored and Pascal Vizeli committed 2017-09-19 17:06:52 +02:00
1 parent 185ada2354
commit a5a970709f
12 files changed
+55 -57

No files matched your search

@@ -53,7 +53,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@asyncio.coroutine
def async_setup_platform(hass, config, add_devices,
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 \
@@ -61,25 +61,25 @@ def async_setup_platform(hass, config, add_devices,
return False
if discovery_info is not None:
async_add_devices_discovery(hass, discovery_info, add_devices)
async_add_devices_discovery(hass, discovery_info, async_add_devices)
else:
async_add_devices_config(hass, config, add_devices)
async_add_devices_config(hass, config, async_add_devices)
return True
@callback
def async_add_devices_discovery(hass, discovery_info, add_devices):
def async_add_devices_discovery(hass, discovery_info, async_add_devices):
"""Set up binary sensors 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(KNXBinarySensor(hass, device))
add_devices(entities)
async_add_devices(entities)
@callback
def async_add_devices_config(hass, config, add_devices):
def async_add_devices_config(hass, config, async_add_devices):
"""Set up binary senor for KNX platform configured within plattform."""
name = config.get(CONF_NAME)
import xknx
@@ -101,7 +101,7 @@ def async_add_devices_config(hass, config, add_devices):
entity.automations.append(KNXAutomation(
hass=hass, device=binary_sensor, hook=hook,
action=action, counter=counter))
add_devices([entity])
async_add_devices([entity])
class KNXBinarySensor(BinarySensorDevice):
@@ -41,14 +41,14 @@ def _create_sensor(hass, zone):
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_entities,
def async_setup_platform(hass, config, async_add_devices,
discovery_info=None):
"""Initialize the platform."""
if (discovery_info is None or
discovery_info[ATTR_DISCOVER_DEVICES] is None):
return
async_add_entities(
async_add_devices(
_create_sensor(hass, zone)
for zone in discovery_info[ATTR_DISCOVER_DEVICES]
if _get_device_class(zone['type']))