From 1e0025acaec4947087d6b335677b973c35edf563 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 8 Nov 2016 20:25:19 -0800 Subject: [PATCH] Fix Tellstick doing I/O inside event loop (#4268) --- homeassistant/components/sensor/tellstick.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/tellstick.py b/homeassistant/components/sensor/tellstick.py index 464e3554324..08e15cd332f 100644 --- a/homeassistant/components/sensor/tellstick.py +++ b/homeassistant/components/sensor/tellstick.py @@ -98,6 +98,7 @@ class TellstickSensor(Entity): self.datatype = datatype self.sensor = sensor self._unit_of_measurement = sensor_info.unit or None + self._value = None self._name = '{} {}'.format(name, sensor_info.name) @@ -109,9 +110,13 @@ class TellstickSensor(Entity): @property def state(self): """Return the state of the sensor.""" - return self.sensor.value(self.datatype).value + return self._value @property def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement + + def update(self): + """Update tellstick sensor.""" + self._value = self.sensor.value(self.datatype).value