From 719aa0f317d3bc184150610f534f8a0022dd1416 Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Fri, 11 Sep 2020 22:05:07 +0200 Subject: [PATCH] Use STATE_UNKNOWN constant in dlink and ecobee (#39948) --- homeassistant/components/dlink/switch.py | 5 +++-- homeassistant/components/ecobee/sensor.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/dlink/switch.py b/homeassistant/components/dlink/switch.py index c173c879ad1..4fd21f200dd 100644 --- a/homeassistant/components/dlink/switch.py +++ b/homeassistant/components/dlink/switch.py @@ -13,6 +13,7 @@ from homeassistant.const import ( CONF_NAME, CONF_PASSWORD, CONF_USERNAME, + STATE_UNKNOWN, TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv @@ -145,14 +146,14 @@ class SmartPlugData: _LOGGER.warning("Waiting %s s to retry", retry_seconds) return - _state = "unknown" + _state = STATE_UNKNOWN try: self._last_tried = dt_util.now() _state = self.smartplug.state except urllib.error.HTTPError: _LOGGER.error("D-Link connection problem") - if _state == "unknown": + if _state == STATE_UNKNOWN: self._n_tried += 1 self.available = False _LOGGER.warning("Failed to connect to D-Link switch") diff --git a/homeassistant/components/ecobee/sensor.py b/homeassistant/components/ecobee/sensor.py index d9d6e74e3de..4351b230538 100644 --- a/homeassistant/components/ecobee/sensor.py +++ b/homeassistant/components/ecobee/sensor.py @@ -5,6 +5,7 @@ from homeassistant.const import ( DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, PERCENTAGE, + STATE_UNKNOWN, TEMP_FAHRENHEIT, ) from homeassistant.helpers.entity import Entity @@ -108,7 +109,11 @@ class EcobeeSensor(Entity): @property def state(self): """Return the state of the sensor.""" - if self._state in [ECOBEE_STATE_CALIBRATING, ECOBEE_STATE_UNKNOWN, "unknown"]: + if self._state in [ + ECOBEE_STATE_CALIBRATING, + ECOBEE_STATE_UNKNOWN, + STATE_UNKNOWN, + ]: return None if self.type == "temperature":