mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Fix error handling in switch.broadlink module (#20772)
* Fix error handling in switch.broadlink module * Improve error messages
This commit is contained in:
parent
b8cc547fa3
commit
a1477fa156
@ -235,7 +235,7 @@ class BroadlinkRMSwitch(SwitchDevice):
|
||||
self._device.send_data(packet)
|
||||
except (socket.timeout, ValueError) as error:
|
||||
if retry < 1:
|
||||
_LOGGER.error(error)
|
||||
_LOGGER.error("Error during sending a packet: %s", error)
|
||||
return False
|
||||
if not self._auth():
|
||||
return False
|
||||
@ -247,6 +247,8 @@ class BroadlinkRMSwitch(SwitchDevice):
|
||||
auth = self._device.auth()
|
||||
except socket.timeout:
|
||||
auth = False
|
||||
if retry < 1:
|
||||
_LOGGER.error("Timeout during authorization")
|
||||
if not auth and retry > 0:
|
||||
return self._auth(retry-1)
|
||||
return auth
|
||||
@ -268,7 +270,7 @@ class BroadlinkSP1Switch(BroadlinkRMSwitch):
|
||||
self._device.set_power(packet)
|
||||
except (socket.timeout, ValueError) as error:
|
||||
if retry < 1:
|
||||
_LOGGER.error(error)
|
||||
_LOGGER.error("Error during sending a packet: %s", error)
|
||||
return False
|
||||
if not self._auth():
|
||||
return False
|
||||
@ -308,7 +310,7 @@ class BroadlinkSP2Switch(BroadlinkSP1Switch):
|
||||
load_power = self._device.get_energy()
|
||||
except (socket.timeout, ValueError) as error:
|
||||
if retry < 1:
|
||||
_LOGGER.error(error)
|
||||
_LOGGER.error("Error during updating the state: %s", error)
|
||||
return
|
||||
if not self._auth():
|
||||
return
|
||||
@ -341,7 +343,7 @@ class BroadlinkMP1Slot(BroadlinkRMSwitch):
|
||||
self._device.set_power(self._slot, packet)
|
||||
except (socket.timeout, ValueError) as error:
|
||||
if retry < 1:
|
||||
_LOGGER.error(error)
|
||||
_LOGGER.error("Error during sending a packet: %s", error)
|
||||
return False
|
||||
if not self._auth():
|
||||
return False
|
||||
@ -382,7 +384,7 @@ class BroadlinkMP1Switch:
|
||||
states = self._device.check_power()
|
||||
except (socket.timeout, ValueError) as error:
|
||||
if retry < 1:
|
||||
_LOGGER.error(error)
|
||||
_LOGGER.error("Error during updating the state: %s", error)
|
||||
return
|
||||
if not self._auth():
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user