-
-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added HassOpenCover and HassCloseCover intents (#13372)
* Added intents to cover * Added test for cover intents * Style fixes * Reverted reversions * Async fixes * Woof * Added conditional loading * Added conditional loading * Added conditional loading * Moved tests, fixed logic * Moved tests, fixed logic * Pylint * Pylint * Refactored componenet registration * Refactored componenet registration * Lint
- Loading branch information
1 parent
bf58945
commit bf44dc4
Showing
5 changed files
with
183 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""The tests for the cover platform.""" | ||
|
||
from homeassistant.components.cover import (SERVICE_OPEN_COVER, | ||
SERVICE_CLOSE_COVER) | ||
from homeassistant.components import intent | ||
import homeassistant.components as comps | ||
from tests.common import async_mock_service | ||
|
||
|
||
async def test_open_cover_intent(hass): | ||
"""Test HassOpenCover intent.""" | ||
result = await comps.cover.async_setup(hass, {}) | ||
assert result | ||
|
||
hass.states.async_set('cover.garage_door', 'closed') | ||
calls = async_mock_service(hass, 'cover', SERVICE_OPEN_COVER) | ||
|
||
response = await intent.async_handle( | ||
hass, 'test', 'HassOpenCover', {'name': {'value': 'garage door'}} | ||
) | ||
await hass.async_block_till_done() | ||
|
||
assert response.speech['plain']['speech'] == 'Opened garage door' | ||
assert len(calls) == 1 | ||
call = calls[0] | ||
assert call.domain == 'cover' | ||
assert call.service == 'open_cover' | ||
assert call.data == {'entity_id': 'cover.garage_door'} | ||
|
||
|
||
async def test_close_cover_intent(hass): | ||
"""Test HassCloseCover intent.""" | ||
result = await comps.cover.async_setup(hass, {}) | ||
assert result | ||
|
||
hass.states.async_set('cover.garage_door', 'open') | ||
calls = async_mock_service(hass, 'cover', SERVICE_CLOSE_COVER) | ||
|
||
response = await intent.async_handle( | ||
hass, 'test', 'HassCloseCover', {'name': {'value': 'garage door'}} | ||
) | ||
await hass.async_block_till_done() | ||
|
||
assert response.speech['plain']['speech'] == 'Closed garage door' | ||
assert len(calls) == 1 | ||
call = calls[0] | ||
assert call.domain == 'cover' | ||
assert call.service == 'close_cover' | ||
assert call.data == {'entity_id': 'cover.garage_door'} |
Oops, something went wrong.