Async syntax 6, sensor (#17020)
This commit is contained in:
1 parent
121dba659c
commit
9e4c8f45d6
45 files changed
+195
-319
No files matched your search
@@ -4,7 +4,6 @@ Support for statistics for sensor values.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.statistics/
|
||||
"""
|
||||
import asyncio
|
||||
import logging
|
||||
import statistics
|
||||
from collections import deque
|
||||
@@ -58,9 +57,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 Statistics sensor."""
|
||||
entity_id = config.get(CONF_ENTITY_ID)
|
||||
name = config.get(CONF_NAME)
|
||||
@@ -179,8 +177,7 @@ class StatisticsSensor(Entity):
|
||||
self.ages.popleft()
|
||||
self.states.popleft()
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_update(self):
|
||||
async def async_update(self):
|
||||
"""Get the latest data and updates the states."""
|
||||
if self._max_age is not None:
|
||||
self._purge_old()
|
||||
@@ -236,8 +233,7 @@ class StatisticsSensor(Entity):
|
||||
self.change = self.average_change = STATE_UNKNOWN
|
||||
self.change_rate = STATE_UNKNOWN
|
||||
|
||||
@asyncio.coroutine
|
||||
def _initialize_from_database(self):
|
||||
async def _initialize_from_database(self):
|
||||
"""Initialize the list of states from the database.
|
||||
|
||||
The query will get the list of states in DESCENDING order so that we
|
||||
|
||||
Reference in new issue
Block a user