mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 20:55:10 +02:00
Move imports in waterfurnace component (#27449)
This commit is contained in:
committed by
Fabian Affolter
parent
cb30065a40
commit
8bd847ed39
@@ -5,6 +5,7 @@ import time
|
||||
import threading
|
||||
|
||||
import voluptuous as vol
|
||||
from waterfurnace.waterfurnace import WaterFurnace, WFCredentialError, WFException
|
||||
|
||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import callback
|
||||
@@ -37,19 +38,18 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
|
||||
def setup(hass, base_config):
|
||||
"""Set up waterfurnace platform."""
|
||||
import waterfurnace.waterfurnace as wf
|
||||
|
||||
config = base_config.get(DOMAIN)
|
||||
|
||||
username = config.get(CONF_USERNAME)
|
||||
password = config.get(CONF_PASSWORD)
|
||||
|
||||
wfconn = wf.WaterFurnace(username, password)
|
||||
wfconn = WaterFurnace(username, password)
|
||||
# NOTE(sdague): login will throw an exception if this doesn't
|
||||
# work, which will abort the setup.
|
||||
try:
|
||||
wfconn.login()
|
||||
except wf.WFCredentialError:
|
||||
except WFCredentialError:
|
||||
_LOGGER.error("Invalid credentials for waterfurnace login.")
|
||||
return False
|
||||
|
||||
@@ -83,7 +83,6 @@ class WaterFurnaceData(threading.Thread):
|
||||
|
||||
def _reconnect(self):
|
||||
"""Reconnect on a failure."""
|
||||
import waterfurnace.waterfurnace as wf
|
||||
|
||||
self._fails += 1
|
||||
if self._fails > MAX_FAILS:
|
||||
@@ -105,7 +104,7 @@ class WaterFurnaceData(threading.Thread):
|
||||
try:
|
||||
self.client.login()
|
||||
self.data = self.client.read()
|
||||
except wf.WFException:
|
||||
except WFException:
|
||||
_LOGGER.exception("Failed to reconnect attempt %s", self._fails)
|
||||
else:
|
||||
_LOGGER.debug("Reconnected to furnace")
|
||||
@@ -113,7 +112,6 @@ class WaterFurnaceData(threading.Thread):
|
||||
|
||||
def run(self):
|
||||
"""Thread run loop."""
|
||||
import waterfurnace.waterfurnace as wf
|
||||
|
||||
@callback
|
||||
def register():
|
||||
@@ -143,7 +141,7 @@ class WaterFurnaceData(threading.Thread):
|
||||
try:
|
||||
self.data = self.client.read()
|
||||
|
||||
except wf.WFException:
|
||||
except WFException:
|
||||
# WFExceptions are things the WF library understands
|
||||
# that pretty much can all be solved by logging in and
|
||||
# back out again.
|
||||
|
Reference in New Issue
Block a user