mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Use STATE_UNKNOWN constant in dlink and ecobee (#39948)
This commit is contained in:
parent
50c573eb4d
commit
719aa0f317
@ -13,6 +13,7 @@ from homeassistant.const import (
|
|||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
|
STATE_UNKNOWN,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -145,14 +146,14 @@ class SmartPlugData:
|
|||||||
_LOGGER.warning("Waiting %s s to retry", retry_seconds)
|
_LOGGER.warning("Waiting %s s to retry", retry_seconds)
|
||||||
return
|
return
|
||||||
|
|
||||||
_state = "unknown"
|
_state = STATE_UNKNOWN
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._last_tried = dt_util.now()
|
self._last_tried = dt_util.now()
|
||||||
_state = self.smartplug.state
|
_state = self.smartplug.state
|
||||||
except urllib.error.HTTPError:
|
except urllib.error.HTTPError:
|
||||||
_LOGGER.error("D-Link connection problem")
|
_LOGGER.error("D-Link connection problem")
|
||||||
if _state == "unknown":
|
if _state == STATE_UNKNOWN:
|
||||||
self._n_tried += 1
|
self._n_tried += 1
|
||||||
self.available = False
|
self.available = False
|
||||||
_LOGGER.warning("Failed to connect to D-Link switch")
|
_LOGGER.warning("Failed to connect to D-Link switch")
|
||||||
|
@ -5,6 +5,7 @@ from homeassistant.const import (
|
|||||||
DEVICE_CLASS_HUMIDITY,
|
DEVICE_CLASS_HUMIDITY,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
|
STATE_UNKNOWN,
|
||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
@ -108,7 +109,11 @@ class EcobeeSensor(Entity):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the sensor."""
|
"""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
|
return None
|
||||||
|
|
||||||
if self.type == "temperature":
|
if self.type == "temperature":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user