Skip to content

Commit

Permalink
Fix options flow for HA 2023.11
Browse files Browse the repository at this point in the history
  • Loading branch information
dext0r committed Oct 28, 2023
1 parent da38bc8 commit 29173ca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion custom_components/yandex_smart_home/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async def async_step_init(self, _: ConfigType | None = None) -> FlowResult:
if self._data[const.CONF_CONNECTION_TYPE] == ConnectionType.CLOUD:
options += ["cloud_info", "cloud_settings"]

return self.async_show_menu(step_id="menu", menu_options=options)
return self.async_show_menu(step_id="init", menu_options=options)

async def async_step_filter_yaml(self, user_input: ConfigType | None = None) -> FlowResult:
"""Show warning about filter was configured in yaml."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/yandex_smart_home/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"entities_not_selected": "Необходимо выбрать хотя бы один объект"
},
"step": {
"menu": {
"init": {
"menu_options": {
"include_entities": "Объекты для передачи в УДЯ",
"connection_type": "Тип подключения",
Expand Down
26 changes: 13 additions & 13 deletions tests/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async def test_options_step_init_cloud(hass):

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"
assert result["menu_options"] == ["include_entities", "connection_type", "cloud_info", "cloud_settings"]


Expand All @@ -237,7 +237,7 @@ async def test_options_step_init_direct(hass):

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"
assert result["menu_options"] == ["include_entities", "connection_type"]


Expand All @@ -248,7 +248,7 @@ async def test_options_step_connection_type_no_change(hass, connection_type):

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"

result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"next_step_id": "connection_type"}
Expand All @@ -272,7 +272,7 @@ async def test_options_step_connection_type_change_to_direct(hass):

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"

result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"next_step_id": "connection_type"}
Expand Down Expand Up @@ -302,7 +302,7 @@ async def test_options_step_connection_type_change_to_cloud(hass, aioclient_mock

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"

result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"next_step_id": "connection_type"}
Expand Down Expand Up @@ -360,7 +360,7 @@ async def test_options_step_connection_type_change_to_cloud_again(hass, aioclien

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"

result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"next_step_id": "connection_type"}
Expand Down Expand Up @@ -388,7 +388,7 @@ async def test_options_step_cloud_info(hass):

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"

result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"next_step_id": "cloud_info"}
Expand All @@ -399,7 +399,7 @@ async def test_options_step_cloud_info(hass):

result3 = await hass.config_entries.options.async_configure(result["flow_id"], user_input={})
assert result3["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result3["step_id"] == "menu"
assert result3["step_id"] == "init"


async def test_options_step_cloud_settings(hass, hass_admin_user):
Expand All @@ -408,7 +408,7 @@ async def test_options_step_cloud_settings(hass, hass_admin_user):

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"

result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"next_step_id": "cloud_settings"}
Expand Down Expand Up @@ -441,7 +441,7 @@ async def test_options_step_include_entities_with_yaml_filters(hass):

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"

result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"next_step_id": "include_entities"}
Expand All @@ -451,7 +451,7 @@ async def test_options_step_include_entities_with_yaml_filters(hass):

result3 = await hass.config_entries.options.async_configure(result2["flow_id"], user_input={})
assert result3["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result3["step_id"] == "menu"
assert result3["step_id"] == "init"


@pytest.mark.parametrize("connection_type", [ConnectionType.CLOUD, ConnectionType.DIRECT])
Expand All @@ -467,7 +467,7 @@ async def test_options_flow_include_entities(hass, connection_type):

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"

result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"next_step_id": "include_entities"}
Expand All @@ -494,7 +494,7 @@ async def test_options_flow_filter_no_entities(hass, connection_type):

result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_MENU
assert result["step_id"] == "menu"
assert result["step_id"] == "init"

result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"next_step_id": "include_entities"}
Expand Down

0 comments on commit 29173ca

Please sign in to comment.