Homeconnect remote states (#45610)

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
badguy99 2021-02-03 16:05:20 +00:00 committed by GitHub
parent 0875f654c8
commit 6458ff774f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 157 additions and 37 deletions

View file

@ -6,7 +6,7 @@ import logging
from homeassistant.const import DEVICE_CLASS_TIMESTAMP
import homeassistant.util.dt as dt_util
from .const import DOMAIN
from .const import BSH_OPERATION_STATE, DOMAIN
from .entity import HomeConnectEntity
_LOGGER = logging.getLogger(__name__)
@ -51,7 +51,7 @@ class HomeConnectSensor(HomeConnectEntity):
return self._state is not None
async def async_update(self):
"""Update the sensos status."""
"""Update the sensor's status."""
status = self.device.appliance.status
if self._key not in status:
self._state = None
@ -74,6 +74,11 @@ class HomeConnectSensor(HomeConnectEntity):
).isoformat()
else:
self._state = status[self._key].get("value")
if self._key == BSH_OPERATION_STATE:
# Value comes back as an enum, we only really care about the
# last part, so split it off
# https://developer.home-connect.com/docs/status/operation_state
self._state = self._state.split(".")[-1]
_LOGGER.debug("Updated, new state: %s", self._state)
@property