From 134137dd1cbb74a0a57998e70e20d119473090a8 Mon Sep 17 00:00:00 2001 From: Mark Coombes Date: Sat, 12 Oct 2019 16:11:30 -0400 Subject: [PATCH] Fix for unknown sensor state (#27542) --- homeassistant/components/ecobee/binary_sensor.py | 8 ++++++-- homeassistant/components/ecobee/sensor.py | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/ecobee/binary_sensor.py b/homeassistant/components/ecobee/binary_sensor.py index 7afdbae5a28..375146b96e8 100644 --- a/homeassistant/components/ecobee/binary_sensor.py +++ b/homeassistant/components/ecobee/binary_sensor.py @@ -67,6 +67,10 @@ class EcobeeBinarySensor(BinarySensorDevice): """Get the latest state of the sensor.""" await self.data.update() for sensor in self.data.ecobee.get_remote_sensors(self.index): + if sensor["name"] != self.sensor_name: + continue for item in sensor["capability"]: - if item["type"] == "occupancy" and self.sensor_name == sensor["name"]: - self._state = item["value"] + if item["type"] != "occupancy": + continue + self._state = item["value"] + break diff --git a/homeassistant/components/ecobee/sensor.py b/homeassistant/components/ecobee/sensor.py index 24ea3d281bc..48a616a1d1f 100644 --- a/homeassistant/components/ecobee/sensor.py +++ b/homeassistant/components/ecobee/sensor.py @@ -74,7 +74,7 @@ class EcobeeSensor(Entity): @property def state(self): """Return the state of the sensor.""" - if self._state in [ECOBEE_STATE_CALIBRATING, ECOBEE_STATE_UNKNOWN]: + if self._state in [ECOBEE_STATE_CALIBRATING, ECOBEE_STATE_UNKNOWN, "unknown"]: return None if self.type == "temperature": @@ -91,6 +91,10 @@ class EcobeeSensor(Entity): """Get the latest state of the sensor.""" await self.data.update() for sensor in self.data.ecobee.get_remote_sensors(self.index): + if sensor["name"] != self.sensor_name: + continue for item in sensor["capability"]: - if item["type"] == self.type and self.sensor_name == sensor["name"]: - self._state = item["value"] + if item["type"] != self.type: + continue + self._state = item["value"] + break