From eef4408599f05e543ec3a751e980779dc99e84d6 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 17 Mar 2023 12:34:52 -0700 Subject: [PATCH] fix: sleep toggle sleep state (#186) --- custom_components/openevse/switch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/openevse/switch.py b/custom_components/openevse/switch.py index f60d085..3b433ba 100644 --- a/custom_components/openevse/switch.py +++ b/custom_components/openevse/switch.py @@ -20,6 +20,8 @@ from .entity import OpenEVSESwitchEntityDescription _LOGGER = logging.getLogger(__name__) +SLEEP_STATE = "sleeping" +ATTR_STATE = "state" async def async_setup_entry(hass, entry, async_add_entities): @@ -88,8 +90,8 @@ def is_on(self) -> bool: _LOGGER.info("switch [%s] not supported.", self._type) return None _LOGGER.debug("switch [%s]: %s", self._attr_name, data[self._type]) - if self._type == "state": - return True if data[self._type] == "Sleeping" else False + if self._type == ATTR_STATE: + return True if data[self._type] == SLEEP_STATE else False return cast(bool, data[self._type] == 1) async def async_turn_on(self, **kwargs: Any) -> None: