Fix homematicip cloud cover tilt position (#73410)

* cover slats fixed set tilt position

* Update cover.py

* Adjust tests

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Joel 2022-06-20 16:08:43 +02:00 committed by GitHub
parent 483406dea5
commit 3824703a64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View File

@ -241,15 +241,19 @@ class HomematicipMultiCoverSlats(HomematicipMultiCoverShutter, CoverEntity):
position = kwargs[ATTR_TILT_POSITION]
# HmIP slats is closed:1 -> open:0
level = 1 - position / 100.0
await self._device.set_slats_level(level, self._channel)
await self._device.set_slats_level(slatsLevel=level, channelIndex=self._channel)
async def async_open_cover_tilt(self, **kwargs) -> None:
"""Open the slats."""
await self._device.set_slats_level(HMIP_SLATS_OPEN, self._channel)
await self._device.set_slats_level(
slatsLevel=HMIP_SLATS_OPEN, channelIndex=self._channel
)
async def async_close_cover_tilt(self, **kwargs) -> None:
"""Close the slats."""
await self._device.set_slats_level(HMIP_SLATS_CLOSED, self._channel)
await self._device.set_slats_level(
slatsLevel=HMIP_SLATS_CLOSED, channelIndex=self._channel
)
async def async_stop_cover_tilt(self, **kwargs) -> None:
"""Stop the device if in motion."""

View File

@ -109,7 +109,7 @@ async def test_hmip_cover_slats(hass, default_mock_hap_factory):
)
assert len(hmip_device.mock_calls) == service_call_counter + 1
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
assert hmip_device.mock_calls[-1][1] == (0, 1)
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 1, "slatsLevel": 0}
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0)
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0)
ha_state = hass.states.get(entity_id)
@ -125,7 +125,7 @@ async def test_hmip_cover_slats(hass, default_mock_hap_factory):
)
assert len(hmip_device.mock_calls) == service_call_counter + 4
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
assert hmip_device.mock_calls[-1][1] == (0.5, 1)
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 1, "slatsLevel": 0.5}
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0.5)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OPEN
@ -137,7 +137,7 @@ async def test_hmip_cover_slats(hass, default_mock_hap_factory):
)
assert len(hmip_device.mock_calls) == service_call_counter + 6
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
assert hmip_device.mock_calls[-1][1] == (1, 1)
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 1, "slatsLevel": 1}
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 1)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OPEN
@ -187,7 +187,7 @@ async def test_hmip_multi_cover_slats(hass, default_mock_hap_factory):
)
assert len(hmip_device.mock_calls) == service_call_counter + 1
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
assert hmip_device.mock_calls[-1][1] == (0, 4)
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 4, "slatsLevel": 0}
await async_manipulate_test_data(hass, hmip_device, "shutterLevel", 0, channel=4)
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0, channel=4)
ha_state = hass.states.get(entity_id)
@ -203,7 +203,7 @@ async def test_hmip_multi_cover_slats(hass, default_mock_hap_factory):
)
assert len(hmip_device.mock_calls) == service_call_counter + 4
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
assert hmip_device.mock_calls[-1][1] == (0.5, 4)
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 4, "slatsLevel": 0.5}
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 0.5, channel=4)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OPEN
@ -215,7 +215,7 @@ async def test_hmip_multi_cover_slats(hass, default_mock_hap_factory):
)
assert len(hmip_device.mock_calls) == service_call_counter + 6
assert hmip_device.mock_calls[-1][0] == "set_slats_level"
assert hmip_device.mock_calls[-1][1] == (1, 4)
assert hmip_device.mock_calls[-1][2] == {"channelIndex": 4, "slatsLevel": 1}
await async_manipulate_test_data(hass, hmip_device, "slatsLevel", 1, channel=4)
ha_state = hass.states.get(entity_id)
assert ha_state.state == STATE_OPEN