mirror of
https://github.com/home-assistant/core.git
synced 2026-11-29 17:17:35 -04:00
Add support for zwave_js lock services (#45451)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Test the Z-Wave JS lock platform."""
|
||||
from zwave_js_server.const import ATTR_CODE_SLOT, ATTR_USERCODE
|
||||
from zwave_js_server.event import Event
|
||||
|
||||
from homeassistant.components.lock import (
|
||||
@@ -6,6 +7,11 @@ from homeassistant.components.lock import (
|
||||
SERVICE_LOCK,
|
||||
SERVICE_UNLOCK,
|
||||
)
|
||||
from homeassistant.components.zwave_js.const import DOMAIN as ZWAVE_JS_DOMAIN
|
||||
from homeassistant.components.zwave_js.lock import (
|
||||
SERVICE_CLEAR_LOCK_USERCODE,
|
||||
SERVICE_SET_LOCK_USERCODE,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_LOCKED, STATE_UNLOCKED
|
||||
|
||||
SCHLAGE_BE469_LOCK_ENTITY = "lock.touchscreen_deadbolt_current_lock_mode"
|
||||
@@ -122,3 +128,78 @@ async def test_door_lock(hass, client, lock_schlage_be469, integration):
|
||||
},
|
||||
}
|
||||
assert args["value"] == 0
|
||||
|
||||
client.async_send_command.reset_mock()
|
||||
|
||||
# Test set usercode service
|
||||
await hass.services.async_call(
|
||||
ZWAVE_JS_DOMAIN,
|
||||
SERVICE_SET_LOCK_USERCODE,
|
||||
{
|
||||
ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY,
|
||||
ATTR_CODE_SLOT: 1,
|
||||
ATTR_USERCODE: "1234",
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
assert len(client.async_send_command.call_args_list) == 1
|
||||
args = client.async_send_command.call_args[0][0]
|
||||
assert args["command"] == "node.set_value"
|
||||
assert args["nodeId"] == 20
|
||||
assert args["valueId"] == {
|
||||
"commandClassName": "User Code",
|
||||
"commandClass": 99,
|
||||
"endpoint": 0,
|
||||
"property": "userCode",
|
||||
"propertyName": "userCode",
|
||||
"propertyKey": 1,
|
||||
"propertyKeyName": "1",
|
||||
"metadata": {
|
||||
"type": "string",
|
||||
"readable": True,
|
||||
"writeable": True,
|
||||
"minLength": 4,
|
||||
"maxLength": 10,
|
||||
"label": "User Code (1)",
|
||||
},
|
||||
"value": "**********",
|
||||
}
|
||||
assert args["value"] == "1234"
|
||||
|
||||
client.async_send_command.reset_mock()
|
||||
|
||||
# Test clear usercode
|
||||
await hass.services.async_call(
|
||||
ZWAVE_JS_DOMAIN,
|
||||
SERVICE_CLEAR_LOCK_USERCODE,
|
||||
{ATTR_ENTITY_ID: SCHLAGE_BE469_LOCK_ENTITY, ATTR_CODE_SLOT: 1},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
assert len(client.async_send_command.call_args_list) == 1
|
||||
args = client.async_send_command.call_args[0][0]
|
||||
assert args["command"] == "node.set_value"
|
||||
assert args["nodeId"] == 20
|
||||
assert args["valueId"] == {
|
||||
"commandClassName": "User Code",
|
||||
"commandClass": 99,
|
||||
"endpoint": 0,
|
||||
"property": "userIdStatus",
|
||||
"propertyName": "userIdStatus",
|
||||
"propertyKey": 1,
|
||||
"propertyKeyName": "1",
|
||||
"metadata": {
|
||||
"type": "number",
|
||||
"readable": True,
|
||||
"writeable": True,
|
||||
"label": "User ID status (1)",
|
||||
"states": {
|
||||
"0": "Available",
|
||||
"1": "Enabled",
|
||||
"2": "Disabled",
|
||||
},
|
||||
},
|
||||
"value": 1,
|
||||
}
|
||||
assert args["value"] == 0
|
||||
|
||||
Reference in New Issue
Block a user