Added toggle service to covers (#23198)
* Added toggle service to cover * Added toggle tilt service and tilt closed property * Added is_tilt_closed so tilt can be toggled * Added toggle services * Added toggle tilt service * Removed spaces * Added tests for tilt services * Updated tests * Added range conversion in comparison * Added tests to cover broken areas * Fixed open/close tilt values and added toggle function * Added default toggle behavior using tilt_position of 0, reverted other changes * blank space * Added constants and swapped assert comparisons * Fixed attribute name * Added mqtt responses in test * Added constants * Space * Fix tilt_optimistic flag being ignored if status topic set * Added more tests * Changed async toggle call * Updated group tilt test * Updated format of asserts * Updated states calls * Updated function variables * merge fixes * Added blank line * Changed calls to async * More async updates
This commit is contained in:
1 parent
a02b69db38
commit
7564d1fb52
9 files changed
+596
-118
No files matched your search
@@ -7,6 +7,7 @@ from homeassistant.components.cover import (
|
||||
ATTR_POSITION, ATTR_TILT_POSITION, DOMAIN)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID, SERVICE_CLOSE_COVER, SERVICE_CLOSE_COVER_TILT,
|
||||
SERVICE_TOGGLE, SERVICE_TOGGLE_COVER_TILT,
|
||||
SERVICE_OPEN_COVER, SERVICE_OPEN_COVER_TILT, SERVICE_SET_COVER_POSITION,
|
||||
SERVICE_SET_COVER_TILT_POSITION, SERVICE_STOP_COVER,
|
||||
STATE_CLOSED, STATE_OPEN)
|
||||
@@ -464,6 +465,20 @@ async def test_set_position(hass, calls):
|
||||
state = hass.states.get('cover.test_template_cover')
|
||||
assert state.attributes.get('current_position') == 0.0
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('cover.test_template_cover')
|
||||
assert state.attributes.get('current_position') == 100.0
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('cover.test_template_cover')
|
||||
assert state.attributes.get('current_position') == 0.0
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_SET_COVER_POSITION,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER, ATTR_POSITION: 25}, blocking=True)
|
||||
@@ -626,6 +641,20 @@ async def test_set_position_optimistic(hass, calls):
|
||||
state = hass.states.get('cover.test_template_cover')
|
||||
assert state.state == STATE_OPEN
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('cover.test_template_cover')
|
||||
assert state.state == STATE_CLOSED
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('cover.test_template_cover')
|
||||
assert state.state == STATE_OPEN
|
||||
|
||||
|
||||
async def test_set_tilt_position_optimistic(hass, calls):
|
||||
"""Test the optimistic tilt_position mode."""
|
||||
@@ -675,6 +704,20 @@ async def test_set_tilt_position_optimistic(hass, calls):
|
||||
state = hass.states.get('cover.test_template_cover')
|
||||
assert state.attributes.get('current_tilt_position') == 100.0
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('cover.test_template_cover')
|
||||
assert state.attributes.get('current_tilt_position') == 0.0
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TOGGLE_COVER_TILT,
|
||||
{ATTR_ENTITY_ID: ENTITY_COVER}, blocking=True)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get('cover.test_template_cover')
|
||||
assert state.attributes.get('current_tilt_position') == 100.0
|
||||
|
||||
|
||||
async def test_icon_template(hass, calls):
|
||||
"""Test icon template."""
|
||||
|
||||
Reference in new issue
Block a user