Bootstrap / Component setup async (#6264)

* Bootstrap / Entiy setup async

* Cleanup add_job stuff / return task/future object

* Address paulus comments / part 1

* fix install pip

* Cleanup bootstrap / move config stuff to config.py

* Make demo async

* Further bootstrap improvement

* Address Martin's comments

* Fix initial tests

* Fix final tests

* Fix bug with prepare loader

* Remove no longer needed things

* Log error when invalid config

* More cleanup

* Cleanups platform events & fix lint

* Use a non blocking add_entities callback for platform

* Fix Autoamtion is setup befor entity is ready

* Better automation fix

* Address paulus comments

* Typo

* fix lint

* rename functions

* fix tests

* fix test

* change exceptions

* fix spell
This commit is contained in:
Pascal Vizeli authored and Paulus Schoutsen committed 2017-02-28 20:33:19 -08:00
1 parent 383b0914b3
commit 41f558b181
109 files changed
+764 -848

No files matched your search

@@ -61,7 +61,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, remove_logger)
yield from async_add_devices([entity])
async_add_devices([entity])
class APICount(Entity):
+1 -1
View File
@@ -49,7 +49,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
else:
resolver = config.get(CONF_RESOLVER)
yield from async_add_devices([WanIpSensor(
async_add_devices([WanIpSensor(
hass, hostname, resolver, ipv6)], True)
+1 -1
View File
@@ -103,7 +103,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
DerivativeDSMREntity('Hourly Gas Consumption', gas_obis),
]
yield from async_add_devices(devices)
async_add_devices(devices)
def update_entities_telegram(telegram):
"""Update entities with latests telegram & trigger state update."""
@@ -34,7 +34,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
hass.data[DATA_EVL])
devices.append(device)
yield from async_add_devices(devices)
async_add_devices(devices)
class EnvisalinkSensor(EnvisalinkDevice, Entity):
+1 -1
View File
@@ -61,7 +61,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
sensor_type = config.get(CONF_TYPE)
round_digits = config.get(CONF_ROUND_DIGITS)
yield from async_add_devices(
async_add_devices(
[MinMaxSensor(hass, entity_ids, name, sensor_type, round_digits)],
True)
return True
+1 -1
View File
@@ -33,7 +33,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the Moon sensor."""
name = config.get(CONF_NAME)
yield from async_add_devices([MoonSensor(name)], True)
async_add_devices([MoonSensor(name)], True)
return True
+1 -1
View File
@@ -38,7 +38,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
if value_template is not None:
value_template.hass = hass
yield from async_add_devices([MqttSensor(
async_add_devices([MqttSensor(
config.get(CONF_NAME),
config.get(CONF_STATE_TOPIC),
config.get(CONF_QOS),
+1 -1
View File
@@ -59,7 +59,7 @@ MQTT_PAYLOAD = vol.Schema(vol.All(json.loads, vol.Schema({
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Setup MQTT Sensor."""
yield from async_add_devices([MQTTRoomSensor(
async_add_devices([MQTTRoomSensor(
config.get(CONF_NAME),
config.get(CONF_STATE_TOPIC),
config.get(CONF_DEVICE_ID),
+1 -1
View File
@@ -36,7 +36,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
minimum = config.get(CONF_MINIMUM)
maximum = config.get(CONF_MAXIMUM)
yield from async_add_devices([RandomSensor(name, minimum, maximum)], True)
async_add_devices([RandomSensor(name, minimum, maximum)], True)
return True
+7 -2
View File
@@ -74,7 +74,7 @@ def devices_from_config(domain_config, hass=None):
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the Rflink platform."""
yield from async_add_devices(devices_from_config(config, hass))
async_add_devices(devices_from_config(config, hass))
# Add new (unconfigured) devices to user desired group
if config[CONF_NEW_DEVICES_GROUP]:
@@ -91,7 +91,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
rflinksensor = partial(RflinkSensor, device_id, hass)
device = rflinksensor(event[EVENT_KEY_SENSOR], event[EVENT_KEY_UNIT])
# Add device entity
yield from async_add_devices([device])
async_add_devices([device])
# Register entity to listen to incoming rflink events
hass.data[DATA_ENTITY_LOOKUP][
@@ -122,6 +122,11 @@ class RflinkSensor(RflinkDevice):
"""Domain specific event handler."""
self._state = event['value']
@property
def entity_id(self):
"""Return entity id."""
return "sensor.{}".format(self.name)
@property
def unit_of_measurement(self):
"""Return measurement unit."""
@@ -50,7 +50,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
name = config.get(CONF_NAME)
sampling_size = config.get(CONF_SAMPLING_SIZE)
yield from async_add_devices(
async_add_devices(
[StatisticsSensor(hass, entity_id, name, sampling_size)], True)
return True
+1 -1
View File
@@ -69,7 +69,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
_LOGGER.error("No sensors added")
return False
yield from async_add_devices(sensors, True)
async_add_devices(sensors, True)
return True
+1 -1
View File
@@ -46,7 +46,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
for variable in config[CONF_DISPLAY_OPTIONS]:
devices.append(TimeDateSensor(variable))
yield from async_add_devices(devices, True)
async_add_devices(devices, True)
return True
@@ -35,7 +35,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
name = config.get(CONF_NAME)
time_zone = dt_util.get_time_zone(config.get(CONF_TIME_ZONE))
yield from async_add_devices([WorldClockSensor(time_zone, name)], True)
async_add_devices([WorldClockSensor(time_zone, name)], True)
return True
+1 -1
View File
@@ -78,7 +78,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
dev = []
for sensor_type in config[CONF_MONITORED_CONDITIONS]:
dev.append(YrSensor(sensor_type))
yield from async_add_devices(dev)
async_add_devices(dev)
weather = YrData(hass, coordinates, dev)
# Update weather on the hour, spread seconds