mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Update zwave_js WS APIs for provisioning (#117400)
This commit is contained in:
parent
1c2cda5033
commit
89ae425ac2
@ -116,8 +116,8 @@ ENABLED = "enabled"
|
||||
OPTED_IN = "opted_in"
|
||||
|
||||
# constants for granting security classes
|
||||
SECURITY_CLASSES = "security_classes"
|
||||
CLIENT_SIDE_AUTH = "client_side_auth"
|
||||
SECURITY_CLASSES = "securityClasses"
|
||||
CLIENT_SIDE_AUTH = "clientSideAuth"
|
||||
|
||||
# constants for inclusion
|
||||
INCLUSION_STRATEGY = "inclusion_strategy"
|
||||
@ -145,19 +145,19 @@ QR_CODE_STRING = "qr_code_string"
|
||||
DSK = "dsk"
|
||||
|
||||
VERSION = "version"
|
||||
GENERIC_DEVICE_CLASS = "generic_device_class"
|
||||
SPECIFIC_DEVICE_CLASS = "specific_device_class"
|
||||
INSTALLER_ICON_TYPE = "installer_icon_type"
|
||||
MANUFACTURER_ID = "manufacturer_id"
|
||||
PRODUCT_TYPE = "product_type"
|
||||
PRODUCT_ID = "product_id"
|
||||
APPLICATION_VERSION = "application_version"
|
||||
MAX_INCLUSION_REQUEST_INTERVAL = "max_inclusion_request_interval"
|
||||
GENERIC_DEVICE_CLASS = "genericDeviceClass"
|
||||
SPECIFIC_DEVICE_CLASS = "specificDeviceClass"
|
||||
INSTALLER_ICON_TYPE = "installerIconType"
|
||||
MANUFACTURER_ID = "manufacturerId"
|
||||
PRODUCT_TYPE = "productType"
|
||||
PRODUCT_ID = "productId"
|
||||
APPLICATION_VERSION = "applicationVersion"
|
||||
MAX_INCLUSION_REQUEST_INTERVAL = "maxInclusionRequestInterval"
|
||||
UUID = "uuid"
|
||||
SUPPORTED_PROTOCOLS = "supported_protocols"
|
||||
SUPPORTED_PROTOCOLS = "supportedProtocols"
|
||||
ADDITIONAL_PROPERTIES = "additional_properties"
|
||||
STATUS = "status"
|
||||
REQUESTED_SECURITY_CLASSES = "requested_security_classes"
|
||||
REQUESTED_SECURITY_CLASSES = "requestedSecurityClasses"
|
||||
|
||||
FEATURE = "feature"
|
||||
STRATEGY = "strategy"
|
||||
@ -183,6 +183,7 @@ def convert_planned_provisioning_entry(info: dict) -> ProvisioningEntry:
|
||||
|
||||
def convert_qr_provisioning_information(info: dict) -> QRProvisioningInformation:
|
||||
"""Convert QR provisioning information dict to QRProvisioningInformation."""
|
||||
## Remove this when we have fix for QRProvisioningInformation.from_dict()
|
||||
return QRProvisioningInformation(
|
||||
version=info[VERSION],
|
||||
security_classes=info[SECURITY_CLASSES],
|
||||
@ -199,7 +200,28 @@ def convert_qr_provisioning_information(info: dict) -> QRProvisioningInformation
|
||||
supported_protocols=info.get(SUPPORTED_PROTOCOLS),
|
||||
status=info[STATUS],
|
||||
requested_security_classes=info.get(REQUESTED_SECURITY_CLASSES),
|
||||
additional_properties=info.get(ADDITIONAL_PROPERTIES, {}),
|
||||
additional_properties={
|
||||
k: v
|
||||
for k, v in info.items()
|
||||
if k
|
||||
not in (
|
||||
VERSION,
|
||||
SECURITY_CLASSES,
|
||||
DSK,
|
||||
GENERIC_DEVICE_CLASS,
|
||||
SPECIFIC_DEVICE_CLASS,
|
||||
INSTALLER_ICON_TYPE,
|
||||
MANUFACTURER_ID,
|
||||
PRODUCT_TYPE,
|
||||
PRODUCT_ID,
|
||||
APPLICATION_VERSION,
|
||||
MAX_INCLUSION_REQUEST_INTERVAL,
|
||||
UUID,
|
||||
SUPPORTED_PROTOCOLS,
|
||||
STATUS,
|
||||
REQUESTED_SECURITY_CLASSES,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@ -253,8 +275,8 @@ QR_PROVISIONING_INFORMATION_SCHEMA = vol.All(
|
||||
vol.Optional(REQUESTED_SECURITY_CLASSES): vol.All(
|
||||
cv.ensure_list, [vol.Coerce(SecurityClass)]
|
||||
),
|
||||
vol.Optional(ADDITIONAL_PROPERTIES): dict,
|
||||
}
|
||||
},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
),
|
||||
convert_qr_provisioning_information,
|
||||
)
|
||||
@ -990,9 +1012,7 @@ async def websocket_get_provisioning_entries(
|
||||
) -> None:
|
||||
"""Get provisioning entries (entries that have been pre-provisioned)."""
|
||||
provisioning_entries = await driver.controller.async_get_provisioning_entries()
|
||||
connection.send_result(
|
||||
msg[ID], [dataclasses.asdict(entry) for entry in provisioning_entries]
|
||||
)
|
||||
connection.send_result(msg[ID], [entry.to_dict() for entry in provisioning_entries])
|
||||
|
||||
|
||||
@websocket_api.require_admin
|
||||
@ -1018,7 +1038,7 @@ async def websocket_parse_qr_code_string(
|
||||
qr_provisioning_information = await async_parse_qr_code_string(
|
||||
client, msg[QR_CODE_STRING]
|
||||
)
|
||||
connection.send_result(msg[ID], dataclasses.asdict(qr_provisioning_information))
|
||||
connection.send_result(msg[ID], qr_provisioning_information.to_dict())
|
||||
|
||||
|
||||
@websocket_api.require_admin
|
||||
|
@ -38,7 +38,6 @@ from zwave_js_server.model.value import ConfigurationValue, get_value_id_str
|
||||
|
||||
from homeassistant.components.websocket_api import ERR_INVALID_FORMAT, ERR_NOT_FOUND
|
||||
from homeassistant.components.zwave_js.api import (
|
||||
ADDITIONAL_PROPERTIES,
|
||||
APPLICATION_VERSION,
|
||||
CLIENT_SIDE_AUTH,
|
||||
COMMAND_CLASS_ID,
|
||||
@ -59,6 +58,7 @@ from homeassistant.components.zwave_js.api import (
|
||||
LEVEL,
|
||||
LOG_TO_FILE,
|
||||
MANUFACTURER_ID,
|
||||
MAX_INCLUSION_REQUEST_INTERVAL,
|
||||
NODE_ID,
|
||||
OPTED_IN,
|
||||
PIN,
|
||||
@ -74,7 +74,9 @@ from homeassistant.components.zwave_js.api import (
|
||||
SPECIFIC_DEVICE_CLASS,
|
||||
STATUS,
|
||||
STRATEGY,
|
||||
SUPPORTED_PROTOCOLS,
|
||||
TYPE,
|
||||
UUID,
|
||||
VALUE,
|
||||
VERSION,
|
||||
)
|
||||
@ -1072,7 +1074,7 @@ async def test_provision_smart_start_node(
|
||||
PRODUCT_TYPE: 1,
|
||||
PRODUCT_ID: 1,
|
||||
APPLICATION_VERSION: "test",
|
||||
ADDITIONAL_PROPERTIES: {"name": "test"},
|
||||
"name": "test",
|
||||
},
|
||||
}
|
||||
)
|
||||
@ -1331,14 +1333,7 @@ async def test_get_provisioning_entries(
|
||||
msg = await ws_client.receive_json()
|
||||
assert msg["success"]
|
||||
assert msg["result"] == [
|
||||
{
|
||||
"dsk": "test",
|
||||
"security_classes": [SecurityClass.S2_UNAUTHENTICATED],
|
||||
"requested_security_classes": None,
|
||||
"status": 0,
|
||||
"protocol": None,
|
||||
"additional_properties": {"fake": "test"},
|
||||
}
|
||||
{DSK: "test", SECURITY_CLASSES: [0], STATUS: 0, "fake": "test"}
|
||||
]
|
||||
|
||||
assert len(client.async_send_command.call_args_list) == 1
|
||||
@ -1414,23 +1409,20 @@ async def test_parse_qr_code_string(
|
||||
msg = await ws_client.receive_json()
|
||||
assert msg["success"]
|
||||
assert msg["result"] == {
|
||||
"version": 0,
|
||||
"security_classes": [SecurityClass.S2_UNAUTHENTICATED],
|
||||
"dsk": "test",
|
||||
"generic_device_class": 1,
|
||||
"specific_device_class": 1,
|
||||
"installer_icon_type": 1,
|
||||
"manufacturer_id": 1,
|
||||
"product_type": 1,
|
||||
"product_id": 1,
|
||||
"protocol": None,
|
||||
"application_version": "test",
|
||||
"max_inclusion_request_interval": 1,
|
||||
"uuid": "test",
|
||||
"supported_protocols": [Protocols.ZWAVE],
|
||||
"status": 0,
|
||||
"requested_security_classes": None,
|
||||
"additional_properties": {},
|
||||
VERSION: 0,
|
||||
SECURITY_CLASSES: [0],
|
||||
DSK: "test",
|
||||
GENERIC_DEVICE_CLASS: 1,
|
||||
SPECIFIC_DEVICE_CLASS: 1,
|
||||
INSTALLER_ICON_TYPE: 1,
|
||||
MANUFACTURER_ID: 1,
|
||||
PRODUCT_TYPE: 1,
|
||||
PRODUCT_ID: 1,
|
||||
APPLICATION_VERSION: "test",
|
||||
MAX_INCLUSION_REQUEST_INTERVAL: 1,
|
||||
UUID: "test",
|
||||
SUPPORTED_PROTOCOLS: [Protocols.ZWAVE],
|
||||
STATUS: 0,
|
||||
}
|
||||
|
||||
assert len(client.async_send_command.call_args_list) == 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user