diff --git a/homeassistant/components/hue/config_flow.py b/homeassistant/components/hue/config_flow.py index a77a2ff101a..ceb5a9a1a8e 100644 --- a/homeassistant/components/hue/config_flow.py +++ b/homeassistant/components/hue/config_flow.py @@ -12,7 +12,7 @@ import async_timeout import slugify as unicode_slug import voluptuous as vol -from homeassistant import config_entries +from homeassistant import config_entries, data_entry_flow from homeassistant.components import ssdp, zeroconf from homeassistant.const import CONF_API_KEY, CONF_HOST from homeassistant.core import callback @@ -48,7 +48,10 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): config_entry: config_entries.ConfigEntry, ) -> HueOptionsFlowHandler: """Get the options flow for this handler.""" - return HueOptionsFlowHandler(config_entry) + if config_entry.data.get(CONF_API_VERSION, 1) == 1: + # Options for Hue are only applicable to V1 bridges. + return HueOptionsFlowHandler(config_entry) + raise data_entry_flow.UnknownHandler def __init__(self) -> None: """Initialize the Hue flow.""" @@ -292,10 +295,6 @@ class HueOptionsFlowHandler(config_entries.OptionsFlow): if user_input is not None: return self.async_create_entry(title="", data=user_input) - if self.config_entry.data.get(CONF_API_VERSION, 1) > 1: - # Options for Hue are only applicable to V1 bridges. - return self.async_show_form(step_id="init") - return self.async_show_form( step_id="init", data_schema=vol.Schema( diff --git a/tests/components/hue/test_config_flow.py b/tests/components/hue/test_config_flow.py index 80e1a8909b9..65d3dd696d6 100644 --- a/tests/components/hue/test_config_flow.py +++ b/tests/components/hue/test_config_flow.py @@ -7,7 +7,7 @@ from aiohue.errors import LinkButtonNotPressed import pytest import voluptuous as vol -from homeassistant import config_entries +from homeassistant import config_entries, data_entry_flow from homeassistant.components import ssdp, zeroconf from homeassistant.components.hue import config_flow, const from homeassistant.components.hue.errors import CannotConnect @@ -706,12 +706,8 @@ async def test_options_flow_v2(hass): ) entry.add_to_hass(hass) - result = await hass.config_entries.options.async_init(entry.entry_id) - - assert result["type"] == "form" - assert result["step_id"] == "init" - # V2 bridge does not have config options - assert result["data_schema"] is None + with pytest.raises(data_entry_flow.UnknownHandler): + await hass.config_entries.options.async_init(entry.entry_id) async def test_bridge_zeroconf(hass, aioclient_mock):