diff --git a/homeassistant/components/transmission/config_flow.py b/homeassistant/components/transmission/config_flow.py index fac4e770a26..d16981add87 100644 --- a/homeassistant/components/transmission/config_flow.py +++ b/homeassistant/components/transmission/config_flow.py @@ -7,13 +7,7 @@ from typing import Any import voluptuous as vol from homeassistant import config_entries -from homeassistant.const import ( - CONF_HOST, - CONF_PASSWORD, - CONF_PORT, - CONF_SCAN_INTERVAL, - CONF_USERNAME, -) +from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME from homeassistant.core import callback from homeassistant.data_entry_flow import FlowResult @@ -25,7 +19,6 @@ from .const import ( DEFAULT_NAME, DEFAULT_ORDER, DEFAULT_PORT, - DEFAULT_SCAN_INTERVAL, DOMAIN, SUPPORTED_ORDER_MODES, ) @@ -147,12 +140,6 @@ class TransmissionOptionsFlowHandler(config_entries.OptionsFlow): return self.async_create_entry(title="", data=user_input) options = { - vol.Optional( - CONF_SCAN_INTERVAL, - default=self.config_entry.options.get( - CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL - ), - ): int, vol.Optional( CONF_LIMIT, default=self.config_entry.options.get(CONF_LIMIT, DEFAULT_LIMIT), diff --git a/homeassistant/components/transmission/coordinator.py b/homeassistant/components/transmission/coordinator.py index a9cfc93eea0..9df509b9783 100644 --- a/homeassistant/components/transmission/coordinator.py +++ b/homeassistant/components/transmission/coordinator.py @@ -8,7 +8,7 @@ import transmission_rpc from transmission_rpc.session import SessionStats from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST, CONF_SCAN_INTERVAL +from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed @@ -48,14 +48,9 @@ class TransmissionDataUpdateCoordinator(DataUpdateCoordinator[SessionStats]): hass, name=f"{DOMAIN} - {self.host}", logger=_LOGGER, - update_interval=timedelta(seconds=self.scan_interval), + update_interval=timedelta(seconds=DEFAULT_SCAN_INTERVAL), ) - @property - def scan_interval(self) -> float: - """Return scan interval.""" - return self.config_entry.options.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL) - @property def limit(self) -> int: """Return limit.""" diff --git a/homeassistant/components/transmission/sensor.py b/homeassistant/components/transmission/sensor.py index 2bfa065c19b..c3ba418f885 100644 --- a/homeassistant/components/transmission/sensor.py +++ b/homeassistant/components/transmission/sensor.py @@ -36,7 +36,7 @@ async def async_setup_entry( config_entry.entry_id ] - dev = [ + entities = [ TransmissionSpeedSensor( coordinator, "download_speed", @@ -79,7 +79,7 @@ async def async_setup_entry( ), ] - async_add_entities(dev, True) + async_add_entities(entities) class TransmissionSensor( diff --git a/homeassistant/components/transmission/switch.py b/homeassistant/components/transmission/switch.py index bf01b5a9cdc..6d236964987 100644 --- a/homeassistant/components/transmission/switch.py +++ b/homeassistant/components/transmission/switch.py @@ -27,11 +27,11 @@ async def async_setup_entry( config_entry.entry_id ] - dev = [] + entities = [] for switch_type, switch_name in SWITCH_TYPES.items(): - dev.append(TransmissionSwitch(switch_type, switch_name, coordinator)) + entities.append(TransmissionSwitch(switch_type, switch_name, coordinator)) - async_add_entities(dev, True) + async_add_entities(entities) class TransmissionSwitch( diff --git a/tests/components/transmission/test_config_flow.py b/tests/components/transmission/test_config_flow.py index 1bfae98fb71..04f44d3b7e7 100644 --- a/tests/components/transmission/test_config_flow.py +++ b/tests/components/transmission/test_config_flow.py @@ -76,7 +76,7 @@ async def test_options(hass: HomeAssistant) -> None: entry = MockConfigEntry( domain=transmission.DOMAIN, data=MOCK_CONFIG_DATA, - options={"scan_interval": 120}, + options={"limit": 10, "order": "oldest_first"}, ) entry.add_to_hass(hass) @@ -93,11 +93,12 @@ async def test_options(hass: HomeAssistant) -> None: assert result["step_id"] == "init" result = await hass.config_entries.options.async_configure( - result["flow_id"], user_input={"scan_interval": 10} + result["flow_id"], user_input={"limit": 20} ) assert result["type"] == FlowResultType.CREATE_ENTRY - assert result["data"]["scan_interval"] == 10 + assert result["data"]["limit"] == 20 + assert result["data"]["order"] == "oldest_first" async def test_error_on_wrong_credentials(