Async syntax 6, sensor (#17020)

This commit is contained in:
cdce8p authored and Paulus Schoutsen committed 2018-10-01 08:55:43 +02:00
1 parent 121dba659c
commit 9e4c8f45d6
45 files changed
+195 -319

No files matched your search

+4 -8
View File
@@ -4,7 +4,6 @@ Allows the creation of a sensor that breaks out state_attributes.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.template/
"""
import asyncio
import logging
from typing import Optional
@@ -41,9 +40,8 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
})
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the template sensors."""
sensors = []
@@ -123,8 +121,7 @@ class SensorTemplate(Entity):
self._entities = entity_ids
self._device_class = device_class
@asyncio.coroutine
def async_added_to_hass(self):
async def async_added_to_hass(self):
"""Register callbacks."""
@callback
def template_sensor_state_listener(entity, old_state, new_state):
@@ -177,8 +174,7 @@ class SensorTemplate(Entity):
"""No polling needed."""
return False
@asyncio.coroutine
def async_update(self):
async def async_update(self):
"""Update the state from the template."""
try:
self._state = self._template.async_render()