diff --git a/homeassistant/components/alexa/smart_home.py b/homeassistant/components/alexa/smart_home.py index c0a42ef8aa6..a4f0225d22d 100644 --- a/homeassistant/components/alexa/smart_home.py +++ b/homeassistant/components/alexa/smart_home.py @@ -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 diff --git a/tests/components/alexa/test_smart_home.py b/tests/components/alexa/test_smart_home.py index 96e16544438..9654c667c5f 100644 --- a/tests/components/alexa/test_smart_home.py +++ b/tests/components/alexa/test_smart_home.py @@ -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):