From f8275c2bd7d3ac28bb53e3d652cfc4b027bf88a7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 8 Jun 2022 02:42:31 +0200 Subject: [PATCH] Add FlowResultType enum to data entry flow (#1357) --- ...022-06-07-dataflow-constants-deprecation.md | 18 ++++++++++++++++++ docs/data_entry_flow_index.md | 16 ++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 blog/2022-06-07-dataflow-constants-deprecation.md 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"