Always return lockState == LOCKED when handling Alexa.LockController (#12328)

This commit is contained in:
Richard Lucas 2018-02-11 23:20:54 -08:00 committed by Paulus Schoutsen
parent 5d15b257c4
commit 7059b6c6c1
2 changed files with 17 additions and 2 deletions

View File

@ -1065,7 +1065,16 @@ def async_api_lock(hass, config, request, entity):
ATTR_ENTITY_ID: entity.entity_id ATTR_ENTITY_ID: entity.entity_id
}, blocking=False) }, blocking=False)
return api_message(request) # Alexa expects a lockState in the response, we don't know the actual
# lockState at this point but assume it is locked. It is reported
# correctly later when ReportState is called. The alt. to this approach
# is to implement DeferredResponse
properties = [{
'name': 'lockState',
'namespace': 'Alexa.LockController',
'value': 'LOCKED'
}]
return api_message(request, context={'properties': properties})
# Not supported by Alexa yet # Not supported by Alexa yet

View File

@ -401,11 +401,17 @@ def test_lock(hass):
assert appliance['friendlyName'] == "Test lock" assert appliance['friendlyName'] == "Test lock"
assert_endpoint_capabilities(appliance, 'Alexa.LockController') assert_endpoint_capabilities(appliance, 'Alexa.LockController')
yield from assert_request_calls_service( _, msg = yield from assert_request_calls_service(
'Alexa.LockController', 'Lock', 'lock#test', 'Alexa.LockController', 'Lock', 'lock#test',
'lock.lock', 'lock.lock',
hass) hass)
# always return LOCKED for now
properties = msg['context']['properties'][0]
assert properties['name'] == 'lockState'
assert properties['namespace'] == 'Alexa.LockController'
assert properties['value'] == 'LOCKED'
@asyncio.coroutine @asyncio.coroutine
def test_media_player(hass): def test_media_player(hass):