Update voluptuous-serialize to 2.7.0 (#150822)

This commit is contained in:
Matthias Alphart
2025-08-19 16:42:49 +02:00
committed by GitHub
parent f4400516b8
commit 63640af4d4
46 changed files with 519 additions and 136 deletions

View File

@@ -199,23 +199,19 @@ class AuthProvidersView(HomeAssistantView):
) )
def _prepare_result_json( def _prepare_result_json(result: AuthFlowResult) -> dict[str, Any]:
result: AuthFlowResult, """Convert result to JSON serializable dict."""
) -> AuthFlowResult:
"""Convert result to JSON."""
if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY: if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY:
data = result.copy() return {
data.pop("result") key: val for key, val in result.items() if key not in ("result", "data")
data.pop("data") }
return data
if result["type"] != data_entry_flow.FlowResultType.FORM: if result["type"] != data_entry_flow.FlowResultType.FORM:
return result return result # type: ignore[return-value]
data = result.copy() data = dict(result)
if (schema := result["data_schema"]) is None:
if (schema := data["data_schema"]) is None: data["data_schema"] = []
data["data_schema"] = [] # type: ignore[typeddict-item] # json result type
else: else:
data["data_schema"] = voluptuous_serialize.convert(schema) data["data_schema"] = voluptuous_serialize.convert(schema)

View File

