Only show zwave_js command classes that are on the node (#54794)

This commit is contained in:
Raman Gupta 2021-08-18 11:53:00 -04:00 committed by GitHub
parent a6ac55390a
commit c1595d5ceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -197,7 +197,10 @@ async def async_get_condition_capabilities(
"extra_fields": vol.Schema(
{
vol.Required(ATTR_COMMAND_CLASS): vol.In(
{cc.value: cc.name for cc in CommandClass}
{
CommandClass(cc.id).value: CommandClass(cc.id).name
for cc in sorted(node.command_classes, key=lambda cc: cc.name) # type: ignore[no-any-return]
}
),
vol.Required(ATTR_PROPERTY): cv.string,
vol.Optional(ATTR_PROPERTY_KEY): cv.string,

View File

@ -430,7 +430,18 @@ async def test_get_condition_capabilities_value(
)
assert capabilities and "extra_fields" in capabilities
cc_options = [(cc.value, cc.name) for cc in CommandClass]
cc_options = [
(133, "ASSOCIATION"),
(128, "BATTERY"),
(112, "CONFIGURATION"),
(98, "DOOR_LOCK"),
(122, "FIRMWARE_UPDATE_MD"),
(114, "MANUFACTURER_SPECIFIC"),
(113, "ALARM"),
(152, "SECURITY"),
(99, "USER_CODE"),
(134, "VERSION"),
]
assert voluptuous_serialize.convert(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer