diff --git a/blog/2022-06-07-dataflow-constants-deprecation.md b/blog/2022-06-07-dataflow-constants-deprecation.md new file mode 100644 index 00000000..68181753 --- /dev/null +++ b/blog/2022-06-07-dataflow-constants-deprecation.md @@ -0,0 +1,18 @@ +--- +author: epenet +authorURL: https://github.com/epenet +title: "Deprecating Data Entry Flow constants" +--- + +As of Home Assistant Core 2022.7, all `RESULT_TYPE_*` constants for data entry flow result types are deprecated: + + - `RESULT_TYPE_FORM` + - `RESULT_TYPE_CREATE_ENTRY` + - `RESULT_TYPE_ABORT` + - `RESULT_TYPE_EXTERNAL_STEP` + - `RESULT_TYPE_EXTERNAL_STEP_DONE` + - `RESULT_TYPE_SHOW_PROGRESS` + - `RESULT_TYPE_SHOW_PROGRESS_DONE` + - `RESULT_TYPE_MENU` + + Use the new `FlowResultType` enum instead. diff --git a/docs/data_entry_flow_index.md b/docs/data_entry_flow_index.md index 40126235..bb38a667 100644 --- a/docs/data_entry_flow_index.md +++ b/docs/data_entry_flow_index.md @@ -22,14 +22,14 @@ async def async_finish_flow(flow, result): """Finish flow.""" ``` -This async callback is called when a flow is finished or aborted. i.e. `result['type'] in [RESULT_TYPE_CREATE_ENTRY, RESULT_TYPE_ABORT]`. The callback function can modify result and return it back, if the result type changed to `RESULT_TYPE_FORM`, the flow will continue running, display another form. +This async callback is called when a flow is finished or aborted. i.e. `result['type'] in [FlowResultType.CREATE_ENTRY, FlowResultType.ABORT]`. The callback function can modify result and return it back, if the result type changed to `FlowResultType.FORM`, the flow will continue running, display another form. -If the result type is `RESULT_TYPE_FORM`, the result should look like: +If the result type is `FlowResultType.FORM`, the result should look like: ```python { # The result type of the flow - "type": RESULT_TYPE_FORM, + "type": FlowResultType.FORM, # the id of the flow "flow_id": "abcdfgh1234", # handler name @@ -45,14 +45,14 @@ If the result type is `RESULT_TYPE_FORM`, the result should look like: } ``` -If the result type is `RESULT_TYPE_CREATE_ENTRY`, the result should look like: +If the result type is `FlowResultType.CREATE_ENTRY`, the result should look like: ```python { # Data schema version of the entry "version": 2, # The result type of the flow - "type": RESULT_TYPE_CREATE_ENTRY, + "type": FlowResultType.CREATE_ENTRY, # the id of the flow "flow_id": "abcdfgh1234", # handler name @@ -65,12 +65,12 @@ If the result type is `RESULT_TYPE_CREATE_ENTRY`, the result should look like: } ``` -If the result type is `RESULT_TYPE_ABORT`, the result should look like: +If the result type is `FlowResultType.ABORT`, the result should look like: ```python { # The result type of the flow - "type": RESULT_TYPE_ABORT, + "type": FlowResultType.ABORT, # the id of the flow "flow_id": "abcdfgh1234", # handler name @@ -307,7 +307,7 @@ from homeassistant import data_entry_flow async def handle_result(hass, flow_id, data): result = await hass.config_entries.async_configure(flow_id, data) - if result["type"] == data_entry_flow.RESULT_TYPE_EXTERNAL_STEP_DONE: + if result["type"] == data_entry_flow.FlowResultType.EXTERNAL_STEP_DONE: return "success!" else: return "Invalid config flow specified"