mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 22:07:10 +00:00
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
@ -18,7 +18,7 @@ from homeassistant.core import callback
|
|||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
|
|
||||||
REQUIREMENTS = ["waterfurnace==0.3.0"]
|
REQUIREMENTS = ["waterfurnace==0.4.0"]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -83,6 +83,8 @@ class WaterFurnaceData(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Thread run loop."""
|
"""Thread run loop."""
|
||||||
|
import waterfurnace.waterfurnace as wf
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def register():
|
def register():
|
||||||
"""Connect to hass for shutdown."""
|
"""Connect to hass for shutdown."""
|
||||||
@ -110,8 +112,11 @@ class WaterFurnaceData(threading.Thread):
|
|||||||
try:
|
try:
|
||||||
self.data = self.client.read()
|
self.data = self.client.read()
|
||||||
|
|
||||||
except ConnectionError:
|
except wf.WFException:
|
||||||
# attempt to log back in if there was a session expiration.
|
# 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:
|
try:
|
||||||
self.client.login()
|
self.client.login()
|
||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
@ -127,10 +132,6 @@ class WaterFurnaceData(threading.Thread):
|
|||||||
"Lost our connection to websocket, trying again")
|
"Lost our connection to websocket, trying again")
|
||||||
time.sleep(SCAN_INTERVAL.seconds)
|
time.sleep(SCAN_INTERVAL.seconds)
|
||||||
|
|
||||||
except Exception: # pylint: disable=broad-except
|
|
||||||
_LOGGER.exception("Error updating waterfurnace data.")
|
|
||||||
time.sleep(SCAN_INTERVAL.seconds)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.hass.helpers.dispatcher.dispatcher_send(UPDATE_TOPIC)
|
self.hass.helpers.dispatcher.dispatcher_send(UPDATE_TOPIC)
|
||||||
time.sleep(SCAN_INTERVAL.seconds)
|
time.sleep(SCAN_INTERVAL.seconds)
|
||||||
|
@ -1223,7 +1223,7 @@ waqiasync==1.0.0
|
|||||||
warrant==0.6.1
|
warrant==0.6.1
|
||||||
|
|
||||||
# homeassistant.components.waterfurnace
|
# homeassistant.components.waterfurnace
|
||||||
waterfurnace==0.3.0
|
waterfurnace==0.4.0
|
||||||
|
|
||||||
# homeassistant.components.media_player.gpmdp
|
# homeassistant.components.media_player.gpmdp
|
||||||
websocket-client==0.37.0
|
websocket-client==0.37.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user