Make the velbus component more robust in handling errors (#25567)
* Add some try excepts for velbus as the python-velbus lib is not good in handling these * Only catch velbusExceptions * only wrap the lines that can cause the exception * Fix indentation mixup
This commit is contained in:
1 parent
67cae00caa
commit
15ae970941
4 files changed
+42
-10
No files matched your search
@@ -1,6 +1,8 @@
|
||||
"""Support for Velbus switches."""
|
||||
import logging
|
||||
|
||||
from velbus.util import VelbusException
|
||||
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
|
||||
from . import VelbusEntity
|
||||
@@ -37,8 +39,14 @@ class VelbusSwitch(VelbusEntity, SwitchDevice):
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Instruct the switch to turn on."""
|
||||
self._module.turn_on(self._channel)
|
||||
try:
|
||||
self._module.turn_on(self._channel)
|
||||
except VelbusException as err:
|
||||
_LOGGER.error('A Velbus error occurred: %s', err)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Instruct the switch to turn off."""
|
||||
self._module.turn_off(self._channel)
|
||||
try:
|
||||
self._module.turn_off(self._channel)
|
||||
except VelbusException as err:
|
||||
_LOGGER.error('A Velbus error occurred: %s', err)
|
||||
Reference in new issue
Block a user