Fix conversion of cover position between HASS and deCONZ (#43602)

This commit is contained in:
Robert Svensson 2020-11-24 14:47:56 +01:00 committed by GitHub
parent 755f15abe3
commit 7214d6517a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -85,7 +85,8 @@ class DeconzCover(DeconzDevice, CoverEntity):
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position.""" """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): async def async_open_cover(self, **kwargs):
"""Open cover.""" """Open cover."""

View File

@ -47,7 +47,7 @@ COVERS = {
"id": "deconz old brightness cover id", "id": "deconz old brightness cover id",
"name": "deconz old brightness cover", "name": "deconz old brightness cover",
"type": "Level controllable output", "type": "Level controllable output",
"state": {"bri": 255, "on": False, "reachable": True}, "state": {"bri": 254, "on": False, "reachable": True},
"modelid": "Not zigbee spec", "modelid": "Not zigbee spec",
"uniqueid": "00:00:00:00:00:00:00:03-00", "uniqueid": "00:00:00:00:00:00:00:03-00",
}, },
@ -55,7 +55,7 @@ COVERS = {
"id": "Window covering controller id", "id": "Window covering controller id",
"name": "Window covering controller", "name": "Window covering controller",
"type": "Window covering controller", "type": "Window covering controller",
"state": {"bri": 254, "on": True, "reachable": True}, "state": {"bri": 253, "on": True, "reachable": True},
"modelid": "Motor controller", "modelid": "Motor controller",
"uniqueid": "00:00:00:00:00:00:00:04-00", "uniqueid": "00:00:00:00:00:00:00:04-00",
}, },
@ -147,11 +147,11 @@ async def test_cover(hass):
await hass.services.async_call( await hass.services.async_call(
COVER_DOMAIN, COVER_DOMAIN,
SERVICE_SET_COVER_POSITION, 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, blocking=True,
) )
await hass.async_block_till_done() 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 # Service stop cover movement
@ -207,11 +207,11 @@ async def test_cover(hass):
await hass.services.async_call( await hass.services.async_call(
COVER_DOMAIN, COVER_DOMAIN,
SERVICE_SET_COVER_POSITION, 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, blocking=True,
) )
await hass.async_block_till_done() 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 # Service stop cover movement