Skip to content

Commit

Permalink
handle ItemsChanged signals
Browse files Browse the repository at this point in the history
The previous PropertiesChanged on root implementation has been
replaced with an ItemsChanged signal that does the same job.
This time, instead of recording the message as is, we
instead unroll it. This will be compensated for during replay
in giving the user the option to replay the recording in packed
ItemsChanged signals or individual PropertiesChanged signals.

victronenergy/venus#789
  • Loading branch information
izak committed Oct 19, 2021
1 parent 186569f commit 5ad725f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dbusdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, bus, name, eventCallback):
self._dbus_conn.add_signal_receiver(self._on_dbus_value_changed,
dbus_interface='com.victronenergy.BusItem', signal_name='PropertiesChanged', path_keyword='path',
sender_keyword='service_id')
self._dbus_conn.add_signal_receiver(self._on_dbus_items_changed,
dbus_interface='com.victronenergy.BusItem',
signal_name='ItemsChanged', path='/', sender_keyword='service_id')

def __del__(self):
logger.debug('__del__ %s' % self)
Expand All @@ -26,6 +29,11 @@ def _on_dbus_value_changed(self, changes, path=None, service_id=None):
if service_id == self._service_id:
self._eventCallback(self._dbus_name, path, changes)

def _on_dbus_items_changed(self, items, service_id=None):
if service_id == self._service_id:
for path, changes in items.items():
self._eventCallback(self._dbus_name, path, changes)

## Returns the dbus-service-name which represents the Victron-device.
def __str__(self):
return "DbusDevice=%s" % self._dbus_name
Expand Down

0 comments on commit 5ad725f

Please sign in to comment.