Skip to content

Commit

Permalink
add tilt functions
Browse files Browse the repository at this point in the history
  • Loading branch information
patman15 committed Jan 7, 2025
1 parent d73bb1d commit 49bb1e7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
16 changes: 11 additions & 5 deletions custom_components/hunterdouglas_powerview_ble/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,15 @@ async def set_position(
(
ShadeCmd.SET_POSITION,
int.to_bytes(pos1, 2, byteorder="little")
+ int.to_bytes(pos2 if pos2 is not None else 0x8000, 2, byteorder="little")
+ int.to_bytes(pos3 if pos3 is not None else 0x8000, 2, byteorder="little")
+ int.to_bytes(tilt if tilt is not None else 0x8000, 2, byteorder="little")
+ int.to_bytes(
pos2 if pos2 is not None else 0x8000, 2, byteorder="little"
)
+ int.to_bytes(
pos3 if pos3 is not None else 0x8000, 2, byteorder="little"
)
+ int.to_bytes(
tilt if tilt is not None else 0x8000, 2, byteorder="little"
)
+ int.to_bytes(velocity, 1),
),
disconnect,
Expand Down Expand Up @@ -303,7 +309,7 @@ async def query_dev_info(self) -> dict[str, str]:
.decode("UTF-8")
)
except BleakError as ex:
LOGGER.debug("%s: querying failed: %s", ex)
LOGGER.debug("%s: querying failed: %s", self.name, ex)
raise
finally:
await self.disconnect()
Expand Down Expand Up @@ -346,7 +352,7 @@ async def _connect(self) -> None:
disconnected_callback=self._on_disconnect,
services=[
UUID_COV_SERVICE,
# self.UUID_DEV_SERVICE,
UUID_DEV_SERVICE,
# self.UUID_BAT_SERVICE,
],
)
Expand Down
23 changes: 20 additions & 3 deletions custom_components/hunterdouglas_powerview_ble/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,12 @@ class PowerViewCoverTilt(PowerViewCover):
_attr_supported_features = (
CoverEntityFeature.OPEN
| CoverEntityFeature.CLOSE
| CoverEntityFeature.SET_POSITION
| CoverEntityFeature.STOP
# | CoverEntityFeature.CLOSE_TILT
| CoverEntityFeature.SET_POSITION
| CoverEntityFeature.OPEN_TILT
| CoverEntityFeature.CLOSE_TILT
| CoverEntityFeature.STOP_TILT
| CoverEntityFeature.SET_TILT_POSITION
# | CoverEntityFeature.OPEN_TILT
)

def __init__(
Expand Down Expand Up @@ -231,3 +232,19 @@ async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
target_position,
err,
)

async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the cover."""
await self.async_stop_cover(kwargs=kwargs)

async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the cover tilt."""
LOGGER.debug("open cover tilt")
_kwargs = {**kwargs, ATTR_TILT_POSITION: OPEN_POSITION}
await self.async_set_cover_tilt_position(**_kwargs)

async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the cover tilt."""
LOGGER.debug("close cover tilt")
_kwargs = {**kwargs, ATTR_TILT_POSITION: CLOSED_POSITION}
await self.async_set_cover_tilt_position(**_kwargs)

0 comments on commit 49bb1e7

Please sign in to comment.