Skip to content

Commit

Permalink
fix: sleep toggle sleep state (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 authored Mar 17, 2023
1 parent e9ea33b commit eef4408
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/openevse/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit eef4408

Please sign in to comment.