Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions blebox_uniapi/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ def read_cover_type(
def min_position(self) -> int:
return 0

@property
def is_position_inverted(self) -> bool:
# shutterBox/gateController: % closed (0=open, 100=closed), inverted vs HA convention
return True

@property
def is_slider(self) -> bool:
return True
Expand Down Expand Up @@ -176,6 +181,11 @@ def read_cover_type(
class GateBox(Gate):
_control_type: Optional[GateBoxControlType]

@property
def is_position_inverted(self) -> bool:
# gateBox: (0=closed, 100=open), matches HA convention
return False

@property
def is_slider(self) -> bool:
return False
Expand All @@ -189,8 +199,6 @@ def close_command(self) -> str:
return "primary"

def read_state(self, alias: str, raw_value: Any, product: "Box") -> int:
# Reinterpret state to match shutterBox
# NOTE: shutterBox is inverted (0 == closed), gateBox isn't
current = raw_value("position")
desired = raw_value("desired")

Expand Down Expand Up @@ -329,6 +337,10 @@ def is_slider(self) -> Any:
def has_tilt(self) -> bool:
return self._attributes.has_tilt

@property
def is_position_inverted(self) -> bool:
return self._attributes.is_position_inverted

@property
def has_stop(self) -> bool:
return self._has_stop
Expand Down
4 changes: 4 additions & 0 deletions tests/test_cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ async def test_init(self, aioclient_mock):

assert entity.supported_features & SUPPORT_SET_POSITION
assert entity.current_cover_position is None
assert entity._feature.is_position_inverted is True

# TODO: tilt
# assert entity.supported_features & SUPPORT_SET_TILT_POSITION
Expand Down Expand Up @@ -385,6 +386,7 @@ async def test_init(self, aioclient_mock):

assert not entity.supported_features & SUPPORT_SET_POSITION
assert entity.current_cover_position is None
assert entity._feature.is_position_inverted is False
self.assert_state(entity, None)

async def test_device_info(self, aioclient_mock):
Expand Down Expand Up @@ -561,6 +563,7 @@ async def test_init(self, aioclient_mock):
assert entity.supported_features & SUPPORT_OPEN
assert entity.supported_features & SUPPORT_CLOSE
assert entity.current_cover_position is None
assert entity._feature.is_position_inverted is False
self.assert_state(entity, None)

async def test_device_info(self, aioclient_mock):
Expand Down Expand Up @@ -693,6 +696,7 @@ async def test_init(self, aioclient_mock):

assert entity.supported_features & SUPPORT_SET_POSITION
assert entity.current_cover_position is None
assert entity._feature.is_position_inverted is True
self.assert_state(entity, None)

async def test_device_info(self, aioclient_mock):
Expand Down
Loading