Trend binary sensor check for state unavailable (#22621)

* Trend binary sensor check for state unavailable

Fixes: https://github.com/home-assistant/home-assistant/issues/20210

* Fix pylint
This commit is contained in:
VDRainer 2019-04-01 19:03:18 +02:00 committed by Rohan Kapoor
parent 0056fcf904
commit 431cc63aaf

View File

@ -10,7 +10,7 @@ from homeassistant.components.binary_sensor import (
BinarySensorDevice)
from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME, CONF_DEVICE_CLASS, CONF_ENTITY_ID,
CONF_FRIENDLY_NAME, STATE_UNKNOWN, CONF_SENSORS)
CONF_FRIENDLY_NAME, STATE_UNKNOWN, STATE_UNAVAILABLE, CONF_SENSORS)
from homeassistant.core import callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import generate_entity_id
@ -140,7 +140,7 @@ class SensorTrend(BinarySensorDevice):
state = new_state.attributes.get(self._attribute)
else:
state = new_state.state
if state != STATE_UNKNOWN:
if state not in (STATE_UNKNOWN, STATE_UNAVAILABLE):
sample = (utcnow().timestamp(), float(state))
self.samples.append(sample)
self.async_schedule_update_ha_state(True)