mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Update alexa lock to support locking, unlocking, jammed (#52841)
This commit is contained in:
parent
8f61efe714
commit
4d122fc366
@ -19,6 +19,7 @@ from homeassistant.components.alarm_control_panel.const import (
|
||||
SUPPORT_ALARM_ARM_NIGHT,
|
||||
)
|
||||
import homeassistant.components.climate.const as climate
|
||||
from homeassistant.components.lock import STATE_LOCKING, STATE_UNLOCKING
|
||||
import homeassistant.components.media_player.const as media_player
|
||||
from homeassistant.const import (
|
||||
ATTR_SUPPORTED_FEATURES,
|
||||
@ -446,9 +447,11 @@ class AlexaLockController(AlexaCapability):
|
||||
if name != "lockState":
|
||||
raise UnsupportedProperty(name)
|
||||
|
||||
if self.entity.state == STATE_LOCKED:
|
||||
# If its unlocking its still locked and not unlocked yet
|
||||
if self.entity.state in (STATE_UNLOCKING, STATE_LOCKED):
|
||||
return "LOCKED"
|
||||
if self.entity.state == STATE_UNLOCKED:
|
||||
# If its locking its still unlocked and not locked yet
|
||||
if self.entity.state in (STATE_LOCKING, STATE_UNLOCKED):
|
||||
return "UNLOCKED"
|
||||
return "JAMMED"
|
||||
|
||||
|
@ -6,6 +6,7 @@ import pytest
|
||||
from homeassistant.components.alexa import smart_home
|
||||
from homeassistant.components.alexa.errors import UnsupportedProperty
|
||||
from homeassistant.components.climate import const as climate
|
||||
from homeassistant.components.lock import STATE_JAMMED, STATE_LOCKING, STATE_UNLOCKING
|
||||
from homeassistant.components.media_player.const import (
|
||||
SUPPORT_PAUSE,
|
||||
SUPPORT_PLAY,
|
||||
@ -227,17 +228,29 @@ async def test_report_lock_state(hass):
|
||||
"""Test LockController implements lockState property."""
|
||||
hass.states.async_set("lock.locked", STATE_LOCKED, {})
|
||||
hass.states.async_set("lock.unlocked", STATE_UNLOCKED, {})
|
||||
hass.states.async_set("lock.unlocking", STATE_UNLOCKING, {})
|
||||
hass.states.async_set("lock.locking", STATE_LOCKING, {})
|
||||
hass.states.async_set("lock.jammed", STATE_JAMMED, {})
|
||||
hass.states.async_set("lock.unknown", STATE_UNKNOWN, {})
|
||||
|
||||
properties = await reported_properties(hass, "lock.locked")
|
||||
properties.assert_equal("Alexa.LockController", "lockState", "LOCKED")
|
||||
|
||||
properties = await reported_properties(hass, "lock.unlocking")
|
||||
properties.assert_equal("Alexa.LockController", "lockState", "LOCKED")
|
||||
|
||||
properties = await reported_properties(hass, "lock.unlocked")
|
||||
properties.assert_equal("Alexa.LockController", "lockState", "UNLOCKED")
|
||||
|
||||
properties = await reported_properties(hass, "lock.locking")
|
||||
properties.assert_equal("Alexa.LockController", "lockState", "UNLOCKED")
|
||||
|
||||
properties = await reported_properties(hass, "lock.unknown")
|
||||
properties.assert_equal("Alexa.LockController", "lockState", "JAMMED")
|
||||
|
||||
properties = await reported_properties(hass, "lock.jammed")
|
||||
properties.assert_equal("Alexa.LockController", "lockState", "JAMMED")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"supported_color_modes", [["brightness"], ["hs"], ["color_temp"]]
|
||||
|
Loading…
x
Reference in New Issue
Block a user