Remove remnants of configurable RainMachine scan interval (#42239)

* Remove remnants of configurable RainMachine scan interval

* Clean up tests

* Cleanup
This commit is contained in:
Aaron Bach 2020-10-22 20:32:04 -06:00 committed by GitHub
parent 6e53aa1155
commit 536f1186b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 31 deletions

View File

@ -12,7 +12,6 @@ from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_PASSWORD,
CONF_PORT,
CONF_SCAN_INTERVAL,
CONF_SSL,
)
from homeassistant.core import callback
@ -32,7 +31,6 @@ from .const import (
DATA_RESTRICTIONS_UNIVERSAL,
DATA_ZONES,
DATA_ZONES_DETAILS,
DEFAULT_SCAN_INTERVAL,
DEFAULT_ZONE_RUN,
DOMAIN,
PROGRAM_UPDATE_TOPIC,
@ -48,6 +46,7 @@ CONF_ZONE_ID = "zone_id"
DEFAULT_ATTRIBUTION = "Data provided by Green Electronics LLC"
DEFAULT_ICON = "mdi:water"
DEFAULT_SCAN_INTERVAL = timedelta(seconds=60)
DEFAULT_SSL = True
SERVICE_ALTER_PROGRAM = vol.Schema({vol.Required(CONF_PROGRAM_ID): cv.positive_int})
@ -113,9 +112,6 @@ async def async_setup_entry(hass, config_entry):
hass,
controller,
config_entry.data.get(CONF_ZONE_RUN_TIME, DEFAULT_ZONE_RUN),
config_entry.data.get(
CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL.total_seconds()
),
)
# Update the data object, which at this point (prior to any sensors registering
@ -231,10 +227,9 @@ async def async_unload_entry(hass, config_entry):
class RainMachine:
"""Define a generic RainMachine object."""
def __init__(self, hass, controller, default_zone_runtime, scan_interval):
def __init__(self, hass, controller, default_zone_runtime):
"""Initialize."""
self._async_cancel_time_interval_listener = None
self._scan_interval_seconds = scan_interval
self.controller = controller
self.data = {}
self.default_zone_runtime = default_zone_runtime
@ -296,7 +291,7 @@ class RainMachine:
self._async_cancel_time_interval_listener = async_track_time_interval(
self.hass,
self._async_update_listener_action,
timedelta(seconds=self._scan_interval_seconds),
DEFAULT_SCAN_INTERVAL,
)
self._api_category_count[api_category] += 1

View File

@ -4,19 +4,12 @@ from regenmaschine.errors import RainMachineError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_PASSWORD,
CONF_PORT,
CONF_SCAN_INTERVAL,
CONF_SSL,
)
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL
from homeassistant.helpers import aiohttp_client
from .const import ( # pylint: disable=unused-import
CONF_ZONE_RUN_TIME,
DEFAULT_PORT,
DEFAULT_SCAN_INTERVAL,
DEFAULT_ZONE_RUN,
DOMAIN,
)
@ -77,9 +70,6 @@ class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
CONF_PASSWORD: user_input[CONF_PASSWORD],
CONF_PORT: user_input[CONF_PORT],
CONF_SSL: user_input.get(CONF_SSL, True),
CONF_SCAN_INTERVAL: user_input.get(
CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL.total_seconds()
),
CONF_ZONE_RUN_TIME: user_input.get(
CONF_ZONE_RUN_TIME, DEFAULT_ZONE_RUN
),

View File

@ -1,6 +1,4 @@
"""Define constants for the SimpliSafe component."""
from datetime import timedelta
DOMAIN = "rainmachine"
CONF_ZONE_RUN_TIME = "zone_run_time"
@ -14,7 +12,6 @@ DATA_ZONES = "zones"
DATA_ZONES_DETAILS = "zones_details"
DEFAULT_PORT = 8080
DEFAULT_SCAN_INTERVAL = timedelta(seconds=60)
DEFAULT_ZONE_RUN = 60 * 10
PROGRAM_UPDATE_TOPIC = f"{DOMAIN}_program_update"

View File

@ -4,13 +4,7 @@ from regenmaschine.errors import RainMachineError
from homeassistant import data_entry_flow
from homeassistant.components.rainmachine import CONF_ZONE_RUN_TIME, DOMAIN, config_flow
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_PASSWORD,
CONF_PORT,
CONF_SCAN_INTERVAL,
CONF_SSL,
)
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL
from tests.async_mock import patch
from tests.common import MockConfigEntry
@ -76,7 +70,6 @@ async def test_step_user(hass):
CONF_PASSWORD: "password",
CONF_PORT: 8080,
CONF_SSL: True,
CONF_SCAN_INTERVAL: 60,
}
flow = config_flow.RainMachineFlowHandler()
@ -96,6 +89,5 @@ async def test_step_user(hass):
CONF_PASSWORD: "password",
CONF_PORT: 8080,
CONF_SSL: True,
CONF_SCAN_INTERVAL: 60,
CONF_ZONE_RUN_TIME: 600,
}