Always return lockState == LOCKED when handling Alexa.LockController (#12328)
parent
2a0bd8d330
commit
a06000c76d
|
@ -1065,7 +1065,16 @@ def async_api_lock(hass, config, request, entity):
|
|||
ATTR_ENTITY_ID: entity.entity_id
|
||||
}, 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
|
||||
|
|
|
@ -401,11 +401,17 @@ def test_lock(hass):
|
|||
assert appliance['friendlyName'] == "Test lock"
|
||||
assert_endpoint_capabilities(appliance, 'Alexa.LockController')
|
||||
|
||||
yield from assert_request_calls_service(
|
||||
_, msg = yield from assert_request_calls_service(
|
||||
'Alexa.LockController', 'Lock', 'lock#test',
|
||||
'lock.lock',
|
||||
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
|
||||
def test_media_player(hass):
|
||||
|
|
Loading…
Reference in New Issue