From 7214d6517ac05b39470581acac09eb60c3374b5b Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Tue, 24 Nov 2020 14:47:56 +0100 Subject: [PATCH] Fix conversion of cover position between HASS and deCONZ (#43602) --- homeassistant/components/deconz/cover.py | 3 ++- tests/components/deconz/test_cover.py | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/deconz/cover.py b/homeassistant/components/deconz/cover.py index ab5f6e0be9e..2d191b7f7ca 100644 --- a/homeassistant/components/deconz/cover.py +++ b/homeassistant/components/deconz/cover.py @@ -85,7 +85,8 @@ class DeconzCover(DeconzDevice, CoverEntity): async def async_set_cover_position(self, **kwargs): """Move the cover to a specific position.""" - await self._device.set_position(kwargs[ATTR_POSITION]) + position = 100 - kwargs[ATTR_POSITION] + await self._device.set_position(position) async def async_open_cover(self, **kwargs): """Open cover.""" diff --git a/tests/components/deconz/test_cover.py b/tests/components/deconz/test_cover.py index 3e31006438a..089a3d90a43 100644 --- a/tests/components/deconz/test_cover.py +++ b/tests/components/deconz/test_cover.py @@ -47,7 +47,7 @@ COVERS = { "id": "deconz old brightness cover id", "name": "deconz old brightness cover", "type": "Level controllable output", - "state": {"bri": 255, "on": False, "reachable": True}, + "state": {"bri": 254, "on": False, "reachable": True}, "modelid": "Not zigbee spec", "uniqueid": "00:00:00:00:00:00:00:03-00", }, @@ -55,7 +55,7 @@ COVERS = { "id": "Window covering controller id", "name": "Window covering controller", "type": "Window covering controller", - "state": {"bri": 254, "on": True, "reachable": True}, + "state": {"bri": 253, "on": True, "reachable": True}, "modelid": "Motor controller", "uniqueid": "00:00:00:00:00:00:00:04-00", }, @@ -147,11 +147,11 @@ async def test_cover(hass): await hass.services.async_call( COVER_DOMAIN, SERVICE_SET_COVER_POSITION, - {ATTR_ENTITY_ID: "cover.window_covering_device", ATTR_POSITION: 50}, + {ATTR_ENTITY_ID: "cover.window_covering_device", ATTR_POSITION: 40}, blocking=True, ) await hass.async_block_till_done() - set_callback.assert_called_with("put", "/lights/2/state", json={"lift": 50}) + set_callback.assert_called_with("put", "/lights/2/state", json={"lift": 60}) # Service stop cover movement @@ -207,11 +207,11 @@ async def test_cover(hass): await hass.services.async_call( COVER_DOMAIN, SERVICE_SET_COVER_POSITION, - {ATTR_ENTITY_ID: "cover.level_controllable_cover", ATTR_POSITION: 50}, + {ATTR_ENTITY_ID: "cover.level_controllable_cover", ATTR_POSITION: 40}, blocking=True, ) await hass.async_block_till_done() - set_callback.assert_called_with("put", "/lights/1/state", json={"bri": 127}) + set_callback.assert_called_with("put", "/lights/1/state", json={"bri": 152}) # Service stop cover movement