diff --git a/homeassistant/components/alexa/handlers.py b/homeassistant/components/alexa/handlers.py index bd07b71ca29aa7983543aa607ecae103b874ff28..139defe831303733ee029bf72e8605b5cad14e78 100644 --- a/homeassistant/components/alexa/handlers.py +++ b/homeassistant/components/alexa/handlers.py @@ -412,7 +412,6 @@ async def async_api_lock(hass, config, directive, context): return response -# Not supported by Alexa yet @HANDLERS.register(("Alexa.LockController", "Unlock")) async def async_api_unlock(hass, config, directive, context): """Process an unlock request.""" @@ -425,7 +424,12 @@ async def async_api_unlock(hass, config, directive, context): context=context, ) - return directive.response() + response = directive.response() + response.add_context_property( + {"namespace": "Alexa.LockController", "name": "lockState", "value": "UNLOCKED"} + ) + + return response @HANDLERS.register(("Alexa.Speaker", "SetVolume")) diff --git a/tests/components/alexa/test_smart_home.py b/tests/components/alexa/test_smart_home.py index 78bdd8e09082a28602ea91e7a9a441e5090603eb..186cb850e341a933394673938994df8e685e88fc 100644 --- a/tests/components/alexa/test_smart_home.py +++ b/tests/components/alexa/test_smart_home.py @@ -403,12 +403,20 @@ async def test_lock(hass): "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" + _, msg = await assert_request_calls_service( + "Alexa.LockController", "Unlock", "lock#test", "lock.unlock", hass + ) + + properties = msg["context"]["properties"][0] + assert properties["name"] == "lockState" + assert properties["namespace"] == "Alexa.LockController" + assert properties["value"] == "UNLOCKED" + async def test_media_player(hass): """Test media player discovery."""