This reverts commit a5a970709f.
This commit is contained in:
1 parent
a5a970709f
commit
1bbaa00976
12 files changed
+57
-55
No files matched your search
@@ -129,7 +129,7 @@ def async_citybikes_request(hass, uri, schema):
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices,
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the CityBikes platform."""
|
||||
if DOMAIN not in hass.data:
|
||||
@@ -159,7 +159,7 @@ def async_setup_platform(hass, config, async_add_devices,
|
||||
|
||||
yield from network.ready.wait()
|
||||
|
||||
devices = []
|
||||
entities = []
|
||||
for station in network.stations:
|
||||
dist = location.distance(latitude, longitude,
|
||||
station[ATTR_LATITUDE],
|
||||
@@ -169,9 +169,9 @@ def async_setup_platform(hass, config, async_add_devices,
|
||||
|
||||
if radius > dist or stations_list.intersection((station_id,
|
||||
station_uid)):
|
||||
devices.append(CityBikesStation(network, station_id, name))
|
||||
entities.append(CityBikesStation(network, station_id, name))
|
||||
|
||||
async_add_devices(devices, True)
|
||||
async_add_entities(entities, True)
|
||||
|
||||
|
||||
class CityBikesNetwork:
|
||||
|
||||
@@ -28,7 +28,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 sensor(s) for KNX platform."""
|
||||
if DATA_KNX not in hass.data \
|
||||
@@ -36,25 +36,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 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))
|
||||
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 sensor for KNX platform configured within plattform."""
|
||||
import xknx
|
||||
sensor = xknx.devices.Sensor(
|
||||
@@ -63,7 +63,7 @@ def async_add_devices_config(hass, config, async_add_devices):
|
||||
group_address=config.get(CONF_ADDRESS),
|
||||
value_type=config.get(CONF_TYPE))
|
||||
hass.data[DATA_KNX].xknx.devices.add(sensor)
|
||||
async_add_devices([KNXSensor(hass, sensor)])
|
||||
add_devices([KNXSensor(hass, sensor)])
|
||||
|
||||
|
||||
class KNXSensor(Entity):
|
||||
|
||||
@@ -51,11 +51,11 @@ ERROR_STATE = [
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_setup_platform(hass, config, async_add_devices,
|
||||
def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
"""Set up the Worx Landroid sensors."""
|
||||
for typ in ('battery', 'state'):
|
||||
async_add_devices([WorxLandroidSensor(typ, config)])
|
||||
async_add_entities([WorxLandroidSensor(typ, config)])
|
||||
|
||||
|
||||
class WorxLandroidSensor(Entity):
|
||||
@@ -86,7 +86,8 @@ class WorxLandroidSensor(Entity):
|
||||
"""Return the unit of measurement of the sensor."""
|
||||
if self.sensor == 'battery':
|
||||
return '%'
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_update(self):
|
||||
@@ -158,6 +159,7 @@ class WorxLandroidSensor(Entity):
|
||||
return 'charging-complete'
|
||||
elif state_obj[15] == 1:
|
||||
return 'going-home'
|
||||
return 'mowing'
|
||||
else:
|
||||
return 'mowing'
|
||||
|
||||
return state
|
||||
Reference in new issue
Block a user