1
0
mirror of https://github.com/home-assistant/core.git synced 2026-06-06 07:26:58 +01:00

Add support for 180-degree tilt in BleBox shutter covers (#172237)

This commit is contained in:
bkobus-bbx
2026-05-26 15:19:43 +02:00
committed by GitHub
parent e37459c16b
commit 910b87b847
2 changed files with 22 additions and 5 deletions
+2 -1
View File
@@ -126,7 +126,8 @@ class BleBoxCoverEntity(BleBoxEntity[blebox_uniapi.cover.Cover], CoverEntity):
async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Fully open the cover tilt."""
await self._feature.async_set_tilt_position(0)
position = 50 if self._feature.is_tilt_180 else 0
await self._feature.async_set_tilt_position(position)
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Fully close the cover tilt."""
+20 -4
View File
@@ -537,15 +537,29 @@ async def test_set_tilt_position(shutterbox, hass: HomeAssistant) -> None:
assert hass.states.get(entity_id).state == CoverState.OPENING
async def test_open_tilt(shutterbox, hass: HomeAssistant) -> None:
"""Test closing tilt."""
@pytest.mark.parametrize(
("is_tilt_180", "expected_tilt_position", "expected_tilt_reported"),
[
pytest.param(False, 0, 100, id="tilt_90"),
pytest.param(True, 50, 50, id="tilt_180"),
],
)
async def test_open_tilt(
shutterbox,
hass: HomeAssistant,
is_tilt_180: bool,
expected_tilt_position: int,
expected_tilt_reported: int,
) -> None:
"""Test opening tilt for 90-degree and 180-degree tilt shutters."""
feature_mock, entity_id = shutterbox
feature_mock.is_tilt_180 = is_tilt_180
def initial_update():
feature_mock.tilt_current = 100
def set_tilt_position(tilt_position):
assert tilt_position == 0
assert tilt_position == expected_tilt_position
feature_mock.tilt_current = tilt_position
feature_mock.async_update = AsyncMock(side_effect=initial_update)
@@ -561,7 +575,9 @@ async def test_open_tilt(shutterbox, hass: HomeAssistant) -> None:
blocking=True,
)
state = hass.states.get(entity_id)
assert state.attributes[ATTR_CURRENT_TILT_POSITION] == 100 # inverted
assert (
state.attributes[ATTR_CURRENT_TILT_POSITION] == expected_tilt_reported
) # inverted
async def test_close_tilt(shutterbox, hass: HomeAssistant) -> None: