Google Assistant for climate entities: Support QUERY and respect system-wide unit_system setting. (#10346)
This commit is contained in:
parent
309e493e76
commit
0b4de54725
4 changed files with 176 additions and 24 deletions
|
@ -11,6 +11,7 @@ from homeassistant import core, const, setup
|
|||
from homeassistant.components import (
|
||||
fan, http, cover, light, switch, climate, async_setup, media_player)
|
||||
from homeassistant.components import google_assistant as ga
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
|
||||
|
||||
from . import DEMO_DEVICES
|
||||
|
||||
|
@ -198,6 +199,101 @@ def test_query_request(hass_fixture, assistant_client):
|
|||
assert devices['light.ceiling_lights']['brightness'] == 70
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_query_climate_request(hass_fixture, assistant_client):
|
||||
"""Test a query request."""
|
||||
reqid = '5711642932632160984'
|
||||
data = {
|
||||
'requestId':
|
||||
reqid,
|
||||
'inputs': [{
|
||||
'intent': 'action.devices.QUERY',
|
||||
'payload': {
|
||||
'devices': [
|
||||
{'id': 'climate.hvac'},
|
||||
{'id': 'climate.heatpump'},
|
||||
{'id': 'climate.ecobee'},
|
||||
]
|
||||
}
|
||||
}]
|
||||
}
|
||||
result = yield from assistant_client.post(
|
||||
ga.const.GOOGLE_ASSISTANT_API_ENDPOINT,
|
||||
data=json.dumps(data),
|
||||
headers=AUTH_HEADER)
|
||||
assert result.status == 200
|
||||
body = yield from result.json()
|
||||
assert body.get('requestId') == reqid
|
||||
devices = body['payload']['devices']
|
||||
assert devices == {
|
||||
'climate.heatpump': {
|
||||
'thermostatTemperatureSetpoint': 20.0,
|
||||
'thermostatTemperatureAmbient': 25.0,
|
||||
'thermostatMode': 'heat',
|
||||
},
|
||||
'climate.ecobee': {
|
||||
'thermostatTemperatureSetpointHigh': 24,
|
||||
'thermostatTemperatureAmbient': 23,
|
||||
'thermostatMode': 'on',
|
||||
'thermostatTemperatureSetpointLow': 21
|
||||
},
|
||||
'climate.hvac': {
|
||||
'thermostatTemperatureSetpoint': 21,
|
||||
'thermostatTemperatureAmbient': 22,
|
||||
'thermostatMode': 'cool',
|
||||
'thermostatHumidityAmbient': 54,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_query_climate_request_f(hass_fixture, assistant_client):
|
||||
"""Test a query request."""
|
||||
hass_fixture.config.units = IMPERIAL_SYSTEM
|
||||
reqid = '5711642932632160984'
|
||||
data = {
|
||||
'requestId':
|
||||
reqid,
|
||||
'inputs': [{
|
||||
'intent': 'action.devices.QUERY',
|
||||
'payload': {
|
||||
'devices': [
|
||||
{'id': 'climate.hvac'},
|
||||
{'id': 'climate.heatpump'},
|
||||
{'id': 'climate.ecobee'},
|
||||
]
|
||||
}
|
||||
}]
|
||||
}
|
||||
result = yield from assistant_client.post(
|
||||
ga.const.GOOGLE_ASSISTANT_API_ENDPOINT,
|
||||
data=json.dumps(data),
|
||||
headers=AUTH_HEADER)
|
||||
assert result.status == 200
|
||||
body = yield from result.json()
|
||||
assert body.get('requestId') == reqid
|
||||
devices = body['payload']['devices']
|
||||
assert devices == {
|
||||
'climate.heatpump': {
|
||||
'thermostatTemperatureSetpoint': -6.7,
|
||||
'thermostatTemperatureAmbient': -3.9,
|
||||
'thermostatMode': 'heat',
|
||||
},
|
||||
'climate.ecobee': {
|
||||
'thermostatTemperatureSetpointHigh': -4.4,
|
||||
'thermostatTemperatureAmbient': -5,
|
||||
'thermostatMode': 'on',
|
||||
'thermostatTemperatureSetpointLow': -6.1,
|
||||
},
|
||||
'climate.hvac': {
|
||||
'thermostatTemperatureSetpoint': -6.1,
|
||||
'thermostatTemperatureAmbient': -5.6,
|
||||
'thermostatMode': 'cool',
|
||||
'thermostatHumidityAmbient': 54,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_execute_request(hass_fixture, assistant_client):
|
||||
"""Test a execute request."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue