forked from platypush/platypush
Take into account the notify_only_if_changed parameter
This commit is contained in:
parent
6630873e2c
commit
e8f767d819
2 changed files with 5 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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)'
|
||||
},
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue