From e71e999ef632e5b34d40100da13276274e92d76b Mon Sep 17 00:00:00 2001 From: BelowAverageDev Date: Tue, 31 Jan 2023 00:41:03 +0000 Subject: [PATCH] update _is_opening, _is_closing to use 0.37.1 api --- homeassistant/components/switchbot/cover.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/switchbot/cover.py b/homeassistant/components/switchbot/cover.py index 70272c4bd8468b..495ce0468a0557 100644 --- a/homeassistant/components/switchbot/cover.py +++ b/homeassistant/components/switchbot/cover.py @@ -177,25 +177,10 @@ async def async_set_cover_tilt_position(self, **kwargs: Any) -> None: def _handle_coordinator_update(self) -> None: """Handle updated data from the coordinator.""" _tilt = self.parsed_data["tilt"] - _moving_up = ( - self.parsed_data["motionDirection"]["up"] and self.parsed_data["inMotion"] - ) - _moving_down = ( - self.parsed_data["motionDirection"]["down"] and self.parsed_data["inMotion"] - ) - # NOTE: when motion is down, motion up is also set to true for some reason - if _moving_up: - _opening = bool(_tilt > 50) - _closing = not _opening - elif _moving_down: - _opening = bool(_tilt < 50) - _closing = not _opening - else: - _opening = _closing = False self._attr_current_cover_tilt_position = _tilt self._attr_is_closed = (_tilt < self.CLOSED_DOWN_THRESHOLD) or ( _tilt > self.CLOSED_UP_THRESHOLD ) - self._attr_is_opening = _opening - self._attr_is_closing = _closing + self._attr_is_opening = self.parsed_data["motionDirection"]["opening"] + self._attr_is_closing = self.parsed_data["motionDirection"]["closing"] self.async_write_ha_state()