Make waterfurnace recovery more robust (#12202)
This makes waterfurnace recovery more robust by catching any understood exceptions by the library, and always doing another login.
This commit is contained in:
parent
f58e5f442d
commit
6f74b672a3
2 changed files with 9 additions and 8 deletions
|
@ -18,7 +18,7 @@ from homeassistant.core import callback
|
|||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers import discovery
|
||||
|
||||
REQUIREMENTS = ["waterfurnace==0.3.0"]
|
||||
REQUIREMENTS = ["waterfurnace==0.4.0"]
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -83,6 +83,8 @@ class WaterFurnaceData(threading.Thread):
|
|||
|
||||
def run(self):
|
||||
"""Thread run loop."""
|
||||
import waterfurnace.waterfurnace as wf
|
||||
|
||||
@callback
|
||||
def register():
|
||||
"""Connect to hass for shutdown."""
|
||||
|
@ -110,8 +112,11 @@ class WaterFurnaceData(threading.Thread):
|
|||
try:
|
||||
self.data = self.client.read()
|
||||
|
||||
except ConnectionError:
|
||||
# attempt to log back in if there was a session expiration.
|
||||
except wf.WFException:
|
||||
# WFExceptions are things the WF library understands
|
||||
# that pretty much can all be solved by logging in and
|
||||
# back out again.
|
||||
_LOGGER.exception("Failed to read data, attempting to recover")
|
||||
try:
|
||||
self.client.login()
|
||||
except Exception: # pylint: disable=broad-except
|
||||
|
@ -127,10 +132,6 @@ class WaterFurnaceData(threading.Thread):
|
|||
"Lost our connection to websocket, trying again")
|
||||
time.sleep(SCAN_INTERVAL.seconds)
|
||||
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.exception("Error updating waterfurnace data.")
|
||||
time.sleep(SCAN_INTERVAL.seconds)
|
||||
|
||||
else:
|
||||
self.hass.helpers.dispatcher.dispatcher_send(UPDATE_TOPIC)
|
||||
time.sleep(SCAN_INTERVAL.seconds)
|
||||
|
|
|
@ -1223,7 +1223,7 @@ waqiasync==1.0.0
|
|||
warrant==0.6.1
|
||||
|
||||
# homeassistant.components.waterfurnace
|
||||
waterfurnace==0.3.0
|
||||
waterfurnace==0.4.0
|
||||
|
||||
# homeassistant.components.media_player.gpmdp
|
||||
websocket-client==0.37.0
|
||||
|
|
Loading…
Add table
Reference in a new issue