Move imports to top for rainmachine (#29472)

This commit is contained in:
springstan authored and Paulus Schoutsen committed 2019-12-04 21:12:44 -08:00
1 parent c6b8d35c16
commit d9661b408b
3 files changed
+9 -14

No files matched your search

@@ -1,8 +1,10 @@
"""Support for RainMachine devices."""
import asyncio
import logging
from datetime import timedelta
import logging
from regenmaschine import login
from regenmaschine.errors import RainMachineError
import voluptuous as vol
from homeassistant.config_entries import SOURCE_IMPORT
@@ -10,12 +12,12 @@ from homeassistant.const import (
ATTR_ATTRIBUTION,
CONF_BINARY_SENSORS,
CONF_IP_ADDRESS,
CONF_MONITORED_CONDITIONS,
CONF_PASSWORD,
CONF_PORT,
CONF_SCAN_INTERVAL,
CONF_SENSORS,
CONF_SSL,
CONF_MONITORED_CONDITIONS,
CONF_SWITCHES,
)
from homeassistant.exceptions import ConfigEntryNotReady
@@ -211,8 +213,6 @@ async def async_setup(hass, config):
async def async_setup_entry(hass, config_entry):
"""Set up RainMachine as config entry."""
from regenmaschine import login
from regenmaschine.errors import RainMachineError
_verify_domain_control = verify_domain_control(hass, DOMAIN)
@@ -377,7 +377,6 @@ class RainMachine:
async def async_update(self):
"""Update sensor/binary sensor data."""
from regenmaschine.errors import RainMachineError
tasks = {}
@@ -2,10 +2,11 @@
from collections import OrderedDict
from regenmaschine import login
from regenmaschine.errors import RainMachineError
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.core import callback
from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_PASSWORD,
@@ -13,6 +14,7 @@ from homeassistant.const import (
CONF_SCAN_INTERVAL,
CONF_SSL,
)
from homeassistant.core import callback
from homeassistant.helpers import aiohttp_client
from .const import DEFAULT_PORT, DEFAULT_SCAN_INTERVAL, DEFAULT_SSL, DOMAIN
@@ -55,8 +57,6 @@ class RainMachineFlowHandler(config_entries.ConfigFlow):
async def async_step_user(self, user_input=None):
"""Handle the start of the config flow."""
from regenmaschine import login
from regenmaschine.errors import RainMachineError
if not user_input:
return await self._show_form()
@@ -2,6 +2,8 @@
from datetime import datetime
import logging
from regenmaschine.errors import RequestError
from homeassistant.components.switch import SwitchDevice
from homeassistant.const import ATTR_ID
from homeassistant.core import callback
@@ -181,7 +183,6 @@ class RainMachineProgram(RainMachineSwitch):
async def async_turn_off(self, **kwargs) -> None:
"""Turn the program off."""
from regenmaschine.errors import RequestError
try:
await self.rainmachine.client.programs.stop(self._rainmachine_entity_id)
@@ -193,7 +194,6 @@ class RainMachineProgram(RainMachineSwitch):
async def async_turn_on(self, **kwargs) -> None:
"""Turn the program on."""
from regenmaschine.errors import RequestError
try:
await self.rainmachine.client.programs.start(self._rainmachine_entity_id)
@@ -205,7 +205,6 @@ class RainMachineProgram(RainMachineSwitch):
async def async_update(self) -> None:
"""Update info for the program."""
from regenmaschine.errors import RequestError
try:
self._obj = await self.rainmachine.client.programs.get(
@@ -265,7 +264,6 @@ class RainMachineZone(RainMachineSwitch):
async def async_turn_off(self, **kwargs) -> None:
"""Turn the zone off."""
from regenmaschine.errors import RequestError
try:
await self.rainmachine.client.zones.stop(self._rainmachine_entity_id)
@@ -274,7 +272,6 @@ class RainMachineZone(RainMachineSwitch):
async def async_turn_on(self, **kwargs) -> None:
"""Turn the zone on."""
from regenmaschine.errors import RequestError
try:
await self.rainmachine.client.zones.start(
@@ -285,7 +282,6 @@ class RainMachineZone(RainMachineSwitch):
async def async_update(self) -> None:
"""Update info for the zone."""
from regenmaschine.errors import RequestError
try:
self._obj = await self.rainmachine.client.zones.get(