mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
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:
parent
0056fcf904
commit
431cc63aaf
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user