Fix opening cover via emulated_hue without specifying a position (#49570)
This commit is contained in:
parent
e6d94845dd
commit
66dbb17a4a
2 changed files with 28 additions and 8 deletions
|
@ -525,9 +525,10 @@ class HueOneLightChangeView(HomeAssistantView):
|
||||||
# If the requested entity is a cover, convert to open_cover/close_cover
|
# If the requested entity is a cover, convert to open_cover/close_cover
|
||||||
elif entity.domain == cover.DOMAIN:
|
elif entity.domain == cover.DOMAIN:
|
||||||
domain = entity.domain
|
domain = entity.domain
|
||||||
service = SERVICE_CLOSE_COVER
|
|
||||||
if service == SERVICE_TURN_ON:
|
if service == SERVICE_TURN_ON:
|
||||||
service = SERVICE_OPEN_COVER
|
service = SERVICE_OPEN_COVER
|
||||||
|
else:
|
||||||
|
service = SERVICE_CLOSE_COVER
|
||||||
|
|
||||||
if (
|
if (
|
||||||
entity_features & SUPPORT_SET_POSITION
|
entity_features & SUPPORT_SET_POSITION
|
||||||
|
|
|
@ -885,10 +885,10 @@ async def test_put_light_state_media_player(hass_hue, hue_client):
|
||||||
assert walkman.attributes[media_player.ATTR_MEDIA_VOLUME_LEVEL] == level
|
assert walkman.attributes[media_player.ATTR_MEDIA_VOLUME_LEVEL] == level
|
||||||
|
|
||||||
|
|
||||||
async def test_close_cover(hass_hue, hue_client):
|
async def test_open_cover_without_position(hass_hue, hue_client):
|
||||||
"""Test opening cover ."""
|
"""Test opening cover ."""
|
||||||
cover_id = "cover.living_room_window"
|
cover_id = "cover.living_room_window"
|
||||||
# Turn the office light off first
|
# Close cover first
|
||||||
await hass_hue.services.async_call(
|
await hass_hue.services.async_call(
|
||||||
cover.DOMAIN,
|
cover.DOMAIN,
|
||||||
const.SERVICE_CLOSE_COVER,
|
const.SERVICE_CLOSE_COVER,
|
||||||
|
@ -908,25 +908,44 @@ async def test_close_cover(hass_hue, hue_client):
|
||||||
assert cover_test.state == "closed"
|
assert cover_test.state == "closed"
|
||||||
|
|
||||||
# Go through the API to turn it on
|
# Go through the API to turn it on
|
||||||
cover_result = await perform_put_light_state(
|
cover_result = await perform_put_light_state(hass_hue, hue_client, cover_id, True)
|
||||||
hass_hue, hue_client, cover_id, True, 100
|
|
||||||
)
|
|
||||||
|
|
||||||
assert cover_result.status == HTTP_OK
|
assert cover_result.status == HTTP_OK
|
||||||
assert CONTENT_TYPE_JSON in cover_result.headers["content-type"]
|
assert CONTENT_TYPE_JSON in cover_result.headers["content-type"]
|
||||||
|
|
||||||
for _ in range(7):
|
for _ in range(11):
|
||||||
future = dt_util.utcnow() + timedelta(seconds=1)
|
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||||
async_fire_time_changed(hass_hue, future)
|
async_fire_time_changed(hass_hue, future)
|
||||||
await hass_hue.async_block_till_done()
|
await hass_hue.async_block_till_done()
|
||||||
|
|
||||||
cover_result_json = await cover_result.json()
|
cover_result_json = await cover_result.json()
|
||||||
|
|
||||||
assert len(cover_result_json) == 2
|
assert len(cover_result_json) == 1
|
||||||
|
|
||||||
# Check to make sure the state changed
|
# Check to make sure the state changed
|
||||||
cover_test_2 = hass_hue.states.get(cover_id)
|
cover_test_2 = hass_hue.states.get(cover_id)
|
||||||
assert cover_test_2.state == "open"
|
assert cover_test_2.state == "open"
|
||||||
|
assert cover_test_2.attributes.get("current_position") == 100
|
||||||
|
|
||||||
|
# Go through the API to turn it off
|
||||||
|
cover_result = await perform_put_light_state(hass_hue, hue_client, cover_id, False)
|
||||||
|
|
||||||
|
assert cover_result.status == HTTP_OK
|
||||||
|
assert CONTENT_TYPE_JSON in cover_result.headers["content-type"]
|
||||||
|
|
||||||
|
for _ in range(11):
|
||||||
|
future = dt_util.utcnow() + timedelta(seconds=1)
|
||||||
|
async_fire_time_changed(hass_hue, future)
|
||||||
|
await hass_hue.async_block_till_done()
|
||||||
|
|
||||||
|
cover_result_json = await cover_result.json()
|
||||||
|
|
||||||
|
assert len(cover_result_json) == 1
|
||||||
|
|
||||||
|
# Check to make sure the state changed
|
||||||
|
cover_test_2 = hass_hue.states.get(cover_id)
|
||||||
|
assert cover_test_2.state == "closed"
|
||||||
|
assert cover_test_2.attributes.get("current_position") == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_set_position_cover(hass_hue, hue_client):
|
async def test_set_position_cover(hass_hue, hue_client):
|
||||||
|
|
Loading…
Add table
Reference in a new issue