Skip to content

Commit 85a8b61

Browse files
committed
Fix issue when only another phase than L1 is provided
1 parent 8f27edb commit 85a8b61

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v0.1.6
4+
* Changed: Allow to populate only L2 and/or L3 even if L1 is missing
5+
36
## v0.1.5
47
* Added: Timeout on driver startup. Prevents problems, if the MQTT broker is not reachable on driver startup
58
* Changed: Fixed status flapping between running and standby

dbus-mqtt-pv/dbus-mqtt-pv.py

+26-25
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def __init__(
222222
self._dbusservice.add_path('/ProductId', 0xFFFF)
223223
self._dbusservice.add_path('/ProductName', productname)
224224
self._dbusservice.add_path('/CustomName', customname)
225-
self._dbusservice.add_path('/FirmwareVersion', '0.1.5 (20231218)')
225+
self._dbusservice.add_path('/FirmwareVersion', '0.1.6 (20240226)')
226226
# self._dbusservice.add_path('/HardwareVersion', '')
227227
self._dbusservice.add_path('/Connected', 1)
228228

@@ -258,7 +258,8 @@ def _update(self):
258258
self._dbusservice['/Ac/L1/Voltage'] = round(pv_L1_voltage, 2) if pv_L1_voltage is not None else None
259259
self._dbusservice['/Ac/L1/Frequency'] = round(pv_L1_frequency, 2) if pv_L1_frequency is not None else None
260260
self._dbusservice['/Ac/L1/Energy/Forward'] = round(pv_L1_forward, 2) if pv_L1_forward is not None else None
261-
else:
261+
# at least one phase is needed to work properly
262+
elif pv_L2_power is None and pv_L3_power is None:
262263
self._dbusservice['/Ac/L1/Power'] = round(pv_power, 2) if pv_power is not None else None
263264
self._dbusservice['/Ac/L1/Current'] = round(pv_current, 2) if pv_current is not None else None
264265
self._dbusservice['/Ac/L1/Voltage'] = round(pv_voltage, 2) if pv_voltage is not None else None
@@ -389,35 +390,35 @@ def _n(p, v): return (str("%i" % v))
389390
'/Ac/Voltage': {'initial': 0, 'textformat': _v},
390391
'/Ac/Energy/Forward': {'initial': None, 'textformat': _kwh},
391392

392-
'/Ac/L1/Power': {'initial': 0, 'textformat': _w},
393-
'/Ac/L1/Current': {'initial': 0, 'textformat': _a},
394-
'/Ac/L1/Voltage': {'initial': 0, 'textformat': _v},
395-
'/Ac/L1/Frequency': {'initial': None, 'textformat': _hz},
396-
'/Ac/L1/Energy/Forward': {'initial': None, 'textformat': _kwh},
397-
398393
'/Ac/MaxPower': {'initial': int(config['PV']['max']), 'textformat': _w},
399394
'/Ac/Position': {'initial': int(config['PV']['position']), 'textformat': _n},
400395
'/Ac/StatusCode': {'initial': 0, 'textformat': _n},
401396
'/UpdateIndex': {'initial': 0, 'textformat': _n},
402397
}
403398

404-
if pv_L2_power is not None:
405-
paths_dbus.update({
406-
'/Ac/L2/Power': {'initial': 0, 'textformat': _w},
407-
'/Ac/L2/Current': {'initial': 0, 'textformat': _a},
408-
'/Ac/L2/Voltage': {'initial': 0, 'textformat': _v},
409-
'/Ac/L2/Frequency': {'initial': None, 'textformat': _hz},
410-
'/Ac/L2/Energy/Forward': {'initial': None, 'textformat': _kwh},
411-
})
412-
413-
if pv_L3_power is not None:
414-
paths_dbus.update({
415-
'/Ac/L3/Power': {'initial': 0, 'textformat': _w},
416-
'/Ac/L3/Current': {'initial': 0, 'textformat': _a},
417-
'/Ac/L3/Voltage': {'initial': 0, 'textformat': _v},
418-
'/Ac/L3/Frequency': {'initial': None, 'textformat': _hz},
419-
'/Ac/L3/Energy/Forward': {'initial': None, 'textformat': _kwh},
420-
})
399+
paths_dbus.update({
400+
'/Ac/L1/Power': {'initial': None, 'textformat': _w},
401+
'/Ac/L1/Current': {'initial': None, 'textformat': _a},
402+
'/Ac/L1/Voltage': {'initial': None, 'textformat': _v},
403+
'/Ac/L1/Frequency': {'initial': None, 'textformat': _hz},
404+
'/Ac/L1/Energy/Forward': {'initial': None, 'textformat': _kwh},
405+
})
406+
407+
paths_dbus.update({
408+
'/Ac/L2/Power': {'initial': None, 'textformat': _w},
409+
'/Ac/L2/Current': {'initial': None, 'textformat': _a},
410+
'/Ac/L2/Voltage': {'initial': None, 'textformat': _v},
411+
'/Ac/L2/Frequency': {'initial': None, 'textformat': _hz},
412+
'/Ac/L2/Energy/Forward': {'initial': None, 'textformat': _kwh},
413+
})
414+
415+
paths_dbus.update({
416+
'/Ac/L3/Power': {'initial': None, 'textformat': _w},
417+
'/Ac/L3/Current': {'initial': None, 'textformat': _a},
418+
'/Ac/L3/Voltage': {'initial': None, 'textformat': _v},
419+
'/Ac/L3/Frequency': {'initial': None, 'textformat': _hz},
420+
'/Ac/L3/Energy/Forward': {'initial': None, 'textformat': _kwh},
421+
})
421422

422423
DbusMqttPvService(
423424
servicename='com.victronenergy.pvinverter.mqtt_pv_' + str(config['MQTT']['device_instance']),

0 commit comments

Comments
 (0)