Disable options flow for Hue V2 bridges (#61045)

This commit is contained in:
Marcel van der Veldt 2021-12-05 18:47:44 +01:00 committed by GitHub
parent 11e2f51681
commit b98bc64604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 13 deletions

View File

@ -12,7 +12,7 @@ import async_timeout
import slugify as unicode_slug import slugify as unicode_slug
import voluptuous as vol 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 import ssdp, zeroconf
from homeassistant.const import CONF_API_KEY, CONF_HOST from homeassistant.const import CONF_API_KEY, CONF_HOST
from homeassistant.core import callback from homeassistant.core import callback
@ -48,7 +48,10 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
config_entry: config_entries.ConfigEntry, config_entry: config_entries.ConfigEntry,
) -> HueOptionsFlowHandler: ) -> HueOptionsFlowHandler:
"""Get the options flow for this handler.""" """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: def __init__(self) -> None:
"""Initialize the Hue flow.""" """Initialize the Hue flow."""
@ -292,10 +295,6 @@ class HueOptionsFlowHandler(config_entries.OptionsFlow):
if user_input is not None: if user_input is not None:
return self.async_create_entry(title="", data=user_input) 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( return self.async_show_form(
step_id="init", step_id="init",
data_schema=vol.Schema( data_schema=vol.Schema(

View File

@ -7,7 +7,7 @@ from aiohue.errors import LinkButtonNotPressed
import pytest import pytest
import voluptuous as vol 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 import ssdp, zeroconf
from homeassistant.components.hue import config_flow, const from homeassistant.components.hue import config_flow, const
from homeassistant.components.hue.errors import CannotConnect from homeassistant.components.hue.errors import CannotConnect
@ -706,12 +706,8 @@ async def test_options_flow_v2(hass):
) )
entry.add_to_hass(hass) entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(entry.entry_id) with pytest.raises(data_entry_flow.UnknownHandler):
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
async def test_bridge_zeroconf(hass, aioclient_mock): async def test_bridge_zeroconf(hass, aioclient_mock):