Take into account the notify_only_if_changed parameter

This commit is contained in:
Fabio Manganiello 2023-01-07 23:09:42 +01:00
parent 2ee810bdc4
commit c5cf9803ff
Signed by: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 5 additions and 4 deletions

View file

@ -142,6 +142,7 @@ class HidPlugin(RunnablePlugin):
path = dev_def['path']
data_size = rule['data_size']
poll_seconds = rule['poll_seconds']
notify_only_if_changed = rule['notify_only_if_changed']
last_data = None
self.logger.info(f'Starting monitor for device {path}')
@ -162,7 +163,7 @@ class HidPlugin(RunnablePlugin):
wait()
continue
if len(data) and data != last_data:
if not notify_only_if_changed or data != last_data:
data_dump = ''.join(f'{x:02x}' for x in data)
get_bus().post(HidDeviceDataEvent(data=data_dump, **dev_def))
last_data = data

View file

@ -68,10 +68,10 @@ class HidMonitoredDeviceSchema(HidDeviceSchema):
)
poll_seconds = fields.Float(
missing=0.1,
missing=0,
metadata={
'description': 'How often we should check this device for new data '
'(default: 0.1 seconds)'
'description': 'How often we should wait before data reads '
'(default: no wait)'
},
)