Add Google Assistant support for setting climate temperature and operation mode. (#10174)

Fixes #10025.
This commit is contained in:
Eitan Mosenkis 2017-11-01 16:44:59 +02:00 committed by Paulus Schoutsen
parent fb34f94d9c
commit 4da8ec0a05
5 changed files with 120 additions and 17 deletions

View file

@ -6,7 +6,7 @@ import pytest
from homeassistant import setup, const, core
from homeassistant.components import (
http, async_setup, light, cover, media_player, fan, switch
http, async_setup, light, cover, media_player, fan, switch, climate
)
from homeassistant.components import google_assistant as ga
from tests.common import get_test_instance_port
@ -45,7 +45,7 @@ def assistant_client(loop, hass_fixture, test_client):
@pytest.fixture
def hass_fixture(loop, hass):
"""Setup a hass instance for these tests."""
"""Set up a hass instance for these tests."""
# We need to do this to get access to homeassistant/turn_(on,off)
loop.run_until_complete(async_setup(hass, {core.DOMAIN: {}}))
@ -89,6 +89,13 @@ def hass_fixture(loop, hass):
}]
}))
loop.run_until_complete(
setup.async_setup_component(hass, climate.DOMAIN, {
'climate': [{
'platform': 'demo'
}]
}))
# Kitchen light is explicitly excluded from being exposed
ceiling_lights_entity = hass.states.get('light.ceiling_lights')
attrs = dict(ceiling_lights_entity.attributes)
@ -142,15 +149,18 @@ def test_sync_request(hass_fixture, assistant_client):
body = yield from result.json()
assert body.get('requestId') == reqid
devices = body['payload']['devices']
# assert len(devices) == 4
assert len(devices) == len(DEMO_DEVICES)
# HACK this is kind of slow and lazy
for dev in devices:
for demo in DEMO_DEVICES:
if dev['id'] == demo['id']:
assert dev['name'] == demo['name']
assert set(dev['traits']) == set(demo['traits'])
assert dev['type'] == demo['type']
assert (
sorted([dev['id'] for dev in devices])
== sorted([dev['id'] for dev in DEMO_DEVICES]))
for dev, demo in zip(
sorted(devices, key=lambda d: d['id']),
sorted(DEMO_DEVICES, key=lambda d: d['id'])):
assert dev['name'] == demo['name']
assert set(dev['traits']) == set(demo['traits'])
assert dev['type'] == demo['type']
if 'attributes' in demo:
assert dev['attributes'] == demo['attributes']
@asyncio.coroutine