@@ -149,20 +149,16 @@ def websocket_depose_mfa(
hass.async_create_task(async_depose(msg)) hass.async_create_task(async_depose(msg))
def _prepare_result_json( def _prepare_result_json(result: data_entry_flow.FlowResult) -> dict[str, Any]:
result: data_entry_flow.FlowResult, """Convert result to JSON serializable dict."""
) -> data_entry_flow.FlowResult:
"""Convert result to JSON."""
if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY: if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY:
return result.copy() return dict(result)
if result["type"] != data_entry_flow.FlowResultType.FORM: if result["type"] != data_entry_flow.FlowResultType.FORM:
return result return result # type: ignore[return-value]
data = result.copy() data = dict(result)
if (schema := result["data_schema"]) is None:
if (schema := data["data_schema"]) is None: data["data_schema"] = []
data["data_schema"] = [] # type: ignore[typeddict-item] # json result type
else: else:
data["data_schema"] = voluptuous_serialize.convert(schema) data["data_schema"] = voluptuous_serialize.convert(schema)

View File

@@ -137,20 +137,16 @@ class ConfigManagerEntryResourceReloadView(HomeAssistantView):
def _prepare_config_flow_result_json( def _prepare_config_flow_result_json(
result: data_entry_flow.FlowResult, result: data_entry_flow.FlowResult,
prepare_result_json: Callable[ prepare_result_json: Callable[[data_entry_flow.FlowResult], dict[str, Any]],
[data_entry_flow.FlowResult], data_entry_flow.FlowResult ) -> dict[str, Any]:
],
) -> data_entry_flow.FlowResult:
"""Convert result to JSON.""" """Convert result to JSON."""
if result["type"] != data_entry_flow.FlowResultType.CREATE_ENTRY: if result["type"] != data_entry_flow.FlowResultType.CREATE_ENTRY:
return prepare_result_json(result) return prepare_result_json(result)
data = result.copy() data = {key: val for key, val in result.items() if key not in ("data", "context")}
entry: config_entries.ConfigEntry = data["result"] # type: ignore[typeddict-item] entry: config_entries.ConfigEntry = result["result"] # type: ignore[typeddict-item]
# We overwrite the ConfigEntry object with its json representation. # We overwrite the ConfigEntry object with its json representation.
data["result"] = entry.as_json_fragment # type: ignore[typeddict-unknown-key] data["result"] = entry.as_json_fragment
data.pop("data")
data.pop("context")
return data return data
@@ -204,8 +200,8 @@ class ConfigManagerFlowIndexView(
def _prepare_result_json( def _prepare_result_json(
self, result: data_entry_flow.FlowResult self, result: data_entry_flow.FlowResult
) -> data_entry_flow.FlowResult: ) -> dict[str, Any]:
"""Convert result to JSON.""" """Convert result to JSON serializable dict."""
return _prepare_config_flow_result_json(result, super()._prepare_result_json) return _prepare_config_flow_result_json(result, super()._prepare_result_json)
@@ -229,8 +225,8 @@ class ConfigManagerFlowResourceView(
def _prepare_result_json( def _prepare_result_json(
self, result: data_entry_flow.FlowResult self, result: data_entry_flow.FlowResult
) -> data_entry_flow.FlowResult: ) -> dict[str, Any]:
"""Convert result to JSON.""" """Convert result to JSON serializable dict."""
return _prepare_config_flow_result_json(result, super()._prepare_result_json) return _prepare_config_flow_result_json(result, super()._prepare_result_json)

View File

@@ -137,9 +137,9 @@ class RepairsFlowIndexView(FlowManagerIndexView):
"Handler does not support user", HTTPStatus.BAD_REQUEST "Handler does not support user", HTTPStatus.BAD_REQUEST
) )
result = self._prepare_result_json(result) return self.json(
self._prepare_result_json(result),
return self.json(result) )
class RepairsFlowResourceView(FlowManagerResourceView): class RepairsFlowResourceView(FlowManagerResourceView):

View File

@@ -31,27 +31,27 @@ class _BaseFlowManagerView(HomeAssistantView, Generic[_FlowManagerT]):
def _prepare_result_json( def _prepare_result_json(
self, result: data_entry_flow.FlowResult self, result: data_entry_flow.FlowResult
) -> data_entry_flow.FlowResult: ) -> dict[str, Any]:
"""Convert result to JSON.""" """Convert result to JSON serializable dict."""
if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY: if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY:
data = result.copy()
assert "result" not in result assert "result" not in result
data.pop("data") return {
data.pop("context") key: val
return data for key, val in result.items()
if key not in ("data", "context")
}
data = dict(result)
if "data_schema" not in result: if "data_schema" not in result:
return result return data
data = result.copy() if (schema := result["data_schema"]) is None:
data["data_schema"] = []
if (schema := data["data_schema"]) is None:
data["data_schema"] = [] # type: ignore[typeddict-item] # json result type
else: else:
data["data_schema"] = voluptuous_serialize.convert( data["data_schema"] = voluptuous_serialize.convert(
schema, custom_serializer=cv.custom_serializer schema, custom_serializer=cv.custom_serializer
) )
return data return data

View File

@@ -70,7 +70,7 @@ ulid-transform==1.4.0
urllib3>=2.0 urllib3>=2.0
uv==0.8.9 uv==0.8.9
voluptuous-openapi==0.1.0 voluptuous-openapi==0.1.0
voluptuous-serialize==2.6.0 voluptuous-serialize==2.7.0
voluptuous==0.15.2 voluptuous==0.15.2
webrtc-models==0.3.0 webrtc-models==0.3.0
yarl==1.20.1 yarl==1.20.1

View File

@@ -76,7 +76,7 @@ dependencies = [
"urllib3>=2.0", "urllib3>=2.0",
"uv==0.8.9", "uv==0.8.9",
"voluptuous==0.15.2", "voluptuous==0.15.2",
"voluptuous-serialize==2.6.0", "voluptuous-serialize==2.7.0",
"voluptuous-openapi==0.1.0", "voluptuous-openapi==0.1.0",
"yarl==1.20.1", "yarl==1.20.1",
"webrtc-models==0.3.0", "webrtc-models==0.3.0",

2
requirements.txt generated
View File

@@ -48,7 +48,7 @@ ulid-transform==1.4.0
urllib3>=2.0 urllib3>=2.0
uv==0.8.9 uv==0.8.9
voluptuous==0.15.2 voluptuous==0.15.2
voluptuous-serialize==2.6.0 voluptuous-serialize==2.7.0
voluptuous-openapi==0.1.0 voluptuous-openapi==0.1.0
yarl==1.20.1 yarl==1.20.1
webrtc-models==0.3.0 webrtc-models==0.3.0

View File

@@ -245,7 +245,9 @@ async def test_get_action_capabilities(
"arm_night": {"extra_fields": []}, "arm_night": {"extra_fields": []},
"arm_vacation": {"extra_fields": []}, "arm_vacation": {"extra_fields": []},
"disarm": { "disarm": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"trigger": {"extra_fields": []}, "trigger": {"extra_fields": []},
} }
@@ -293,7 +295,9 @@ async def test_get_action_capabilities_legacy(
"arm_night": {"extra_fields": []}, "arm_night": {"extra_fields": []},
"arm_vacation": {"extra_fields": []}, "arm_vacation": {"extra_fields": []},
"disarm": { "disarm": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"trigger": {"extra_fields": []}, "trigger": {"extra_fields": []},
} }
@@ -338,19 +342,29 @@ async def test_get_action_capabilities_arm_code(
expected_capabilities = { expected_capabilities = {
"arm_away": { "arm_away": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"arm_home": { "arm_home": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"arm_night": { "arm_night": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"arm_vacation": { "arm_vacation": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"disarm": { "disarm": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"trigger": {"extra_fields": []}, "trigger": {"extra_fields": []},
} }
@@ -394,19 +408,29 @@ async def test_get_action_capabilities_arm_code_legacy(
expected_capabilities = { expected_capabilities = {
"arm_away": { "arm_away": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"arm_home": { "arm_home": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"arm_night": { "arm_night": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"arm_vacation": { "arm_vacation": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"disarm": { "disarm": {
"extra_fields": [{"name": "code", "optional": True, "type": "string"}] "extra_fields": [
{"name": "code", "optional": True, "required": False, "type": "string"}
]
}, },
"trigger": {"extra_fields": []}, "trigger": {"extra_fields": []},
} }

View File

@@ -191,7 +191,12 @@ async def test_get_trigger_capabilities(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
@@ -226,7 +231,12 @@ async def test_get_trigger_capabilities_legacy(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }

View File

@@ -182,7 +182,12 @@ async def test_get_condition_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
@@ -212,7 +217,12 @@ async def test_get_condition_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
conditions = await async_get_device_automations( conditions = await async_get_device_automations(

View File

@@ -185,7 +185,12 @@ async def test_get_trigger_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
@@ -215,7 +220,12 @@ async def test_get_trigger_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(

View File

@@ -354,7 +354,12 @@ async def test_get_trigger_capabilities_hvac_mode(hass: HomeAssistant) -> None:
"required": True, "required": True,
"type": "select", "type": "select",
}, },
{"name": "for", "optional": True, "type": "positive_time_period_dict"}, {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
},
] ]
@@ -389,13 +394,20 @@ async def test_get_trigger_capabilities_temp_humid(
"description": {"suffix": suffix}, "description": {"suffix": suffix},
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
{ {
"description": {"suffix": suffix}, "description": {"suffix": suffix},
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
{"name": "for", "optional": True, "type": "positive_time_period_dict"}, {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
},
] ]

View File

@@ -625,7 +625,9 @@ async def test_two_step_flow(hass: HomeAssistant, client: TestClient) -> None:
"type": "form", "type": "form",
"handler": "test", "handler": "test",
"step_id": "account", "step_id": "account",
"data_schema": [{"name": "user_title", "type": "string"}], "data_schema": [
{"name": "user_title", "required": False, "type": "string"}
],
"description_placeholders": None, "description_placeholders": None,
"errors": None, "errors": None,
"last_step": None, "last_step": None,
@@ -712,7 +714,9 @@ async def test_continue_flow_unauth(
"type": "form", "type": "form",
"handler": "test", "handler": "test",
"step_id": "account", "step_id": "account",
"data_schema": [{"name": "user_title", "type": "string"}], "data_schema": [
{"name": "user_title", "required": False, "type": "string"}
],
"description_placeholders": None, "description_placeholders": None,
"errors": None, "errors": None,
"last_step": None, "last_step": None,
@@ -1272,7 +1276,7 @@ async def test_two_step_options_flow(hass: HomeAssistant, client: TestClient) ->
"type": "form", "type": "form",
"handler": "test1", "handler": "test1",
"step_id": "finish", "step_id": "finish",
"data_schema": [{"name": "enabled", "type": "boolean"}], "data_schema": [{"name": "enabled", "required": False, "type": "boolean"}],
"description_placeholders": None, "description_placeholders": None,
"errors": None, "errors": None,
"last_step": None, "last_step": None,
@@ -1581,7 +1585,7 @@ async def test_subentry_flow_abort_duplicate(hass: HomeAssistant, client) -> Non
"type": "form", "type": "form",
"handler": ["test1", "test"], "handler": ["test1", "test"],
"step_id": "finish", "step_id": "finish",
"data_schema": [{"name": "enabled", "type": "boolean"}], "data_schema": [{"name": "enabled", "required": False, "type": "boolean"}],
"description_placeholders": None, "description_placeholders": None,
"errors": None, "errors": None,
"last_step": None, "last_step": None,
@@ -1749,7 +1753,7 @@ async def test_two_step_subentry_flow(hass: HomeAssistant, client) -> None:
data = await resp.json() data = await resp.json()
flow_id = data["flow_id"] flow_id = data["flow_id"]
expected_data = { expected_data = {
"data_schema": [{"name": "enabled", "type": "boolean"}], "data_schema": [{"name": "enabled", "required": False, "type": "boolean"}],
"description_placeholders": None, "description_placeholders": None,
"errors": None, "errors": None,
"flow_id": flow_id, "flow_id": flow_id,

View File

@@ -260,6 +260,7 @@ async def test_get_action_capabilities_set_pos(
{ {
"name": "position", "name": "position",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 0, "default": 0,
"valueMax": 100, "valueMax": 100,
@@ -310,6 +311,7 @@ async def test_get_action_capabilities_set_tilt_pos(
{ {
"name": "position", "name": "position",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 0, "default": 0,
"valueMax": 100, "valueMax": 100,

View File

@@ -254,6 +254,7 @@ async def test_get_condition_capabilities_set_pos(
{ {
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 0, "default": 0,
"valueMax": 100, "valueMax": 100,
@@ -262,6 +263,7 @@ async def test_get_condition_capabilities_set_pos(
{ {
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 100, "default": 100,
"valueMax": 100, "valueMax": 100,
@@ -311,6 +313,7 @@ async def test_get_condition_capabilities_set_tilt_pos(
{ {
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 0, "default": 0,
"valueMax": 100, "valueMax": 100,
@@ -319,6 +322,7 @@ async def test_get_condition_capabilities_set_tilt_pos(
{ {
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 100, "default": 100,
"valueMax": 100, "valueMax": 100,

View File

@@ -192,7 +192,12 @@ async def test_get_trigger_capabilities(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
@@ -230,7 +235,12 @@ async def test_get_trigger_capabilities_legacy(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
@@ -262,6 +272,7 @@ async def test_get_trigger_capabilities_set_pos(
{ {
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 0, "default": 0,
"valueMax": 100, "valueMax": 100,
@@ -270,6 +281,7 @@ async def test_get_trigger_capabilities_set_pos(
{ {
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 100, "default": 100,
"valueMax": 100, "valueMax": 100,
@@ -293,6 +305,7 @@ async def test_get_trigger_capabilities_set_pos(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
] ]
@@ -326,6 +339,7 @@ async def test_get_trigger_capabilities_set_tilt_pos(
{ {
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 0, "default": 0,
"valueMax": 100, "valueMax": 100,
@@ -334,6 +348,7 @@ async def test_get_trigger_capabilities_set_tilt_pos(
{ {
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"default": 100, "default": 100,
"valueMax": 100, "valueMax": 100,
@@ -357,6 +372,7 @@ async def test_get_trigger_capabilities_set_tilt_pos(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
] ]

View File

@@ -293,7 +293,9 @@ async def test_websocket_get_action_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"turn_on": { "turn_on": {
"extra_fields": [{"type": "string", "name": "code", "optional": True}] "extra_fields": [
{"type": "string", "name": "code", "optional": True, "required": False}
]
}, },
"turn_off": {"extra_fields": []}, "turn_off": {"extra_fields": []},
"toggle": {"extra_fields": []}, "toggle": {"extra_fields": []},
@@ -452,7 +454,12 @@ async def test_websocket_get_condition_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
@@ -745,7 +752,12 @@ async def test_websocket_get_trigger_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }

View File

@@ -125,7 +125,12 @@ async def test_get_trigger_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
@@ -155,7 +160,12 @@ async def test_get_trigger_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(

View File

@@ -180,6 +180,7 @@ async def test_supervisor_issue_repair_flow_with_multiple_suggestions(
["system_execute_reboot", "system_execute_reboot"], ["system_execute_reboot", "system_execute_reboot"],
["system_test_type", "system_test_type"], ["system_test_type", "system_test_type"],
], ],
"required": False,
"name": "next_step_id", "name": "next_step_id",
} }
], ],
@@ -275,6 +276,7 @@ async def test_supervisor_issue_repair_flow_with_multiple_suggestions_and_confir
["system_execute_reboot", "system_execute_reboot"], ["system_execute_reboot", "system_execute_reboot"],
["system_test_type", "system_test_type"], ["system_test_type", "system_test_type"],
], ],
"required": False,
"name": "next_step_id", "name": "next_step_id",
} }
], ],
@@ -545,6 +547,7 @@ async def test_mount_failed_repair_flow(
["mount_execute_reload", "mount_execute_reload"], ["mount_execute_reload", "mount_execute_reload"],
["mount_execute_remove", "mount_execute_remove"], ["mount_execute_remove", "mount_execute_remove"],
], ],
"required": False,
"name": "next_step_id", "name": "next_step_id",
} }
], ],
@@ -756,6 +759,7 @@ async def test_supervisor_issue_repair_flow_multiple_data_disks(
["system_rename_data_disk", "system_rename_data_disk"], ["system_rename_data_disk", "system_rename_data_disk"],
["system_adopt_data_disk", "system_adopt_data_disk"], ["system_adopt_data_disk", "system_adopt_data_disk"],
], ],
"required": False,
"name": "next_step_id", "name": "next_step_id",
} }
], ],
@@ -960,6 +964,7 @@ async def test_supervisor_issue_addon_boot_fail(
["addon_execute_start", "addon_execute_start"], ["addon_execute_start", "addon_execute_start"],
["addon_disable_boot", "addon_disable_boot"], ["addon_disable_boot", "addon_disable_boot"],
], ],
"required": False,
"name": "next_step_id", "name": "next_step_id",
} }
], ],

View File

@@ -363,6 +363,7 @@ async def test_if_state_legacy(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
], ],
@@ -376,6 +377,7 @@ async def test_if_state_legacy(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
], ],
@@ -417,6 +419,7 @@ async def test_if_state_legacy(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
], ],
@@ -430,6 +433,7 @@ async def test_if_state_legacy(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
], ],
@@ -533,6 +537,7 @@ async def test_capabilities(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
], ],
@@ -546,6 +551,7 @@ async def test_capabilities(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
], ],
@@ -587,6 +593,7 @@ async def test_capabilities(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
], ],
@@ -600,6 +607,7 @@ async def test_capabilities(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
} }
], ],

View File

@@ -543,7 +543,14 @@ async def test_get_trigger_capabilities_on(hass: HomeAssistant) -> None:
assert voluptuous_serialize.convert( assert voluptuous_serialize.convert(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer capabilities["extra_fields"], custom_serializer=cv.custom_serializer
) == [{"name": "for", "optional": True, "type": "positive_time_period_dict"}] ) == [
{
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
]
async def test_get_trigger_capabilities_off(hass: HomeAssistant) -> None: async def test_get_trigger_capabilities_off(hass: HomeAssistant) -> None:
@@ -563,7 +570,14 @@ async def test_get_trigger_capabilities_off(hass: HomeAssistant) -> None:
assert voluptuous_serialize.convert( assert voluptuous_serialize.convert(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer capabilities["extra_fields"], custom_serializer=cv.custom_serializer
) == [{"name": "for", "optional": True, "type": "positive_time_period_dict"}] ) == [
{
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
]
async def test_get_trigger_capabilities_humidity(hass: HomeAssistant) -> None: async def test_get_trigger_capabilities_humidity(hass: HomeAssistant) -> None:
@@ -588,13 +602,20 @@ async def test_get_trigger_capabilities_humidity(hass: HomeAssistant) -> None:
"description": {"suffix": "%"}, "description": {"suffix": "%"},
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
}, },
{ {
"description": {"suffix": "%"}, "description": {"suffix": "%"},
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
}, },
{"name": "for", "optional": True, "type": "positive_time_period_dict"}, {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
},
] ]

View File

@@ -301,6 +301,7 @@ async def test_get_trigger_capabilities(
{ {
"name": "destination", "name": "destination",
"optional": True, "optional": True,
"required": False,
"selector": { "selector": {
"select": { "select": {
"custom_value": True, "custom_value": True,
@@ -314,6 +315,7 @@ async def test_get_trigger_capabilities(
{ {
"name": "group_value_write", "name": "group_value_write",
"optional": True, "optional": True,
"required": False,
"default": True, "default": True,
"selector": { "selector": {
"boolean": {}, "boolean": {},
@@ -322,6 +324,7 @@ async def test_get_trigger_capabilities(
{ {
"name": "group_value_response", "name": "group_value_response",
"optional": True, "optional": True,
"required": False,
"default": True, "default": True,
"selector": { "selector": {
"boolean": {}, "boolean": {},
@@ -330,6 +333,7 @@ async def test_get_trigger_capabilities(
{ {
"name": "group_value_read", "name": "group_value_read",
"optional": True, "optional": True,
"required": False,
"default": True, "default": True,
"selector": { "selector": {
"boolean": {}, "boolean": {},
@@ -338,6 +342,7 @@ async def test_get_trigger_capabilities(
{ {
"name": "incoming", "name": "incoming",
"optional": True, "optional": True,
"required": False,
"default": True, "default": True,
"selector": { "selector": {
"boolean": {}, "boolean": {},
@@ -346,6 +351,7 @@ async def test_get_trigger_capabilities(
{ {
"name": "outgoing", "name": "outgoing",
"optional": True, "optional": True,
"required": False,
"default": True, "default": True,
"selector": { "selector": {
"boolean": {}, "boolean": {},

View File

@@ -349,7 +349,15 @@ async def test_get_transponder_trigger_capabilities(
assert voluptuous_serialize.convert( assert voluptuous_serialize.convert(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer capabilities["extra_fields"], custom_serializer=cv.custom_serializer
) == [{"name": "code", "optional": True, "type": "string", "lower": True}] ) == [
{
"name": "code",
"optional": True,
"required": False,
"type": "string",
"lower": True,
}
]
async def test_get_fingerprint_trigger_capabilities( async def test_get_fingerprint_trigger_capabilities(
@@ -373,7 +381,15 @@ async def test_get_fingerprint_trigger_capabilities(
assert voluptuous_serialize.convert( assert voluptuous_serialize.convert(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer capabilities["extra_fields"], custom_serializer=cv.custom_serializer
) == [{"name": "code", "optional": True, "type": "string", "lower": True}] ) == [
{
"name": "code",
"optional": True,
"required": False,
"type": "string",
"lower": True,
}
]
async def test_get_transmitter_trigger_capabilities( async def test_get_transmitter_trigger_capabilities(
@@ -398,13 +414,32 @@ async def test_get_transmitter_trigger_capabilities(
assert voluptuous_serialize.convert( assert voluptuous_serialize.convert(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer capabilities["extra_fields"], custom_serializer=cv.custom_serializer
) == [ ) == [
{"name": "code", "type": "string", "optional": True, "lower": True}, {
{"name": "level", "type": "integer", "optional": True, "valueMin": 0}, "name": "code",
{"name": "key", "type": "integer", "optional": True, "valueMin": 0}, "type": "string",
"optional": True,
"required": False,
"lower": True,
},
{
"name": "level",
"type": "integer",
"optional": True,
"required": False,
"valueMin": 0,
},
{
"name": "key",
"type": "integer",
"optional": True,
"required": False,
"valueMin": 0,
},
{ {
"name": "action", "name": "action",
"type": "select", "type": "select",
"optional": True, "optional": True,
"required": False,
"options": [("hit", "hit"), ("make", "make"), ("break", "break")], "options": [("hit", "hit"), ("make", "make"), ("break", "break")],
}, },
] ]
@@ -436,6 +471,7 @@ async def test_get_send_keys_trigger_capabilities(
"name": "key", "name": "key",
"type": "select", "type": "select",
"optional": True, "optional": True,
"required": False,
"options": [(send_key.lower(), send_key.lower()) for send_key in SENDKEYS], "options": [(send_key.lower(), send_key.lower()) for send_key in SENDKEYS],
}, },
{ {
@@ -445,6 +481,7 @@ async def test_get_send_keys_trigger_capabilities(
(key_action.lower(), key_action.lower()) for key_action in KEY_ACTIONS (key_action.lower(), key_action.lower()) for key_action in KEY_ACTIONS
], ],
"optional": True, "optional": True,
"required": False,
}, },
] ]

View File

@@ -194,6 +194,7 @@ async def test_get_action_capabilities(
{ {
"name": "brightness_pct", "name": "brightness_pct",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
"valueMax": 100, "valueMax": 100,
"valueMin": 0, "valueMin": 0,
@@ -219,6 +220,7 @@ async def test_get_action_capabilities(
{ {
"name": "brightness_pct", "name": "brightness_pct",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
"valueMax": 100, "valueMax": 100,
"valueMin": 0, "valueMin": 0,
@@ -238,6 +240,7 @@ async def test_get_action_capabilities(
{ {
"name": "flash", "name": "flash",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [("short", "short"), ("long", "long")], "options": [("short", "short"), ("long", "long")],
} }
@@ -256,6 +259,7 @@ async def test_get_action_capabilities(
{ {
"name": "flash", "name": "flash",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [("short", "short"), ("long", "long")], "options": [("short", "short"), ("long", "long")],
} }
@@ -341,6 +345,7 @@ async def test_get_action_capabilities_features(
{ {
"name": "brightness_pct", "name": "brightness_pct",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
"valueMax": 100, "valueMax": 100,
"valueMin": 0, "valueMin": 0,
@@ -366,6 +371,7 @@ async def test_get_action_capabilities_features(
{ {
"name": "brightness_pct", "name": "brightness_pct",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
"valueMax": 100, "valueMax": 100,
"valueMin": 0, "valueMin": 0,
@@ -385,6 +391,7 @@ async def test_get_action_capabilities_features(
{ {
"name": "flash", "name": "flash",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [("short", "short"), ("long", "long")], "options": [("short", "short"), ("long", "long")],
} }
@@ -403,6 +410,7 @@ async def test_get_action_capabilities_features(
{ {
"name": "flash", "name": "flash",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [("short", "short"), ("long", "long")], "options": [("short", "short"), ("long", "long")],
} }

View File

@@ -128,7 +128,12 @@ async def test_get_condition_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
@@ -158,7 +163,12 @@ async def test_get_condition_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
conditions = await async_get_device_automations( conditions = await async_get_device_automations(

View File

@@ -133,7 +133,12 @@ async def test_get_trigger_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
@@ -163,7 +168,12 @@ async def test_get_trigger_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(

View File

@@ -155,7 +155,12 @@ async def test_get_trigger_capabilities(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
@@ -187,7 +192,12 @@ async def test_get_trigger_capabilities_legacy(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }

View File

@@ -161,7 +161,12 @@ async def test_get_trigger_capabilities(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
@@ -193,7 +198,12 @@ async def test_get_trigger_capabilities_legacy(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }

View File

@@ -125,7 +125,12 @@ async def test_get_condition_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
@@ -155,7 +160,12 @@ async def test_get_condition_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
conditions = await async_get_device_automations( conditions = await async_get_device_automations(

View File

@@ -125,7 +125,12 @@ async def test_get_trigger_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
@@ -155,7 +160,12 @@ async def test_get_trigger_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(

View File

@@ -376,6 +376,7 @@ async def test_get_action_capabilities(
{ {
"name": "cycle", "name": "cycle",
"optional": True, "optional": True,
"required": False,
"type": "boolean", "type": "boolean",
"default": True, "default": True,
}, },
@@ -391,6 +392,7 @@ async def test_get_action_capabilities(
{ {
"name": "cycle", "name": "cycle",
"optional": True, "optional": True,
"required": False,
"type": "boolean", "type": "boolean",
"default": True, "default": True,
}, },
@@ -476,6 +478,7 @@ async def test_get_action_capabilities_legacy(
{ {
"name": "cycle", "name": "cycle",
"optional": True, "optional": True,
"required": False,
"type": "boolean", "type": "boolean",
"default": True, "default": True,
}, },
@@ -491,6 +494,7 @@ async def test_get_action_capabilities_legacy(
{ {
"name": "cycle", "name": "cycle",
"optional": True, "optional": True,
"required": False,
"type": "boolean", "type": "boolean",
"default": True, "default": True,
}, },

View File

@@ -276,6 +276,7 @@ async def test_get_condition_capabilities(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
}, },
] ]
@@ -301,6 +302,7 @@ async def test_get_condition_capabilities(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
}, },
] ]
@@ -336,6 +338,7 @@ async def test_get_condition_capabilities_legacy(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
}, },
] ]
@@ -361,6 +364,7 @@ async def test_get_condition_capabilities_legacy(
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
}, },
] ]

View File

@@ -310,18 +310,21 @@ async def test_get_trigger_capabilities(
{ {
"name": "from", "name": "from",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [], "options": [],
}, },
{ {
"name": "to", "name": "to",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [], "options": [],
}, },
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
}, },
] ]
@@ -341,18 +344,21 @@ async def test_get_trigger_capabilities(
{ {
"name": "from", "name": "from",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [("option1", "option1"), ("option2", "option2")], "options": [("option1", "option1"), ("option2", "option2")],
}, },
{ {
"name": "to", "name": "to",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [("option1", "option1"), ("option2", "option2")], "options": [("option1", "option1"), ("option2", "option2")],
}, },
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
}, },
] ]
@@ -380,18 +386,21 @@ async def test_get_trigger_capabilities_unknown(
{ {
"name": "from", "name": "from",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [], "options": [],
}, },
{ {
"name": "to", "name": "to",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [], "options": [],
}, },
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
}, },
] ]
@@ -421,18 +430,21 @@ async def test_get_trigger_capabilities_legacy(
{ {
"name": "from", "name": "from",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [], "options": [],
}, },
{ {
"name": "to", "name": "to",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [], "options": [],
}, },
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
}, },
] ]
@@ -452,18 +464,21 @@ async def test_get_trigger_capabilities_legacy(
{ {
"name": "from", "name": "from",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [("option1", "option1"), ("option2", "option2")], "options": [("option1", "option1"), ("option2", "option2")],
}, },
{ {
"name": "to", "name": "to",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [("option1", "option1"), ("option2", "option2")], "options": [("option1", "option1"), ("option2", "option2")],
}, },
{ {
"name": "for", "name": "for",
"optional": True, "optional": True,
"required": False,
"type": "positive_time_period_dict", "type": "positive_time_period_dict",
}, },
] ]

View File

@@ -329,12 +329,14 @@ async def test_get_condition_capabilities(
"description": {"suffix": PERCENTAGE}, "description": {"suffix": PERCENTAGE},
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
{ {
"description": {"suffix": PERCENTAGE}, "description": {"suffix": PERCENTAGE},
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
] ]
@@ -398,12 +400,14 @@ async def test_get_condition_capabilities_legacy(
"description": {"suffix": PERCENTAGE}, "description": {"suffix": PERCENTAGE},
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
{ {
"description": {"suffix": PERCENTAGE}, "description": {"suffix": PERCENTAGE},
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
] ]

View File

@@ -277,15 +277,22 @@ async def test_get_trigger_capabilities(
"description": {"suffix": PERCENTAGE}, "description": {"suffix": PERCENTAGE},
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
{ {
"description": {"suffix": PERCENTAGE}, "description": {"suffix": PERCENTAGE},
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
{"name": "for", "optional": True, "type": "positive_time_period_dict"}, {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
},
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
@@ -347,15 +354,22 @@ async def test_get_trigger_capabilities_legacy(
"description": {"suffix": PERCENTAGE}, "description": {"suffix": PERCENTAGE},
"name": "above", "name": "above",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
{ {
"description": {"suffix": PERCENTAGE}, "description": {"suffix": PERCENTAGE},
"name": "below", "name": "below",
"optional": True, "optional": True,
"required": False,
"type": "float", "type": "float",
}, },
{"name": "for", "optional": True, "type": "positive_time_period_dict"}, {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
},
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(

View File

@@ -125,7 +125,12 @@ async def test_get_condition_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
conditions = await async_get_device_automations( conditions = await async_get_device_automations(
@@ -155,7 +160,12 @@ async def test_get_condition_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
conditions = await async_get_device_automations( conditions = await async_get_device_automations(

View File

@@ -125,7 +125,12 @@ async def test_get_trigger_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
@@ -155,7 +160,12 @@ async def test_get_trigger_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(

View File

@@ -127,7 +127,12 @@ async def test_get_trigger_capabilities(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(
@@ -157,7 +162,12 @@ async def test_get_trigger_capabilities_legacy(
) )
expected_capabilities = { expected_capabilities = {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
triggers = await async_get_device_automations( triggers = await async_get_device_automations(

View File

@@ -134,7 +134,12 @@ async def test_get_trigger_capabilities(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }
@@ -166,7 +171,12 @@ async def test_get_trigger_capabilities_legacy(
) )
assert capabilities == { assert capabilities == {
"extra_fields": [ "extra_fields": [
{"name": "for", "optional": True, "type": "positive_time_period_dict"} {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
}
] ]
} }

View File

@@ -9,6 +9,7 @@ BASE_CUSTOM_CONFIGURATION = {
"valueMax": 6553.6, "valueMax": 6553.6,
"name": "default_light_transition", "name": "default_light_transition",
"optional": True, "optional": True,
"required": False,
"default": 0, "default": 0,
}, },
{ {
@@ -40,6 +41,7 @@ BASE_CUSTOM_CONFIGURATION = {
"valueMin": 0, "valueMin": 0,
"name": "consider_unavailable_mains", "name": "consider_unavailable_mains",
"optional": True, "optional": True,
"required": False,
"default": 7200, "default": 7200,
}, },
{ {
@@ -47,6 +49,7 @@ BASE_CUSTOM_CONFIGURATION = {
"valueMin": 0, "valueMin": 0,
"name": "consider_unavailable_battery", "name": "consider_unavailable_battery",
"optional": True, "optional": True,
"required": False,
"default": 21600, "default": 21600,
}, },
{ {
@@ -80,6 +83,7 @@ CONFIG_WITH_ALARM_OPTIONS = {
"valueMax": 6553.6, "valueMax": 6553.6,
"name": "default_light_transition", "name": "default_light_transition",
"optional": True, "optional": True,
"required": False,
"default": 0, "default": 0,
}, },
{ {
@@ -111,6 +115,7 @@ CONFIG_WITH_ALARM_OPTIONS = {
"valueMin": 0, "valueMin": 0,
"name": "consider_unavailable_mains", "name": "consider_unavailable_mains",
"optional": True, "optional": True,
"required": False,
"default": 7200, "default": 7200,
}, },
{ {
@@ -118,6 +123,7 @@ CONFIG_WITH_ALARM_OPTIONS = {
"valueMin": 0, "valueMin": 0,
"name": "consider_unavailable_battery", "name": "consider_unavailable_battery",
"optional": True, "optional": True,
"required": False,
"default": 21600, "default": 21600,
}, },
{ {

View File

@@ -71,12 +71,14 @@ async def test_zcl_schema_conversions(hass: HomeAssistant) -> None:
"options": ["Execute if off present"], "options": ["Execute if off present"],
"name": "options_mask", "name": "options_mask",
"optional": True, "optional": True,
"required": False,
}, },
{ {
"type": "multi_select", "type": "multi_select",
"options": ["Execute if off"], "options": ["Execute if off"],
"name": "options_override", "name": "options_override",
"optional": True, "optional": True,
"required": False,
}, },
] ]
vol_schema = voluptuous_serialize.convert( vol_schema = voluptuous_serialize.convert(

View File

@@ -549,7 +549,14 @@ async def test_get_action_capabilities(
assert voluptuous_serialize.convert( assert voluptuous_serialize.convert(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer capabilities["extra_fields"], custom_serializer=cv.custom_serializer
) == [{"type": "boolean", "name": "refresh_all_values", "optional": True}] ) == [
{
"type": "boolean",
"name": "refresh_all_values",
"optional": True,
"required": False,
}
]
# Test ping # Test ping
capabilities = await device_action.async_get_action_capabilities( capabilities = await device_action.async_get_action_capabilities(
@@ -608,10 +615,15 @@ async def test_get_action_capabilities(
"type": "select", "type": "select",
}, },
{"name": "property", "required": True, "type": "string"}, {"name": "property", "required": True, "type": "string"},
{"name": "property_key", "optional": True, "type": "string"}, {"name": "property_key", "optional": True, "required": False, "type": "string"},
{"name": "endpoint", "optional": True, "type": "string"}, {"name": "endpoint", "optional": True, "required": False, "type": "string"},
{"name": "value", "required": True, "type": "string"}, {"name": "value", "required": True, "type": "string"},
{"type": "boolean", "name": "wait_for_result", "optional": True}, {
"type": "boolean",
"name": "wait_for_result",
"optional": True,
"required": False,
},
] ]
# Test enumerated type param # Test enumerated type param
@@ -771,7 +783,7 @@ async def test_get_action_capabilities_meter_triggers(
assert voluptuous_serialize.convert( assert voluptuous_serialize.convert(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer capabilities["extra_fields"], custom_serializer=cv.custom_serializer
) == [{"type": "string", "name": "value", "optional": True}] ) == [{"type": "string", "name": "value", "optional": True, "required": False}]
async def test_failure_scenarios( async def test_failure_scenarios(

View File

@@ -511,8 +511,8 @@ async def test_get_condition_capabilities_value(
"type": "select", "type": "select",
}, },
{"name": "property", "required": True, "type": "string"}, {"name": "property", "required": True, "type": "string"},
{"name": "property_key", "optional": True, "type": "string"}, {"name": "property_key", "optional": True, "required": False, "type": "string"},
{"name": "endpoint", "optional": True, "type": "string"}, {"name": "endpoint", "optional": True, "required": False, "type": "string"},
{"name": "value", "required": True, "type": "string"}, {"name": "value", "required": True, "type": "string"},
] ]

View File

@@ -201,10 +201,15 @@ async def test_get_trigger_capabilities_notification_notification(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer capabilities["extra_fields"], custom_serializer=cv.custom_serializer
) == unordered( ) == unordered(
[ [
{"name": "type.", "optional": True, "type": "string"}, {"name": "type.", "optional": True, "required": False, "type": "string"},
{"name": "label", "optional": True, "type": "string"}, {"name": "label", "optional": True, "required": False, "type": "string"},
{"name": "event", "optional": True, "type": "string"}, {"name": "event", "optional": True, "required": False, "type": "string"},
{"name": "event_label", "optional": True, "type": "string"}, {
"name": "event_label",
"optional": True,
"required": False,
"type": "string",
},
] ]
) )
@@ -336,8 +341,18 @@ async def test_get_trigger_capabilities_entry_control_notification(
capabilities["extra_fields"], custom_serializer=cv.custom_serializer capabilities["extra_fields"], custom_serializer=cv.custom_serializer
) == unordered( ) == unordered(
[ [
{"name": "event_type", "optional": True, "type": "string"}, {
{"name": "data_type", "optional": True, "type": "string"}, "name": "event_type",
"optional": True,
"required": False,
"type": "string",
},
{
"name": "data_type",
"optional": True,
"required": False,
"type": "string",
},
] ]
) )
@@ -580,6 +595,7 @@ async def test_get_trigger_capabilities_node_status(
{ {
"name": "from", "name": "from",
"optional": True, "optional": True,
"required": False,
"options": [ "options": [
("asleep", "asleep"), ("asleep", "asleep"),
("awake", "awake"), ("awake", "awake"),
@@ -591,6 +607,7 @@ async def test_get_trigger_capabilities_node_status(
{ {
"name": "to", "name": "to",
"optional": True, "optional": True,
"required": False,
"options": [ "options": [
("asleep", "asleep"), ("asleep", "asleep"),
("awake", "awake"), ("awake", "awake"),
@@ -599,7 +616,12 @@ async def test_get_trigger_capabilities_node_status(
], ],
"type": "select", "type": "select",
}, },
{"name": "for", "optional": True, "type": "positive_time_period_dict"}, {
"name": "for",
"optional": True,
"required": False,
"type": "positive_time_period_dict",
},
] ]
@@ -781,6 +803,7 @@ async def test_get_trigger_capabilities_basic_value_notification(
{ {
"name": "value", "name": "value",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"valueMin": 0, "valueMin": 0,
"valueMax": 255, "valueMax": 255,
@@ -972,6 +995,7 @@ async def test_get_trigger_capabilities_central_scene_value_notification(
{ {
"name": "value", "name": "value",
"optional": True, "optional": True,
"required": False,
"type": "select", "type": "select",
"options": [(0, "KeyPressed"), (1, "KeyReleased"), (2, "KeyHeldDown")], "options": [(0, "KeyPressed"), (1, "KeyReleased"), (2, "KeyHeldDown")],
}, },
@@ -1156,6 +1180,7 @@ async def test_get_trigger_capabilities_scene_activation_value_notification(
{ {
"name": "value", "name": "value",
"optional": True, "optional": True,
"required": False,
"type": "integer", "type": "integer",
"valueMin": 1, "valueMin": 1,
"valueMax": 255, "valueMax": 255,
@@ -1406,10 +1431,10 @@ async def test_get_trigger_capabilities_value_updated_value(
], ],
}, },
{"name": "property", "required": True, "type": "string"}, {"name": "property", "required": True, "type": "string"},
{"name": "property_key", "optional": True, "type": "string"}, {"name": "property_key", "optional": True, "required": False, "type": "string"},
{"name": "endpoint", "optional": True, "type": "string"}, {"name": "endpoint", "optional": True, "required": False, "type": "string"},
{"name": "from", "optional": True, "type": "string"}, {"name": "from", "optional": True, "required": False, "type": "string"},
{"name": "to", "optional": True, "type": "string"}, {"name": "to", "optional": True, "required": False, "type": "string"},
] ]
@@ -1552,6 +1577,7 @@ async def test_get_trigger_capabilities_value_updated_config_parameter_range(
{ {
"name": "from", "name": "from",
"optional": True, "optional": True,
"required": False,
"valueMin": 0, "valueMin": 0,
"valueMax": 255, "valueMax": 255,
"type": "integer", "type": "integer",
@@ -1559,6 +1585,7 @@ async def test_get_trigger_capabilities_value_updated_config_parameter_range(
{ {
"name": "to", "name": "to",
"optional": True, "optional": True,
"required": False,
"valueMin": 0, "valueMin": 0,
"valueMax": 255, "valueMax": 255,
"type": "integer", "type": "integer",
@@ -1600,12 +1627,14 @@ async def test_get_trigger_capabilities_value_updated_config_parameter_enumerate
{ {
"name": "from", "name": "from",
"optional": True, "optional": True,
"required": False,
"options": [(0, "Disable Beeper"), (255, "Enable Beeper")], "options": [(0, "Disable Beeper"), (255, "Enable Beeper")],
"type": "select", "type": "select",
}, },
{ {
"name": "to", "name": "to",
"optional": True, "optional": True,
"required": False,
"options": [(0, "Disable Beeper"), (255, "Enable Beeper")], "options": [(0, "Disable Beeper"), (255, "Enable Beeper")],
"type": "select", "type": "select",
}, },

View File

@@ -1229,7 +1229,13 @@ def test_section_in_serializer() -> None:
) == { ) == {
"expanded": True, "expanded": True,
"schema": [ "schema": [
{"default": False, "name": "option_1", "optional": True, "type": "boolean"}, {
"default": False,
"name": "option_1",
"optional": True,
"required": False,
"type": "boolean",
},
{"name": "option_2", "required": True, "type": "integer"}, {"name": "option_2", "required": True, "type": "integer"},
], ],
"type": "expandable", "type": "expandable",