diff --git a/homeassistant/components/blink/__init__.py b/homeassistant/components/blink/__init__.py index d83c2686563..50c7fad516a 100644 --- a/homeassistant/components/blink/__init__.py +++ b/homeassistant/components/blink/__init__.py @@ -107,7 +107,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data[DOMAIN][entry.entry_id] = coordinator await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) - entry.async_on_unload(entry.add_update_listener(update_listener)) return True @@ -129,9 +128,3 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS): hass.data[DOMAIN].pop(entry.entry_id) return unload_ok - - -async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None: - """Handle options update.""" - blink: Blink = hass.data[DOMAIN][entry.entry_id].api - blink.refresh_rate = entry.options[CONF_SCAN_INTERVAL] diff --git a/homeassistant/components/blink/config_flow.py b/homeassistant/components/blink/config_flow.py index 4326c6cb86c..aaacbb9390c 100644 --- a/homeassistant/components/blink/config_flow.py +++ b/homeassistant/components/blink/config_flow.py @@ -9,46 +9,17 @@ from blinkpy.auth import Auth, LoginError, TokenRefreshFailed from blinkpy.blinkpy import Blink, BlinkSetupError import voluptuous as vol -from homeassistant.config_entries import ConfigEntry, ConfigFlow -from homeassistant.const import ( - CONF_PASSWORD, - CONF_PIN, - CONF_SCAN_INTERVAL, - CONF_USERNAME, -) +from homeassistant.config_entries import ConfigFlow +from homeassistant.const import CONF_PASSWORD, CONF_PIN, CONF_USERNAME from homeassistant.core import HomeAssistant, callback from homeassistant.data_entry_flow import FlowResult from homeassistant.exceptions import HomeAssistantError -from homeassistant.helpers import selector from homeassistant.helpers.aiohttp_client import async_get_clientsession -from homeassistant.helpers.schema_config_entry_flow import ( - SchemaFlowFormStep, - SchemaOptionsFlowHandler, -) -from .const import DEFAULT_SCAN_INTERVAL, DEVICE_ID, DOMAIN +from .const import DEVICE_ID, DOMAIN _LOGGER = logging.getLogger(__name__) -SIMPLE_OPTIONS_SCHEMA = vol.Schema( - { - vol.Optional( - CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL - ): selector.NumberSelector( - selector.NumberSelectorConfig( - mode=selector.NumberSelectorMode.BOX, - unit_of_measurement="seconds", - ), - ), - } -) - - -OPTIONS_FLOW = { - "init": SchemaFlowFormStep(next_step="simple_options"), - "simple_options": SchemaFlowFormStep(SIMPLE_OPTIONS_SCHEMA), -} - async def validate_input(auth: Auth) -> None: """Validate the user input allows us to connect.""" @@ -78,14 +49,6 @@ class BlinkConfigFlow(ConfigFlow, domain=DOMAIN): """Initialize the blink flow.""" self.auth: Auth | None = None - @staticmethod - @callback - def async_get_options_flow( - config_entry: ConfigEntry, - ) -> SchemaOptionsFlowHandler: - """Get options flow for this handler.""" - return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW) - async def async_step_user( self, user_input: dict[str, Any] | None = None ) -> FlowResult: diff --git a/tests/components/blink/test_config_flow.py b/tests/components/blink/test_config_flow.py index ada38451754..e5ce3c83fb7 100644 --- a/tests/components/blink/test_config_flow.py +++ b/tests/components/blink/test_config_flow.py @@ -1,5 +1,5 @@ """Test the Blink config flow.""" -from unittest.mock import AsyncMock, Mock, patch +from unittest.mock import patch from blinkpy.auth import LoginError from blinkpy.blinkpy import BlinkSetupError @@ -8,8 +8,6 @@ from homeassistant import config_entries, data_entry_flow from homeassistant.components.blink import DOMAIN from homeassistant.core import HomeAssistant -from tests.common import MockConfigEntry - async def test_form(hass: HomeAssistant) -> None: """Test we get the form.""" @@ -258,46 +256,3 @@ async def test_reauth_shows_user_step(hass: HomeAssistant) -> None: ) assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "user" - - -async def test_options_flow(hass: HomeAssistant) -> None: - """Test config flow options.""" - config_entry = MockConfigEntry( - domain=DOMAIN, - data={"username": "blink@example.com", "password": "example"}, - options={}, - entry_id=1, - version=3, - ) - config_entry.add_to_hass(hass) - - mock_auth = AsyncMock( - startup=Mock(return_value=True), check_key_required=Mock(return_value=False) - ) - mock_blink = AsyncMock(cameras=Mock(), sync=Mock()) - - with patch("homeassistant.components.blink.Auth", return_value=mock_auth), patch( - "homeassistant.components.blink.Blink", return_value=mock_blink - ): - await hass.config_entries.async_setup(config_entry.entry_id) - await hass.async_block_till_done() - - result = await hass.config_entries.options.async_init( - config_entry.entry_id, context={"show_advanced_options": False} - ) - - assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["step_id"] == "simple_options" - - with patch("homeassistant.components.blink.Auth", return_value=mock_auth), patch( - "homeassistant.components.blink.Blink", return_value=mock_blink - ): - result = await hass.config_entries.options.async_configure( - result["flow_id"], - user_input={"scan_interval": 5}, - ) - assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY - assert result["data"] == {"scan_interval": 5} - await hass.async_block_till_done() - - assert mock_blink.refresh_rate == 5