Always wait 5 seconds (regardless of the poll interval) in case of errors.

Also, print the error only on the first occurrence, to prevent log
spamming.
This commit is contained in:
Fabio Manganiello 2023-01-07 23:21:59 +01:00
parent c5cf9803ff
commit 40bdc3b7f3
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -158,9 +158,10 @@ class HidPlugin(RunnablePlugin):
device = hid.Device(dev_def['vendor_id'], dev_def['product_id']) # type: ignore device = hid.Device(dev_def['vendor_id'], dev_def['product_id']) # type: ignore
data = device.read(data_size) data = device.read(data_size)
except Exception as e: except Exception as e:
self.logger.warning(f'Read error from {path}: {e}') if device:
self.logger.warning(f'Read error from {path}: {e}')
device = None device = None
wait() sleep(5)
continue continue
if not notify_only_if_changed or data != last_data: if not notify_only_if_changed or data != last_data: