mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Handle GA Disconnect intent (#21387)
* Handle GA Disconnect intent * Fixed lint error
This commit is contained in:
parent
db4c06c8fe
commit
6626e5c4a4
@ -187,7 +187,7 @@ async def async_handle_message(hass, config, message):
|
|||||||
"""Handle incoming API messages."""
|
"""Handle incoming API messages."""
|
||||||
response = await _process(hass, config, message)
|
response = await _process(hass, config, message)
|
||||||
|
|
||||||
if 'errorCode' in response['payload']:
|
if response and 'errorCode' in response['payload']:
|
||||||
_LOGGER.error('Error handling message %s: %s',
|
_LOGGER.error('Error handling message %s: %s',
|
||||||
message, response['payload'])
|
message, response['payload'])
|
||||||
|
|
||||||
@ -215,7 +215,6 @@ async def _process(hass, config, message):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
result = await handler(hass, config, inputs[0].get('payload'))
|
result = await handler(hass, config, inputs[0].get('payload'))
|
||||||
return {'requestId': request_id, 'payload': result}
|
|
||||||
except SmartHomeError as err:
|
except SmartHomeError as err:
|
||||||
return {
|
return {
|
||||||
'requestId': request_id,
|
'requestId': request_id,
|
||||||
@ -228,6 +227,10 @@ async def _process(hass, config, message):
|
|||||||
'payload': {'errorCode': ERR_UNKNOWN_ERROR}
|
'payload': {'errorCode': ERR_UNKNOWN_ERROR}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if result is None:
|
||||||
|
return None
|
||||||
|
return {'requestId': request_id, 'payload': result}
|
||||||
|
|
||||||
|
|
||||||
@HANDLERS.register('action.devices.SYNC')
|
@HANDLERS.register('action.devices.SYNC')
|
||||||
async def async_devices_sync(hass, config, payload):
|
async def async_devices_sync(hass, config, payload):
|
||||||
@ -337,6 +340,15 @@ async def handle_devices_execute(hass, config, payload):
|
|||||||
return {'commands': final_results}
|
return {'commands': final_results}
|
||||||
|
|
||||||
|
|
||||||
|
@HANDLERS.register('action.devices.DISCONNECT')
|
||||||
|
async def async_devices_disconnect(hass, config, payload):
|
||||||
|
"""Handle action.devices.DISCONNECT request.
|
||||||
|
|
||||||
|
https://developers.google.com/actions/smarthome/create#actiondevicesdisconnect
|
||||||
|
"""
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def turned_off_response(message):
|
def turned_off_response(message):
|
||||||
"""Return a device turned off response."""
|
"""Return a device turned off response."""
|
||||||
return {
|
return {
|
||||||
|
@ -316,3 +316,15 @@ async def test_empty_name_doesnt_sync(hass):
|
|||||||
'devices': []
|
'devices': []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_query_disconnect(hass):
|
||||||
|
"""Test a disconnect message."""
|
||||||
|
result = await sh.async_handle_message(hass, BASIC_CONFIG, {
|
||||||
|
'inputs': [
|
||||||
|
{'intent': 'action.devices.DISCONNECT'}
|
||||||
|
],
|
||||||
|
'requestId': REQ_ID
|
||||||
|
})
|
||||||
|
|
||||||
|
assert result is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user