mirror of
https://github.com/home-assistant/core.git
synced 2025-11-15 22:10:09 +00:00
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:
committed by
Paulus Schoutsen
parent
383b0914b3
commit
41f558b181
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user