renamed add_devices to async_add_devices according to hass naming scheme (second try after failed #9485) (#9505)
This commit is contained in:
parent
3dbf951086
commit
a5155a2609
11 changed files with 54 additions and 56 deletions
|
@ -28,7 +28,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 sensor(s) for KNX platform."""
|
||||
if DATA_KNX not in hass.data \
|
||||
|
@ -36,25 +36,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 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(KNXSensor(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 sensor for KNX platform configured within plattform."""
|
||||
import xknx
|
||||
sensor = xknx.devices.Sensor(
|
||||
|
@ -63,7 +63,7 @@ def async_add_devices_config(hass, config, add_devices):
|
|||
group_address=config.get(CONF_ADDRESS),
|
||||
value_type=config.get(CONF_TYPE))
|
||||
hass.data[DATA_KNX].xknx.devices.add(sensor)
|
||||
add_devices([KNXSensor(hass, sensor)])
|
||||
async_add_devices([KNXSensor(hass, sensor)])
|
||||
|
||||
|
||||
class KNXSensor(Entity):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue