Skip to content

Commit

Permalink
added status code, fixes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Nov 6, 2023
1 parent 7f6bff1 commit b68a29d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.1.4
* Added: Frequency
* Added: StatusCode: 7 = Running; 8 = Standby

## v0.1.3
* Changed: Fix crash when rounding none value
* Changed: Fixed a typo
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
I wrote this script for myself. I'm not responsible, if you damage something using my script.


### Supporting/Sponsoring this project

You like the project and you want to support me?

[<img src="https://github.md0.eu/uploads/donate-button.svg" height="50">](https://www.paypal.com/donate/?hosted_button_id=3NEVZBDM5KABW)


### Purpose

The script emulates a Photovoltaic AC Inverter in Venus OS. It gets the MQTT data from a subscribed topic and publishes the information on the dbus as the service `com.victronenergy.pvinverter.mqtt_pv` with the VRM instance `51`.
Expand Down Expand Up @@ -197,10 +204,3 @@ It was tested on Venus OS Large `v2.92` on the following devices:
![Pv power L1, L2, L3 - device list - mqtt pv 2](/screenshots/pv_power_L3_L2_L1_device-list_mqtt-pv-2.png)

</details>


## Supporting/Sponsoring this project

You like the project and you want to support me?

[<img src="https://github.md0.eu/uploads/donate-button.svg" height="50">](https://www.paypal.com/donate/?hosted_button_id=3NEVZBDM5KABW)
12 changes: 9 additions & 3 deletions dbus-mqtt-pv/dbus-mqtt-pv.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def __init__(
self._dbusservice.add_path('/ProductId', 0xFFFF)
self._dbusservice.add_path('/ProductName', productname)
self._dbusservice.add_path('/CustomName', customname)
self._dbusservice.add_path('/FirmwareVersion', '0.1.3 (20230522)')
self._dbusservice.add_path('/FirmwareVersion', '0.1.4 (20231106)')
# self._dbusservice.add_path('/HardwareVersion', '')
self._dbusservice.add_path('/Connected', 1)

Expand Down Expand Up @@ -262,8 +262,6 @@ def _update(self):
self._dbusservice['/Ac/L1/Frequency'] = None
self._dbusservice['/Ac/L1/Energy/Forward'] = round(pv_forward, 2) if pv_forward is not None else None

# self._dbusservice['/StatusCode'] = 7

if pv_L2_power is not None:
self._dbusservice['/Ac/L2/Power'] = round(pv_L2_power, 2) if pv_L2_power is not None else None
self._dbusservice['/Ac/L2/Current'] = round(pv_L2_current, 2) if pv_L2_current is not None else None
Expand All @@ -286,6 +284,14 @@ def _update(self):
if pv_L3_power:
logging.debug("|- L3: {:.1f} W - {:.1f} V - {:.1f} A".format(pv_L3_power, pv_L3_voltage, pv_L3_current))

# is only displayed for Fronius inverters (product ID 0xA142)
# if power above 10 W, set status code to 9 (running)
if self._dbusservice['/StatusCode'] != 7 and self._dbusservice['/Ac/Power'] > 10:
self._dbusservice['/StatusCode'] = 7
# else set status code to 8 (standby)
elif self._dbusservice['/StatusCode'] != 8:
self._dbusservice['/StatusCode'] = 8

last_updated = last_changed

# quit driver if timeout is exceeded
Expand Down

0 comments on commit b68a29d

Please sign in to comment.