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

+2 -4
View File
@@ -4,7 +4,6 @@ Support for Speedtest.net.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.speedtest/
"""
import asyncio
import logging
import voluptuous as vol
@@ -139,10 +138,9 @@ class SpeedtestSensor(Entity):
elif self.type == 'upload':
self._state = round(self._data['upload'] / 10**6, 2)
@asyncio.coroutine
def async_added_to_hass(self):
async def async_added_to_hass(self):
"""Handle all entity which are about to be added."""
state = yield from async_get_last_state(self.hass, self.entity_id)
state = await async_get_last_state(self.hass, self.entity_id)
if not state:
return
self._state = state.state