Async syntax 1, alarm_control_panel & automation & binary_sensor (#17015)

This commit is contained in:
cdce8p authored and Paulus Schoutsen committed 2018-10-01 08:49:19 +02:00
1 parent 750c96709e
commit 38e371c5d9
39 files changed
+109 -220

No files matched your search

@@ -4,7 +4,6 @@ A sensor that monitors trends in other components.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.trend/
"""
import asyncio
from collections import deque
import logging
import math
@@ -138,8 +137,7 @@ class SensorTrend(BinarySensorDevice):
"""No polling needed."""
return False
@asyncio.coroutine
def async_added_to_hass(self):
async def async_added_to_hass(self):
"""Complete device setup after being added to hass."""
@callback
def trend_sensor_state_listener(entity, old_state, new_state):
@@ -160,8 +158,7 @@ class SensorTrend(BinarySensorDevice):
self.hass, self._entity_id,
trend_sensor_state_listener)
@asyncio.coroutine
def async_update(self):
async def async_update(self):
"""Get the latest data and update the states."""
# Remove outdated samples
if self._sample_duration > 0:
@@ -173,7 +170,7 @@ class SensorTrend(BinarySensorDevice):
return
# Calculate gradient of linear trend
yield from self.hass.async_add_job(self._calculate_gradient)
await self.hass.async_add_job(self._calculate_gradient)
# Update state
self._state = (