Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Jan 2, 2023
1 parent 7fb0ed8 commit 63d37e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ I wrote this script for myself. I'm not responsible, if you damage something usi

### Purpose

The script emulates a physical Grid Meter in Venus OS. It gets the MQTT data from a subscribed topic and publishes the information on the dbus as the service `com.victronenergy.grid.mqtt_grid` with the VRM instance `30`.
The script emulates a physical Grid Meter in Venus OS. It gets the MQTT data from a subscribed topic and publishes the information on the dbus as the service `com.victronenergy.grid.mqtt_grid` with the VRM instance `31`.


### Config
Expand Down Expand Up @@ -144,7 +144,7 @@ This will output somethink like `/service/dbus-mqtt-grid: up (pid 5845) 185 seco

If the seconds are under 5 then the service crashes and gets restarted all the time. If you do not see anything in the logs you can increase the log level in `/data/etc/dbus-mqtt-grid/dbus-mqtt-grid.py` by changing `level=logging.WARNING` to `level=logging.INFO` or `level=logging.DEBUG`

If the script stops with the message `dbus.exceptions.NameExistsException: Bus name already exists: com.victronenergy.pvinverter.enphase_envoy"` it means that the service is still running or another service is using that bus name.
If the script stops with the message `dbus.exceptions.NameExistsException: Bus name already exists: com.victronenergy.grid.mqtt_grid"` it means that the service is still running or another service is using that bus name.

### Compatibility

Expand Down
1 change: 1 addition & 0 deletions dbus-mqtt-grid/config.sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
; used when no voltage is received
voltage = 230


[MQTT]
; IP addess or FQDN from MQTT server
broker_address = IP_ADDR_OR_FQDN
Expand Down
11 changes: 6 additions & 5 deletions dbus-mqtt-grid/dbus-mqtt-grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,11 @@ def __init__(

# Create the mandatory objects
self._dbusservice.add_path('/DeviceInstance', deviceinstance)
self._dbusservice.add_path('/ProductId', 0xFFFF) # value used in ac_sensor_bridge.cpp of dbus-cgwacs
self._dbusservice.add_path('/Serial', 30000) # value used in ac_sensor_bridge.cpp of dbus-cgwacs
self._dbusservice.add_path('/ProductId', 0xFFFF)
self._dbusservice.add_path('/ProductName', productname)
self._dbusservice.add_path('/CustomName', productname)
self._dbusservice.add_path('/FirmwareVersion', 0.1)
self._dbusservice.add_path('/HardwareVersion', 0.1)
self._dbusservice.add_path('/FirmwareVersion', '0.0.1')
self._dbusservice.add_path('/HardwareVersion', '0.0.1')
self._dbusservice.add_path('/Connected', 1)

self._dbusservice.add_path('/Latency', None)
Expand Down Expand Up @@ -234,6 +233,7 @@ def main():
# Have a mainloop, so we can send/receive asynchronous calls to and from dbus
DBusGMainLoop(set_as_default=True)


# MQTT setup
client = mqtt.Client("MqttGrid")
client.on_disconnect = on_disconnect
Expand Down Expand Up @@ -271,6 +271,7 @@ def main():
logging.info("Waiting 5 seconds for receiving first data...")
time.sleep(5)


#formatting
_kwh = lambda p, v: (str(round(v, 2)) + 'kWh')
_a = lambda p, v: (str(round(v, 2)) + 'A')
Expand Down Expand Up @@ -315,7 +316,7 @@ def main():

pvac_output = DbusMqttGridService(
servicename='com.victronenergy.grid.mqtt_grid',
deviceinstance=30,
deviceinstance=31,
paths=paths_dbus
)

Expand Down

0 comments on commit 63d37e6

Please sign in to comment.