Skip to content

Commit

Permalink
Correction of cover state bug when using cover when using actions on …
Browse files Browse the repository at this point in the history
…cover group.
  • Loading branch information
cnico committed May 1, 2024
1 parent 305c7ab commit 18d48f3
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions homeassistant/components/dio_chacon/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,41 @@ def __init__(
async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover."""

_LOGGER.debug("Close cover %s , %s", self._target_id, self._attr_name)

self._attr_is_closing = True
self.async_write_ha_state()

await self.dio_chacon_client.move_shutter_direction(
self._target_id, ShutterMoveEnum.DOWN
_LOGGER.debug(
"Close cover %s , %s, %s",
self._target_id,
self._attr_name,
self._attr_is_closed,
)

# closes effectively only if cover is not already closing and not fully closed
if not self._attr_is_closing and not self._attr_is_closed:
self._attr_is_closing = True
self.async_write_ha_state()
await self.dio_chacon_client.move_shutter_direction(
self._target_id, ShutterMoveEnum.DOWN
)

# Closed signal is managed via a callback _on_device_state_changed

async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""

_LOGGER.debug("Open cover %s , %s", self._target_id, self._attr_name)
_LOGGER.debug(
"Open cover %s , %s, %s",
self._target_id,
self._attr_name,
self.current_cover_position,
)

self._attr_is_opening = True
self.async_write_ha_state()
# opens effectively only if cover is not already opening and not fully opened
if not self._attr_is_opening and self.current_cover_position != 100:
self._attr_is_opening = True
self.async_write_ha_state()

await self.dio_chacon_client.move_shutter_direction(
self._target_id, ShutterMoveEnum.UP
)
await self.dio_chacon_client.move_shutter_direction(
self._target_id, ShutterMoveEnum.UP
)

# Opened signal is managed via a callback _on_device_state_changed

Expand Down

0 comments on commit 18d48f3

Please sign in to comment.