Modify dbus python service to read forward and reverse from node red

This commit is contained in:
Carsten Schmiemann 2022-08-30 02:59:37 +02:00
parent bc03b8d259
commit 6e9085066b

View file

@ -98,7 +98,6 @@ class NodeRedMeterEinspeisung:
#send data to DBus #send data to DBus
self._dbusservice['/Ac/Power'] = meter_data['einspeisung']['total_power'] # positive: consumption, negative: feed into grid self._dbusservice['/Ac/Power'] = meter_data['einspeisung']['total_power'] # positive: consumption, negative: feed into grid
self._dbusservice['/Ac/Energy/Forward'] = meter_data['einspeisung']['total_kwh'];
self._dbusservice['/Ac/Current'] = meter_data['einspeisung']['total_current'] self._dbusservice['/Ac/Current'] = meter_data['einspeisung']['total_current']
self._dbusservice['/Ac/L1/Voltage'] = meter_data['einspeisung']['l1_voltage'] self._dbusservice['/Ac/L1/Voltage'] = meter_data['einspeisung']['l1_voltage']
self._dbusservice['/Ac/L2/Voltage'] = meter_data['einspeisung']['l2_voltage'] self._dbusservice['/Ac/L2/Voltage'] = meter_data['einspeisung']['l2_voltage']
@ -112,9 +111,16 @@ class NodeRedMeterEinspeisung:
self._dbusservice['/Ac/L1/Energy/Forward'] = meter_data['einspeisung']['l1_import'] self._dbusservice['/Ac/L1/Energy/Forward'] = meter_data['einspeisung']['l1_import']
self._dbusservice['/Ac/L2/Energy/Forward'] = meter_data['einspeisung']['l2_import'] self._dbusservice['/Ac/L2/Energy/Forward'] = meter_data['einspeisung']['l2_import']
self._dbusservice['/Ac/L3/Energy/Forward'] = meter_data['einspeisung']['l3_import'] self._dbusservice['/Ac/L3/Energy/Forward'] = meter_data['einspeisung']['l3_import']
self._dbusservice['/Ac/L1/Energy/Reverse'] = meter_data['einspeisung']['l1_export']
self._dbusservice['/Ac/L2/Energy/Reverse'] = meter_data['einspeisung']['l2_export']
self._dbusservice['/Ac/L3/Energy/Reverse'] = meter_data['einspeisung']['l3_export']
self._dbusservice['/Ac/Energy/Forward'] = meter_data['einspeisung']['total_import']
self._dbusservice['/Ac/Energy/Reverse'] = meter_data['einspeisung']['total_export']
#logging #logging
logging.debug("House Consumption (/Ac/Power): %s" % (self._dbusservice['/Ac/Power'])) logging.debug("House Consumption (/Ac/Power): %s" % (self._dbusservice['/Ac/Power']))
logging.debug("House Forward (/Ac/Energy/Forward): %s" % (self._dbusservice['/Ac/Energy/Forward']))
logging.debug("House Reverse (/Ac/Energy/Revers): %s" % (self._dbusservice['/Ac/Energy/Reverse']))
logging.debug("---"); logging.debug("---");
# increment UpdateIndex - to show that new data is available # increment UpdateIndex - to show that new data is available
@ -165,9 +171,10 @@ def main():
servicename='com.victronenergy.grid', servicename='com.victronenergy.grid',
deviceinstance=40, deviceinstance=40,
paths={ paths={
'/Ac/Power': {'initial': 0, 'textformat': _w}, '/Ac/Energy/Forward': {'initial': 0, 'textformat': _kwh}, # energy bought from the grid, summ'd over all phases
'/Ac/Energy/Forward': {'initial': 0, 'textformat': _kwh}, '/Ac/Energy/Reverse': {'initial': 0, 'textformat': _kwh}, # energy sold to the grid, summ'd over all phases
'/Ac/Current': {'initial': 0, 'textformat': _a}, '/Ac/Power': {'initial': 0, 'textformat': _w}, # power accumulated over all phases for ess regulation
'/Ac/Current': {'initial': 0, 'textformat': _a}, # current accumulated over all phases
'/Ac/L1/Voltage': {'initial': 0, 'textformat': _v}, '/Ac/L1/Voltage': {'initial': 0, 'textformat': _v},
'/Ac/L2/Voltage': {'initial': 0, 'textformat': _v}, '/Ac/L2/Voltage': {'initial': 0, 'textformat': _v},
'/Ac/L3/Voltage': {'initial': 0, 'textformat': _v}, '/Ac/L3/Voltage': {'initial': 0, 'textformat': _v},
@ -180,6 +187,9 @@ def main():
'/Ac/L1/Energy/Forward': {'initial': 0, 'textformat': _kwh}, '/Ac/L1/Energy/Forward': {'initial': 0, 'textformat': _kwh},
'/Ac/L2/Energy/Forward': {'initial': 0, 'textformat': _kwh}, '/Ac/L2/Energy/Forward': {'initial': 0, 'textformat': _kwh},
'/Ac/L3/Energy/Forward': {'initial': 0, 'textformat': _kwh}, '/Ac/L3/Energy/Forward': {'initial': 0, 'textformat': _kwh},
'/Ac/L1/Energy/Reverse': {'initial': 0, 'textformat': _kwh},
'/Ac/L2/Energy/Reverse': {'initial': 0, 'textformat': _kwh},
'/Ac/L3/Energy/Reverse': {'initial': 0, 'textformat': _kwh},
}) })
logging.info('Connected to dbus, and switching over to gobject.MainLoop() (= event based)') logging.info('Connected to dbus, and switching over to gobject.MainLoop() (= event based)')