From 03dac6e1711eff743bb1d8b9681c8ee7411c307d Mon Sep 17 00:00:00 2001 From: Eric Severance Date: Wed, 28 Jun 2023 11:27:10 -0700 Subject: [PATCH] Remove polling_interval_seconds option from wemo (#95468) --- homeassistant/components/wemo/strings.json | 4 +-- homeassistant/components/wemo/wemo_device.py | 23 ++------------- tests/components/wemo/test_config_flow.py | 6 ---- tests/components/wemo/test_wemo_device.py | 31 -------------------- 4 files changed, 4 insertions(+), 60 deletions(-) diff --git a/homeassistant/components/wemo/strings.json b/homeassistant/components/wemo/strings.json index dfe5d94bb8a..b218f758985 100644 --- a/homeassistant/components/wemo/strings.json +++ b/homeassistant/components/wemo/strings.json @@ -15,14 +15,12 @@ "init": { "data": { "enable_subscription": "Subscribe to device local push updates", - "enable_long_press": "Register for device long-press events", - "polling_interval_seconds": "Seconds to wait between polling the device" + "enable_long_press": "Register for device long-press events" } } }, "error": { "long_press_requires_subscription": "Local push update subscriptions must be enabled to use long-press events", - "polling_interval_to_small": "Polling more frequently than 10 seconds is not supported", "unknown": "[%key:common::config_flow::error::unknown%]" } }, diff --git a/homeassistant/components/wemo/wemo_device.py b/homeassistant/components/wemo/wemo_device.py index 902b196fe7d..65431fb7657 100644 --- a/homeassistant/components/wemo/wemo_device.py +++ b/homeassistant/components/wemo/wemo_device.py @@ -34,13 +34,9 @@ from .const import DOMAIN, WEMO_SUBSCRIPTION_EVENT _LOGGER = logging.getLogger(__name__) # Literal values must match options.error keys from strings.json. -ErrorStringKey = Literal[ - "long_press_requires_subscription", "polling_interval_to_small" -] +ErrorStringKey = Literal["long_press_requires_subscription"] # Literal values must match options.step.init.data keys from strings.json. -OptionsFieldKey = Literal[ - "enable_subscription", "enable_long_press", "polling_interval_seconds" -] +OptionsFieldKey = Literal["enable_subscription", "enable_long_press"] class OptionsValidationError(Exception): @@ -78,9 +74,6 @@ class Options: # Register for device long-press events. enable_long_press: bool = True - # Polling interval for when subscriptions are not enabled or broken. - polling_interval_seconds: int = 30 - def __post_init__(self) -> None: """Validate parameters.""" if not self.enable_subscription and self.enable_long_press: @@ -89,12 +82,6 @@ class Options: "long_press_requires_subscription", "Local push update subscriptions must be enabled to use long-press events", ) - if self.polling_interval_seconds < 10: - raise OptionsValidationError( - "polling_interval_seconds", - "polling_interval_to_small", - "Polling more frequently than 10 seconds is not supported", - ) class DeviceCoordinator(DataUpdateCoordinator[None]): @@ -108,6 +95,7 @@ class DeviceCoordinator(DataUpdateCoordinator[None]): hass, _LOGGER, name=wemo.name, + update_interval=timedelta(seconds=30), ) self.hass = hass self.wemo = wemo @@ -164,11 +152,6 @@ class DeviceCoordinator(DataUpdateCoordinator[None]): ) self.supports_long_press = False - async def _async_set_polling_interval_seconds( - self, polling_interval_seconds: int - ) -> None: - self.update_interval = timedelta(seconds=polling_interval_seconds) - async def async_set_options( self, hass: HomeAssistant, config_entry: ConfigEntry ) -> None: diff --git a/tests/components/wemo/test_config_flow.py b/tests/components/wemo/test_config_flow.py index e84ae4f0205..71f3a378b74 100644 --- a/tests/components/wemo/test_config_flow.py +++ b/tests/components/wemo/test_config_flow.py @@ -61,9 +61,3 @@ async def test_invalid_options(hass: HomeAssistant) -> None: assert result["errors"] == { "enable_subscription": "long_press_requires_subscription" } - - # polling_interval_seconds must be larger than 10. - result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={"polling_interval_seconds": 1} - ) - assert result["errors"] == {"polling_interval_seconds": "polling_interval_to_small"} diff --git a/tests/components/wemo/test_wemo_device.py b/tests/components/wemo/test_wemo_device.py index 2ace50f5543..b715dd4ba72 100644 --- a/tests/components/wemo/test_wemo_device.py +++ b/tests/components/wemo/test_wemo_device.py @@ -214,37 +214,6 @@ async def test_options_enable_long_press_false(hass, pywemo_device, wemo_entity) pywemo_device.remove_long_press_virtual_device.assert_called_once_with() -async def test_options_polling_interval_seconds(hass, pywemo_device, wemo_entity): - """Test setting Options.polling_interval_seconds = 45.""" - config_entry = hass.config_entries.async_get_entry(wemo_entity.config_entry_id) - assert hass.config_entries.async_update_entry( - config_entry, - options=asdict( - wemo_device.Options( - enable_subscription=False, - enable_long_press=False, - polling_interval_seconds=45, - ) - ), - ) - await hass.async_block_till_done() - - # Move time forward to capture the new interval. - async_fire_time_changed(hass, utcnow() + timedelta(seconds=31)) - await hass.async_block_till_done() - pywemo_device.get_state.reset_mock() - - # Make sure no polling occurs before 45 seconds. - async_fire_time_changed(hass, utcnow() + timedelta(seconds=31)) - await hass.async_block_till_done() - pywemo_device.get_state.assert_not_called() - - # Polling occurred after the interval. - async_fire_time_changed(hass, utcnow() + timedelta(seconds=46)) - await hass.async_block_till_done() - pywemo_device.get_state.assert_has_calls([call(True), call()]) - - class TestInsight: """Tests specific to the WeMo Insight device."""