diff --git a/homeassistant/components/auth/login_flow.py b/homeassistant/components/auth/login_flow.py index fe7ccededf2..69ae3eb65bd 100644 --- a/homeassistant/components/auth/login_flow.py +++ b/homeassistant/components/auth/login_flow.py @@ -199,23 +199,19 @@ class AuthProvidersView(HomeAssistantView): ) -def _prepare_result_json( - result: AuthFlowResult, -) -> AuthFlowResult: - """Convert result to JSON.""" +def _prepare_result_json(result: AuthFlowResult) -> dict[str, Any]: + """Convert result to JSON serializable dict.""" if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY: - data = result.copy() - data.pop("result") - data.pop("data") - return data + return { + key: val for key, val in result.items() if key not in ("result", "data") + } if result["type"] != data_entry_flow.FlowResultType.FORM: - return result + return result # type: ignore[return-value] - data = result.copy() - - if (schema := data["data_schema"]) is None: - data["data_schema"] = [] # type: ignore[typeddict-item] # json result type + data = dict(result) + if (schema := result["data_schema"]) is None: + data["data_schema"] = [] else: data["data_schema"] = voluptuous_serialize.convert(schema) diff --git a/homeassistant/components/auth/mfa_setup_flow.py b/homeassistant/components/auth/mfa_setup_flow.py index 6c85f5b7f55..5b4a539b86f 100644 --- a/homeassistant/components/auth/mfa_setup_flow.py +++ b/homeassistant/components/auth/mfa_setup_flow.py @@ -149,20 +149,16 @@ def websocket_depose_mfa( hass.async_create_task(async_depose(msg)) -def _prepare_result_json( - result: data_entry_flow.FlowResult, -) -> data_entry_flow.FlowResult: - """Convert result to JSON.""" +def _prepare_result_json(result: data_entry_flow.FlowResult) -> dict[str, Any]: + """Convert result to JSON serializable dict.""" if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY: - return result.copy() - + return dict(result) if result["type"] != data_entry_flow.FlowResultType.FORM: - return result + return result # type: ignore[return-value] - data = result.copy() - - if (schema := data["data_schema"]) is None: - data["data_schema"] = [] # type: ignore[typeddict-item] # json result type + data = dict(result) + if (schema := result["data_schema"]) is None: + data["data_schema"] = [] else: data["data_schema"] = voluptuous_serialize.convert(schema) diff --git a/homeassistant/components/config/config_entries.py b/homeassistant/components/config/config_entries.py index a9aafcfaa5e..176c9e2b047 100644 --- a/homeassistant/components/config/config_entries.py +++ b/homeassistant/components/config/config_entries.py @@ -137,20 +137,16 @@ class ConfigManagerEntryResourceReloadView(HomeAssistantView): def _prepare_config_flow_result_json( result: data_entry_flow.FlowResult, - prepare_result_json: Callable[ - [data_entry_flow.FlowResult], data_entry_flow.FlowResult - ], -) -> data_entry_flow.FlowResult: + prepare_result_json: Callable[[data_entry_flow.FlowResult], dict[str, Any]], +) -> dict[str, Any]: """Convert result to JSON.""" if result["type"] != data_entry_flow.FlowResultType.CREATE_ENTRY: return prepare_result_json(result) - data = result.copy() - entry: config_entries.ConfigEntry = data["result"] # type: ignore[typeddict-item] + data = {key: val for key, val in result.items() if key not in ("data", "context")} + entry: config_entries.ConfigEntry = result["result"] # type: ignore[typeddict-item] # We overwrite the ConfigEntry object with its json representation. - data["result"] = entry.as_json_fragment # type: ignore[typeddict-unknown-key] - data.pop("data") - data.pop("context") + data["result"] = entry.as_json_fragment return data @@ -204,8 +200,8 @@ class ConfigManagerFlowIndexView( def _prepare_result_json( self, result: data_entry_flow.FlowResult - ) -> data_entry_flow.FlowResult: - """Convert result to JSON.""" + ) -> dict[str, Any]: + """Convert result to JSON serializable dict.""" return _prepare_config_flow_result_json(result, super()._prepare_result_json) @@ -229,8 +225,8 @@ class ConfigManagerFlowResourceView( def _prepare_result_json( self, result: data_entry_flow.FlowResult - ) -> data_entry_flow.FlowResult: - """Convert result to JSON.""" + ) -> dict[str, Any]: + """Convert result to JSON serializable dict.""" return _prepare_config_flow_result_json(result, super()._prepare_result_json) diff --git a/homeassistant/components/repairs/websocket_api.py b/homeassistant/components/repairs/websocket_api.py index 4117b0ee35b..d09c567bb71 100644 --- a/homeassistant/components/repairs/websocket_api.py +++ b/homeassistant/components/repairs/websocket_api.py @@ -137,9 +137,9 @@ class RepairsFlowIndexView(FlowManagerIndexView): "Handler does not support user", HTTPStatus.BAD_REQUEST ) - result = self._prepare_result_json(result) - - return self.json(result) + return self.json( + self._prepare_result_json(result), + ) class RepairsFlowResourceView(FlowManagerResourceView): diff --git a/homeassistant/helpers/data_entry_flow.py b/homeassistant/helpers/data_entry_flow.py index 22074fb90a7..9ace020f342 100644 --- a/homeassistant/helpers/data_entry_flow.py +++ b/homeassistant/helpers/data_entry_flow.py @@ -31,27 +31,27 @@ class _BaseFlowManagerView(HomeAssistantView, Generic[_FlowManagerT]): def _prepare_result_json( self, result: data_entry_flow.FlowResult - ) -> data_entry_flow.FlowResult: - """Convert result to JSON.""" + ) -> dict[str, Any]: + """Convert result to JSON serializable dict.""" if result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY: - data = result.copy() assert "result" not in result - data.pop("data") - data.pop("context") - return data + return { + key: val + for key, val in result.items() + if key not in ("data", "context") + } + + data = dict(result) if "data_schema" not in result: - return result + return data - data = result.copy() - - if (schema := data["data_schema"]) is None: - data["data_schema"] = [] # type: ignore[typeddict-item] # json result type + if (schema := result["data_schema"]) is None: + data["data_schema"] = [] else: data["data_schema"] = voluptuous_serialize.convert( schema, custom_serializer=cv.custom_serializer ) - return data diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index e3c1bf4efe8..4dfb2dad734 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -70,7 +70,7 @@ ulid-transform==1.4.0 urllib3>=2.0 uv==0.8.9 voluptuous-openapi==0.1.0 -voluptuous-serialize==2.6.0 +voluptuous-serialize==2.7.0 voluptuous==0.15.2 webrtc-models==0.3.0 yarl==1.20.1 diff --git a/pyproject.toml b/pyproject.toml index 3e24035f271..30860e381d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ dependencies = [ "urllib3>=2.0", "uv==0.8.9", "voluptuous==0.15.2", - "voluptuous-serialize==2.6.0", + "voluptuous-serialize==2.7.0", "voluptuous-openapi==0.1.0", "yarl==1.20.1", "webrtc-models==0.3.0", diff --git a/requirements.txt b/requirements.txt index f053bc0d541..143df76e636 100644 --- a/requirements.txt +++ b/requirements.txt @@ -48,7 +48,7 @@ ulid-transform==1.4.0 urllib3>=2.0 uv==0.8.9 voluptuous==0.15.2 -voluptuous-serialize==2.6.0 +voluptuous-serialize==2.7.0 voluptuous-openapi==0.1.0 yarl==1.20.1 webrtc-models==0.3.0 diff --git a/tests/components/alarm_control_panel/test_device_action.py b/tests/components/alarm_control_panel/test_device_action.py index a7335017691..d52ee5733a1 100644 --- a/tests/components/alarm_control_panel/test_device_action.py +++ b/tests/components/alarm_control_panel/test_device_action.py @@ -245,7 +245,9 @@ async def test_get_action_capabilities( "arm_night": {"extra_fields": []}, "arm_vacation": {"extra_fields": []}, "disarm": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "trigger": {"extra_fields": []}, } @@ -293,7 +295,9 @@ async def test_get_action_capabilities_legacy( "arm_night": {"extra_fields": []}, "arm_vacation": {"extra_fields": []}, "disarm": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "trigger": {"extra_fields": []}, } @@ -338,19 +342,29 @@ async def test_get_action_capabilities_arm_code( expected_capabilities = { "arm_away": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "arm_home": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "arm_night": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "arm_vacation": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "disarm": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "trigger": {"extra_fields": []}, } @@ -394,19 +408,29 @@ async def test_get_action_capabilities_arm_code_legacy( expected_capabilities = { "arm_away": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "arm_home": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "arm_night": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "arm_vacation": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "disarm": { - "extra_fields": [{"name": "code", "optional": True, "type": "string"}] + "extra_fields": [ + {"name": "code", "optional": True, "required": False, "type": "string"} + ] }, "trigger": {"extra_fields": []}, } diff --git a/tests/components/alarm_control_panel/test_device_trigger.py b/tests/components/alarm_control_panel/test_device_trigger.py index 3efacb80560..979bc33bb00 100644 --- a/tests/components/alarm_control_panel/test_device_trigger.py +++ b/tests/components/alarm_control_panel/test_device_trigger.py @@ -191,7 +191,12 @@ async def test_get_trigger_capabilities( ) assert capabilities == { "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 == { "extra_fields": [ - {"name": "for", "optional": True, "type": "positive_time_period_dict"} + { + "name": "for", + "optional": True, + "required": False, + "type": "positive_time_period_dict", + } ] } diff --git a/tests/components/binary_sensor/test_device_condition.py b/tests/components/binary_sensor/test_device_condition.py index 59fbdf9a253..254c5428806 100644 --- a/tests/components/binary_sensor/test_device_condition.py +++ b/tests/components/binary_sensor/test_device_condition.py @@ -182,7 +182,12 @@ async def test_get_condition_capabilities( ) expected_capabilities = { "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( @@ -212,7 +217,12 @@ async def test_get_condition_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/binary_sensor/test_device_trigger.py b/tests/components/binary_sensor/test_device_trigger.py index dd71c1e5d06..e9ad5d0a1e1 100644 --- a/tests/components/binary_sensor/test_device_trigger.py +++ b/tests/components/binary_sensor/test_device_trigger.py @@ -185,7 +185,12 @@ async def test_get_trigger_capabilities( ) expected_capabilities = { "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( @@ -215,7 +220,12 @@ async def test_get_trigger_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/climate/test_device_trigger.py b/tests/components/climate/test_device_trigger.py index 4b5a578ecc4..06072b88afe 100644 --- a/tests/components/climate/test_device_trigger.py +++ b/tests/components/climate/test_device_trigger.py @@ -354,7 +354,12 @@ async def test_get_trigger_capabilities_hvac_mode(hass: HomeAssistant) -> None: "required": True, "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}, "name": "above", "optional": True, + "required": False, "type": "float", }, { "description": {"suffix": suffix}, "name": "below", "optional": True, + "required": False, "type": "float", }, - {"name": "for", "optional": True, "type": "positive_time_period_dict"}, + { + "name": "for", + "optional": True, + "required": False, + "type": "positive_time_period_dict", + }, ] diff --git a/tests/components/config/test_config_entries.py b/tests/components/config/test_config_entries.py index c6e82976bf1..8f89549944c 100644 --- a/tests/components/config/test_config_entries.py +++ b/tests/components/config/test_config_entries.py @@ -625,7 +625,9 @@ async def test_two_step_flow(hass: HomeAssistant, client: TestClient) -> None: "type": "form", "handler": "test", "step_id": "account", - "data_schema": [{"name": "user_title", "type": "string"}], + "data_schema": [ + {"name": "user_title", "required": False, "type": "string"} + ], "description_placeholders": None, "errors": None, "last_step": None, @@ -712,7 +714,9 @@ async def test_continue_flow_unauth( "type": "form", "handler": "test", "step_id": "account", - "data_schema": [{"name": "user_title", "type": "string"}], + "data_schema": [ + {"name": "user_title", "required": False, "type": "string"} + ], "description_placeholders": None, "errors": None, "last_step": None, @@ -1272,7 +1276,7 @@ async def test_two_step_options_flow(hass: HomeAssistant, client: TestClient) -> "type": "form", "handler": "test1", "step_id": "finish", - "data_schema": [{"name": "enabled", "type": "boolean"}], + "data_schema": [{"name": "enabled", "required": False, "type": "boolean"}], "description_placeholders": None, "errors": None, "last_step": None, @@ -1581,7 +1585,7 @@ async def test_subentry_flow_abort_duplicate(hass: HomeAssistant, client) -> Non "type": "form", "handler": ["test1", "test"], "step_id": "finish", - "data_schema": [{"name": "enabled", "type": "boolean"}], + "data_schema": [{"name": "enabled", "required": False, "type": "boolean"}], "description_placeholders": None, "errors": None, "last_step": None, @@ -1749,7 +1753,7 @@ async def test_two_step_subentry_flow(hass: HomeAssistant, client) -> None: data = await resp.json() flow_id = data["flow_id"] expected_data = { - "data_schema": [{"name": "enabled", "type": "boolean"}], + "data_schema": [{"name": "enabled", "required": False, "type": "boolean"}], "description_placeholders": None, "errors": None, "flow_id": flow_id, diff --git a/tests/components/cover/test_device_action.py b/tests/components/cover/test_device_action.py index db9e75bcaef..438e5de751d 100644 --- a/tests/components/cover/test_device_action.py +++ b/tests/components/cover/test_device_action.py @@ -260,6 +260,7 @@ async def test_get_action_capabilities_set_pos( { "name": "position", "optional": True, + "required": False, "type": "integer", "default": 0, "valueMax": 100, @@ -310,6 +311,7 @@ async def test_get_action_capabilities_set_tilt_pos( { "name": "position", "optional": True, + "required": False, "type": "integer", "default": 0, "valueMax": 100, diff --git a/tests/components/cover/test_device_condition.py b/tests/components/cover/test_device_condition.py index aa5f150172c..5bd02120585 100644 --- a/tests/components/cover/test_device_condition.py +++ b/tests/components/cover/test_device_condition.py @@ -254,6 +254,7 @@ async def test_get_condition_capabilities_set_pos( { "name": "above", "optional": True, + "required": False, "type": "integer", "default": 0, "valueMax": 100, @@ -262,6 +263,7 @@ async def test_get_condition_capabilities_set_pos( { "name": "below", "optional": True, + "required": False, "type": "integer", "default": 100, "valueMax": 100, @@ -311,6 +313,7 @@ async def test_get_condition_capabilities_set_tilt_pos( { "name": "above", "optional": True, + "required": False, "type": "integer", "default": 0, "valueMax": 100, @@ -319,6 +322,7 @@ async def test_get_condition_capabilities_set_tilt_pos( { "name": "below", "optional": True, + "required": False, "type": "integer", "default": 100, "valueMax": 100, diff --git a/tests/components/cover/test_device_trigger.py b/tests/components/cover/test_device_trigger.py index 7901baaa3b8..1a6b50b2935 100644 --- a/tests/components/cover/test_device_trigger.py +++ b/tests/components/cover/test_device_trigger.py @@ -192,7 +192,12 @@ async def test_get_trigger_capabilities( ) assert capabilities == { "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 == { "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", "optional": True, + "required": False, "type": "integer", "default": 0, "valueMax": 100, @@ -270,6 +281,7 @@ async def test_get_trigger_capabilities_set_pos( { "name": "below", "optional": True, + "required": False, "type": "integer", "default": 100, "valueMax": 100, @@ -293,6 +305,7 @@ async def test_get_trigger_capabilities_set_pos( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ] @@ -326,6 +339,7 @@ async def test_get_trigger_capabilities_set_tilt_pos( { "name": "above", "optional": True, + "required": False, "type": "integer", "default": 0, "valueMax": 100, @@ -334,6 +348,7 @@ async def test_get_trigger_capabilities_set_tilt_pos( { "name": "below", "optional": True, + "required": False, "type": "integer", "default": 100, "valueMax": 100, @@ -357,6 +372,7 @@ async def test_get_trigger_capabilities_set_tilt_pos( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ] diff --git a/tests/components/device_automation/test_init.py b/tests/components/device_automation/test_init.py index 94625746b05..456202a63a4 100644 --- a/tests/components/device_automation/test_init.py +++ b/tests/components/device_automation/test_init.py @@ -293,7 +293,9 @@ async def test_websocket_get_action_capabilities( ) expected_capabilities = { "turn_on": { - "extra_fields": [{"type": "string", "name": "code", "optional": True}] + "extra_fields": [ + {"type": "string", "name": "code", "optional": True, "required": False} + ] }, "turn_off": {"extra_fields": []}, "toggle": {"extra_fields": []}, @@ -452,7 +454,12 @@ async def test_websocket_get_condition_capabilities( ) expected_capabilities = { "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 = { "extra_fields": [ - {"name": "for", "optional": True, "type": "positive_time_period_dict"} + { + "name": "for", + "optional": True, + "required": False, + "type": "positive_time_period_dict", + } ] } diff --git a/tests/components/fan/test_device_trigger.py b/tests/components/fan/test_device_trigger.py index bef44c92f34..800412fc9d4 100644 --- a/tests/components/fan/test_device_trigger.py +++ b/tests/components/fan/test_device_trigger.py @@ -125,7 +125,12 @@ async def test_get_trigger_capabilities( ) expected_capabilities = { "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( @@ -155,7 +160,12 @@ async def test_get_trigger_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/hassio/test_repairs.py b/tests/components/hassio/test_repairs.py index 39f9d4580bd..4234aab40c1 100644 --- a/tests/components/hassio/test_repairs.py +++ b/tests/components/hassio/test_repairs.py @@ -180,6 +180,7 @@ async def test_supervisor_issue_repair_flow_with_multiple_suggestions( ["system_execute_reboot", "system_execute_reboot"], ["system_test_type", "system_test_type"], ], + "required": False, "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_test_type", "system_test_type"], ], + "required": False, "name": "next_step_id", } ], @@ -545,6 +547,7 @@ async def test_mount_failed_repair_flow( ["mount_execute_reload", "mount_execute_reload"], ["mount_execute_remove", "mount_execute_remove"], ], + "required": False, "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_adopt_data_disk", "system_adopt_data_disk"], ], + "required": False, "name": "next_step_id", } ], @@ -960,6 +964,7 @@ async def test_supervisor_issue_addon_boot_fail( ["addon_execute_start", "addon_execute_start"], ["addon_disable_boot", "addon_disable_boot"], ], + "required": False, "name": "next_step_id", } ], diff --git a/tests/components/humidifier/test_device_condition.py b/tests/components/humidifier/test_device_condition.py index ec8406bfe7b..55a2c687867 100644 --- a/tests/components/humidifier/test_device_condition.py +++ b/tests/components/humidifier/test_device_condition.py @@ -363,6 +363,7 @@ async def test_if_state_legacy( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ], @@ -376,6 +377,7 @@ async def test_if_state_legacy( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ], @@ -417,6 +419,7 @@ async def test_if_state_legacy( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ], @@ -430,6 +433,7 @@ async def test_if_state_legacy( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ], @@ -533,6 +537,7 @@ async def test_capabilities( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ], @@ -546,6 +551,7 @@ async def test_capabilities( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ], @@ -587,6 +593,7 @@ async def test_capabilities( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ], @@ -600,6 +607,7 @@ async def test_capabilities( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", } ], diff --git a/tests/components/humidifier/test_device_trigger.py b/tests/components/humidifier/test_device_trigger.py index e1b2b2bff61..6d45861b227 100644 --- a/tests/components/humidifier/test_device_trigger.py +++ b/tests/components/humidifier/test_device_trigger.py @@ -543,7 +543,14 @@ async def test_get_trigger_capabilities_on(hass: HomeAssistant) -> None: assert voluptuous_serialize.convert( 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: @@ -563,7 +570,14 @@ async def test_get_trigger_capabilities_off(hass: HomeAssistant) -> None: assert voluptuous_serialize.convert( 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: @@ -588,13 +602,20 @@ async def test_get_trigger_capabilities_humidity(hass: HomeAssistant) -> None: "description": {"suffix": "%"}, "name": "above", "optional": True, + "required": False, "type": "integer", }, { "description": {"suffix": "%"}, "name": "below", "optional": True, + "required": False, "type": "integer", }, - {"name": "for", "optional": True, "type": "positive_time_period_dict"}, + { + "name": "for", + "optional": True, + "required": False, + "type": "positive_time_period_dict", + }, ] diff --git a/tests/components/knx/test_device_trigger.py b/tests/components/knx/test_device_trigger.py index e4a208906c6..124ce60e475 100644 --- a/tests/components/knx/test_device_trigger.py +++ b/tests/components/knx/test_device_trigger.py @@ -301,6 +301,7 @@ async def test_get_trigger_capabilities( { "name": "destination", "optional": True, + "required": False, "selector": { "select": { "custom_value": True, @@ -314,6 +315,7 @@ async def test_get_trigger_capabilities( { "name": "group_value_write", "optional": True, + "required": False, "default": True, "selector": { "boolean": {}, @@ -322,6 +324,7 @@ async def test_get_trigger_capabilities( { "name": "group_value_response", "optional": True, + "required": False, "default": True, "selector": { "boolean": {}, @@ -330,6 +333,7 @@ async def test_get_trigger_capabilities( { "name": "group_value_read", "optional": True, + "required": False, "default": True, "selector": { "boolean": {}, @@ -338,6 +342,7 @@ async def test_get_trigger_capabilities( { "name": "incoming", "optional": True, + "required": False, "default": True, "selector": { "boolean": {}, @@ -346,6 +351,7 @@ async def test_get_trigger_capabilities( { "name": "outgoing", "optional": True, + "required": False, "default": True, "selector": { "boolean": {}, diff --git a/tests/components/lcn/test_device_trigger.py b/tests/components/lcn/test_device_trigger.py index 94eb96591e2..9f134a0c203 100644 --- a/tests/components/lcn/test_device_trigger.py +++ b/tests/components/lcn/test_device_trigger.py @@ -349,7 +349,15 @@ async def test_get_transponder_trigger_capabilities( assert voluptuous_serialize.convert( 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( @@ -373,7 +381,15 @@ async def test_get_fingerprint_trigger_capabilities( assert voluptuous_serialize.convert( 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( @@ -398,13 +414,32 @@ async def test_get_transmitter_trigger_capabilities( assert voluptuous_serialize.convert( 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": "key", "type": "integer", "optional": True, "valueMin": 0}, + { + "name": "code", + "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", "type": "select", "optional": True, + "required": False, "options": [("hit", "hit"), ("make", "make"), ("break", "break")], }, ] @@ -436,6 +471,7 @@ async def test_get_send_keys_trigger_capabilities( "name": "key", "type": "select", "optional": True, + "required": False, "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 ], "optional": True, + "required": False, }, ] diff --git a/tests/components/light/test_device_action.py b/tests/components/light/test_device_action.py index c2ac7087cf0..1f69b586c9b 100644 --- a/tests/components/light/test_device_action.py +++ b/tests/components/light/test_device_action.py @@ -194,6 +194,7 @@ async def test_get_action_capabilities( { "name": "brightness_pct", "optional": True, + "required": False, "type": "float", "valueMax": 100, "valueMin": 0, @@ -219,6 +220,7 @@ async def test_get_action_capabilities( { "name": "brightness_pct", "optional": True, + "required": False, "type": "float", "valueMax": 100, "valueMin": 0, @@ -238,6 +240,7 @@ async def test_get_action_capabilities( { "name": "flash", "optional": True, + "required": False, "type": "select", "options": [("short", "short"), ("long", "long")], } @@ -256,6 +259,7 @@ async def test_get_action_capabilities( { "name": "flash", "optional": True, + "required": False, "type": "select", "options": [("short", "short"), ("long", "long")], } @@ -341,6 +345,7 @@ async def test_get_action_capabilities_features( { "name": "brightness_pct", "optional": True, + "required": False, "type": "float", "valueMax": 100, "valueMin": 0, @@ -366,6 +371,7 @@ async def test_get_action_capabilities_features( { "name": "brightness_pct", "optional": True, + "required": False, "type": "float", "valueMax": 100, "valueMin": 0, @@ -385,6 +391,7 @@ async def test_get_action_capabilities_features( { "name": "flash", "optional": True, + "required": False, "type": "select", "options": [("short", "short"), ("long", "long")], } @@ -403,6 +410,7 @@ async def test_get_action_capabilities_features( { "name": "flash", "optional": True, + "required": False, "type": "select", "options": [("short", "short"), ("long", "long")], } diff --git a/tests/components/light/test_device_condition.py b/tests/components/light/test_device_condition.py index 2a5c9f0bb18..1dabe6e6071 100644 --- a/tests/components/light/test_device_condition.py +++ b/tests/components/light/test_device_condition.py @@ -128,7 +128,12 @@ async def test_get_condition_capabilities( ) expected_capabilities = { "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( @@ -158,7 +163,12 @@ async def test_get_condition_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/light/test_device_trigger.py b/tests/components/light/test_device_trigger.py index ae54bbd2512..99e0a5e5b93 100644 --- a/tests/components/light/test_device_trigger.py +++ b/tests/components/light/test_device_trigger.py @@ -133,7 +133,12 @@ async def test_get_trigger_capabilities( ) expected_capabilities = { "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( @@ -163,7 +168,12 @@ async def test_get_trigger_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/lock/test_device_trigger.py b/tests/components/lock/test_device_trigger.py index 7d1c39d10f0..a5b8e47ef2f 100644 --- a/tests/components/lock/test_device_trigger.py +++ b/tests/components/lock/test_device_trigger.py @@ -155,7 +155,12 @@ async def test_get_trigger_capabilities( ) assert capabilities == { "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 == { "extra_fields": [ - {"name": "for", "optional": True, "type": "positive_time_period_dict"} + { + "name": "for", + "optional": True, + "required": False, + "type": "positive_time_period_dict", + } ] } diff --git a/tests/components/media_player/test_device_trigger.py b/tests/components/media_player/test_device_trigger.py index ae3a84e66a0..e82f1cd3612 100644 --- a/tests/components/media_player/test_device_trigger.py +++ b/tests/components/media_player/test_device_trigger.py @@ -161,7 +161,12 @@ async def test_get_trigger_capabilities( ) assert capabilities == { "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 == { "extra_fields": [ - {"name": "for", "optional": True, "type": "positive_time_period_dict"} + { + "name": "for", + "optional": True, + "required": False, + "type": "positive_time_period_dict", + } ] } diff --git a/tests/components/remote/test_device_condition.py b/tests/components/remote/test_device_condition.py index b4dd513c317..c5ba1c77c31 100644 --- a/tests/components/remote/test_device_condition.py +++ b/tests/components/remote/test_device_condition.py @@ -125,7 +125,12 @@ async def test_get_condition_capabilities( ) expected_capabilities = { "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( @@ -155,7 +160,12 @@ async def test_get_condition_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/remote/test_device_trigger.py b/tests/components/remote/test_device_trigger.py index 800d090fd7b..0321ba8bbaa 100644 --- a/tests/components/remote/test_device_trigger.py +++ b/tests/components/remote/test_device_trigger.py @@ -125,7 +125,12 @@ async def test_get_trigger_capabilities( ) expected_capabilities = { "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( @@ -155,7 +160,12 @@ async def test_get_trigger_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/select/test_device_action.py b/tests/components/select/test_device_action.py index 0ffb860179d..446dbd0a0bf 100644 --- a/tests/components/select/test_device_action.py +++ b/tests/components/select/test_device_action.py @@ -376,6 +376,7 @@ async def test_get_action_capabilities( { "name": "cycle", "optional": True, + "required": False, "type": "boolean", "default": True, }, @@ -391,6 +392,7 @@ async def test_get_action_capabilities( { "name": "cycle", "optional": True, + "required": False, "type": "boolean", "default": True, }, @@ -476,6 +478,7 @@ async def test_get_action_capabilities_legacy( { "name": "cycle", "optional": True, + "required": False, "type": "boolean", "default": True, }, @@ -491,6 +494,7 @@ async def test_get_action_capabilities_legacy( { "name": "cycle", "optional": True, + "required": False, "type": "boolean", "default": True, }, diff --git a/tests/components/select/test_device_condition.py b/tests/components/select/test_device_condition.py index fc35757fa67..83788701877 100644 --- a/tests/components/select/test_device_condition.py +++ b/tests/components/select/test_device_condition.py @@ -276,6 +276,7 @@ async def test_get_condition_capabilities( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", }, ] @@ -301,6 +302,7 @@ async def test_get_condition_capabilities( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", }, ] @@ -336,6 +338,7 @@ async def test_get_condition_capabilities_legacy( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", }, ] @@ -361,6 +364,7 @@ async def test_get_condition_capabilities_legacy( { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", }, ] diff --git a/tests/components/select/test_device_trigger.py b/tests/components/select/test_device_trigger.py index dbb4e23d785..1d8f8b07ad7 100644 --- a/tests/components/select/test_device_trigger.py +++ b/tests/components/select/test_device_trigger.py @@ -310,18 +310,21 @@ async def test_get_trigger_capabilities( { "name": "from", "optional": True, + "required": False, "type": "select", "options": [], }, { "name": "to", "optional": True, + "required": False, "type": "select", "options": [], }, { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", }, ] @@ -341,18 +344,21 @@ async def test_get_trigger_capabilities( { "name": "from", "optional": True, + "required": False, "type": "select", "options": [("option1", "option1"), ("option2", "option2")], }, { "name": "to", "optional": True, + "required": False, "type": "select", "options": [("option1", "option1"), ("option2", "option2")], }, { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", }, ] @@ -380,18 +386,21 @@ async def test_get_trigger_capabilities_unknown( { "name": "from", "optional": True, + "required": False, "type": "select", "options": [], }, { "name": "to", "optional": True, + "required": False, "type": "select", "options": [], }, { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", }, ] @@ -421,18 +430,21 @@ async def test_get_trigger_capabilities_legacy( { "name": "from", "optional": True, + "required": False, "type": "select", "options": [], }, { "name": "to", "optional": True, + "required": False, "type": "select", "options": [], }, { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", }, ] @@ -452,18 +464,21 @@ async def test_get_trigger_capabilities_legacy( { "name": "from", "optional": True, + "required": False, "type": "select", "options": [("option1", "option1"), ("option2", "option2")], }, { "name": "to", "optional": True, + "required": False, "type": "select", "options": [("option1", "option1"), ("option2", "option2")], }, { "name": "for", "optional": True, + "required": False, "type": "positive_time_period_dict", }, ] diff --git a/tests/components/sensor/test_device_condition.py b/tests/components/sensor/test_device_condition.py index da69610f4c5..88bec54c936 100644 --- a/tests/components/sensor/test_device_condition.py +++ b/tests/components/sensor/test_device_condition.py @@ -329,12 +329,14 @@ async def test_get_condition_capabilities( "description": {"suffix": PERCENTAGE}, "name": "above", "optional": True, + "required": False, "type": "float", }, { "description": {"suffix": PERCENTAGE}, "name": "below", "optional": True, + "required": False, "type": "float", }, ] @@ -398,12 +400,14 @@ async def test_get_condition_capabilities_legacy( "description": {"suffix": PERCENTAGE}, "name": "above", "optional": True, + "required": False, "type": "float", }, { "description": {"suffix": PERCENTAGE}, "name": "below", "optional": True, + "required": False, "type": "float", }, ] diff --git a/tests/components/sensor/test_device_trigger.py b/tests/components/sensor/test_device_trigger.py index c39a5216f0f..31bd0d2be55 100644 --- a/tests/components/sensor/test_device_trigger.py +++ b/tests/components/sensor/test_device_trigger.py @@ -277,15 +277,22 @@ async def test_get_trigger_capabilities( "description": {"suffix": PERCENTAGE}, "name": "above", "optional": True, + "required": False, "type": "float", }, { "description": {"suffix": PERCENTAGE}, "name": "below", "optional": True, + "required": False, "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( @@ -347,15 +354,22 @@ async def test_get_trigger_capabilities_legacy( "description": {"suffix": PERCENTAGE}, "name": "above", "optional": True, + "required": False, "type": "float", }, { "description": {"suffix": PERCENTAGE}, "name": "below", "optional": True, + "required": False, "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( diff --git a/tests/components/switch/test_device_condition.py b/tests/components/switch/test_device_condition.py index 5c5737804e1..89c84b1ed34 100644 --- a/tests/components/switch/test_device_condition.py +++ b/tests/components/switch/test_device_condition.py @@ -125,7 +125,12 @@ async def test_get_condition_capabilities( ) expected_capabilities = { "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( @@ -155,7 +160,12 @@ async def test_get_condition_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/switch/test_device_trigger.py b/tests/components/switch/test_device_trigger.py index 81f8a93611d..a642bb44825 100644 --- a/tests/components/switch/test_device_trigger.py +++ b/tests/components/switch/test_device_trigger.py @@ -125,7 +125,12 @@ async def test_get_trigger_capabilities( ) expected_capabilities = { "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( @@ -155,7 +160,12 @@ async def test_get_trigger_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/update/test_device_trigger.py b/tests/components/update/test_device_trigger.py index 55138430ca0..7cdaf4ca720 100644 --- a/tests/components/update/test_device_trigger.py +++ b/tests/components/update/test_device_trigger.py @@ -127,7 +127,12 @@ async def test_get_trigger_capabilities( ) expected_capabilities = { "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( @@ -157,7 +162,12 @@ async def test_get_trigger_capabilities_legacy( ) expected_capabilities = { "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( diff --git a/tests/components/vacuum/test_device_trigger.py b/tests/components/vacuum/test_device_trigger.py index 381cc1caa47..330f14be507 100644 --- a/tests/components/vacuum/test_device_trigger.py +++ b/tests/components/vacuum/test_device_trigger.py @@ -134,7 +134,12 @@ async def test_get_trigger_capabilities( ) assert capabilities == { "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 == { "extra_fields": [ - {"name": "for", "optional": True, "type": "positive_time_period_dict"} + { + "name": "for", + "optional": True, + "required": False, + "type": "positive_time_period_dict", + } ] } diff --git a/tests/components/zha/data.py b/tests/components/zha/data.py index 80a3df524cd..11c09229eb8 100644 --- a/tests/components/zha/data.py +++ b/tests/components/zha/data.py @@ -9,6 +9,7 @@ BASE_CUSTOM_CONFIGURATION = { "valueMax": 6553.6, "name": "default_light_transition", "optional": True, + "required": False, "default": 0, }, { @@ -40,6 +41,7 @@ BASE_CUSTOM_CONFIGURATION = { "valueMin": 0, "name": "consider_unavailable_mains", "optional": True, + "required": False, "default": 7200, }, { @@ -47,6 +49,7 @@ BASE_CUSTOM_CONFIGURATION = { "valueMin": 0, "name": "consider_unavailable_battery", "optional": True, + "required": False, "default": 21600, }, { @@ -80,6 +83,7 @@ CONFIG_WITH_ALARM_OPTIONS = { "valueMax": 6553.6, "name": "default_light_transition", "optional": True, + "required": False, "default": 0, }, { @@ -111,6 +115,7 @@ CONFIG_WITH_ALARM_OPTIONS = { "valueMin": 0, "name": "consider_unavailable_mains", "optional": True, + "required": False, "default": 7200, }, { @@ -118,6 +123,7 @@ CONFIG_WITH_ALARM_OPTIONS = { "valueMin": 0, "name": "consider_unavailable_battery", "optional": True, + "required": False, "default": 21600, }, { diff --git a/tests/components/zha/test_helpers.py b/tests/components/zha/test_helpers.py index f52b403869e..9c833cde0be 100644 --- a/tests/components/zha/test_helpers.py +++ b/tests/components/zha/test_helpers.py @@ -71,12 +71,14 @@ async def test_zcl_schema_conversions(hass: HomeAssistant) -> None: "options": ["Execute if off present"], "name": "options_mask", "optional": True, + "required": False, }, { "type": "multi_select", "options": ["Execute if off"], "name": "options_override", "optional": True, + "required": False, }, ] vol_schema = voluptuous_serialize.convert( diff --git a/tests/components/zwave_js/test_device_action.py b/tests/components/zwave_js/test_device_action.py index 46686be0994..fec75d1c032 100644 --- a/tests/components/zwave_js/test_device_action.py +++ b/tests/components/zwave_js/test_device_action.py @@ -549,7 +549,14 @@ async def test_get_action_capabilities( assert voluptuous_serialize.convert( 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 capabilities = await device_action.async_get_action_capabilities( @@ -608,10 +615,15 @@ async def test_get_action_capabilities( "type": "select", }, {"name": "property", "required": True, "type": "string"}, - {"name": "property_key", "optional": True, "type": "string"}, - {"name": "endpoint", "optional": True, "type": "string"}, + {"name": "property_key", "optional": True, "required": False, "type": "string"}, + {"name": "endpoint", "optional": True, "required": False, "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 @@ -771,7 +783,7 @@ async def test_get_action_capabilities_meter_triggers( assert voluptuous_serialize.convert( 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( diff --git a/tests/components/zwave_js/test_device_condition.py b/tests/components/zwave_js/test_device_condition.py index 17bc4cf0f5d..123191e1f3a 100644 --- a/tests/components/zwave_js/test_device_condition.py +++ b/tests/components/zwave_js/test_device_condition.py @@ -511,8 +511,8 @@ async def test_get_condition_capabilities_value( "type": "select", }, {"name": "property", "required": True, "type": "string"}, - {"name": "property_key", "optional": True, "type": "string"}, - {"name": "endpoint", "optional": True, "type": "string"}, + {"name": "property_key", "optional": True, "required": False, "type": "string"}, + {"name": "endpoint", "optional": True, "required": False, "type": "string"}, {"name": "value", "required": True, "type": "string"}, ] diff --git a/tests/components/zwave_js/test_device_trigger.py b/tests/components/zwave_js/test_device_trigger.py index ccc69f7723d..7ff76888ce4 100644 --- a/tests/components/zwave_js/test_device_trigger.py +++ b/tests/components/zwave_js/test_device_trigger.py @@ -201,10 +201,15 @@ async def test_get_trigger_capabilities_notification_notification( capabilities["extra_fields"], custom_serializer=cv.custom_serializer ) == unordered( [ - {"name": "type.", "optional": True, "type": "string"}, - {"name": "label", "optional": True, "type": "string"}, - {"name": "event", "optional": True, "type": "string"}, - {"name": "event_label", "optional": True, "type": "string"}, + {"name": "type.", "optional": True, "required": False, "type": "string"}, + {"name": "label", "optional": True, "required": False, "type": "string"}, + {"name": "event", "optional": True, "required": False, "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 ) == 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", "optional": True, + "required": False, "options": [ ("asleep", "asleep"), ("awake", "awake"), @@ -591,6 +607,7 @@ async def test_get_trigger_capabilities_node_status( { "name": "to", "optional": True, + "required": False, "options": [ ("asleep", "asleep"), ("awake", "awake"), @@ -599,7 +616,12 @@ async def test_get_trigger_capabilities_node_status( ], "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", "optional": True, + "required": False, "type": "integer", "valueMin": 0, "valueMax": 255, @@ -972,6 +995,7 @@ async def test_get_trigger_capabilities_central_scene_value_notification( { "name": "value", "optional": True, + "required": False, "type": "select", "options": [(0, "KeyPressed"), (1, "KeyReleased"), (2, "KeyHeldDown")], }, @@ -1156,6 +1180,7 @@ async def test_get_trigger_capabilities_scene_activation_value_notification( { "name": "value", "optional": True, + "required": False, "type": "integer", "valueMin": 1, "valueMax": 255, @@ -1406,10 +1431,10 @@ async def test_get_trigger_capabilities_value_updated_value( ], }, {"name": "property", "required": True, "type": "string"}, - {"name": "property_key", "optional": True, "type": "string"}, - {"name": "endpoint", "optional": True, "type": "string"}, - {"name": "from", "optional": True, "type": "string"}, - {"name": "to", "optional": True, "type": "string"}, + {"name": "property_key", "optional": True, "required": False, "type": "string"}, + {"name": "endpoint", "optional": True, "required": False, "type": "string"}, + {"name": "from", "optional": True, "required": False, "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", "optional": True, + "required": False, "valueMin": 0, "valueMax": 255, "type": "integer", @@ -1559,6 +1585,7 @@ async def test_get_trigger_capabilities_value_updated_config_parameter_range( { "name": "to", "optional": True, + "required": False, "valueMin": 0, "valueMax": 255, "type": "integer", @@ -1600,12 +1627,14 @@ async def test_get_trigger_capabilities_value_updated_config_parameter_enumerate { "name": "from", "optional": True, + "required": False, "options": [(0, "Disable Beeper"), (255, "Enable Beeper")], "type": "select", }, { "name": "to", "optional": True, + "required": False, "options": [(0, "Disable Beeper"), (255, "Enable Beeper")], "type": "select", }, diff --git a/tests/test_data_entry_flow.py b/tests/test_data_entry_flow.py index 0faa4dd1a80..f0912188b9e 100644 --- a/tests/test_data_entry_flow.py +++ b/tests/test_data_entry_flow.py @@ -1229,7 +1229,13 @@ def test_section_in_serializer() -> None: ) == { "expanded": True, "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"}, ], "type": "expandable",