question

ndesseauve avatar image
ndesseauve asked

Changing smartshunt DC meter type

Hello,

Is there a way to change the "DC meter type" of a SmartShunt set in DC meter mode other than with the bluetooth app ?

I have a SmartShunt used to monitor a charge controller that can be either solar or hydrogenerator. If I change the type in the bluetooth app all works well : solar is added as solar energy and hydro is not.

It's a little cumbersome and I may forget to change when starting the generator, so I'm looking for a way to do it programmatically.

Thanks !

SmartShunt
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
ndesseauve avatar image
ndesseauve answered ·

After some experimentation, it seems I should be able to do it with the VE.Direct HEX protocol or the VregLink Interface (https://github.com/victronenergy/venus/wiki/dbus-api#the-vreglink-interface).

The VregLink interface is promising, I'm able to read the value on the SmartShunt configured as solar charger :

# dbus -y com.victronenergy.solarcharger.ttyS6 /Devices/0/VregLink GetVreg %0xeeb8
error = 0 data = [247, 255]

Which is correct [247, 255] is 0xfff7 or -9 with two's complement.

What I don't understand is how should be set the data in a SetVreg call. I've tried multiple things :

# dbus -y com.victronenergy.solarcharger.ttyS6 /Devices/0/VregLink SetVreg %0xeeb8 [250, 255]
ERROR:dbus.connection:Unable to set arguments (61112, '[250,', '255]') according to signature 'qay': <class 'TypeError'>: an integer is required (got type str) Traceback (most recent call last):   File "/usr/bin/dbus", line 374, in <module>     ret = obj.object.get_dbus_method(method.name, iface.name)(*args)   File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 141, in __call__     return self._connection.call_blocking(self._named_service,   File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 657, in call_blocking     message.append(signature=signature, *args) TypeError: an integer is required (got type str)
# dbus -y com.victronenergy.solarcharger.ttyS6 /Devices/0/VregLink SetVreg %0xeeb8 %250 %255
ERROR:dbus.connection:Unable to set arguments (61112, 250, 255) according to signature 'qay': <class 'TypeError'>: 'int' object is not iterable
Traceback (most recent call last):
  File "/usr/bin/dbus", line 374, in <module>
    ret = obj.object.get_dbus_method(method.name, iface.name)(*args)
  File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 141, in __call__
    return self._connection.call_blocking(self._named_service,
  File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 657, in call_blocking
    message.append(signature=signature, *args)
TypeError: 'int' object is not iterable
# dbus -y com.victronenergy.solarcharger.ttyS6 /Devices/0/VregLink SetVreg %0xeeb8 %0xfffa
ERROR:dbus.connection:Unable to set arguments (61112, 65530) according to signature 'qay': <class 'TypeError'>: 'int' object is not iterable Traceback (most recent call last):   File "/usr/bin/dbus", line 374, in <module>     ret = obj.object.get_dbus_method(method.name, iface.name)(*args)   File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 141, in __call__     return self._connection.call_blocking(self._named_service,   File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 657, in call_blocking     message.append(signature=signature, *args) TypeError: 'int' object is not iterable
# dbus -y com.victronenergy.solarcharger.ttyS6 /Devices/0/VregLink SetVreg %0xeeb8 %0xfaff
ERROR:dbus.connection:Unable to set arguments (61112, 64255) according to signature 'qay': <class 'TypeError'>: 'int' object is not iterable
Traceback (most recent call last):
  File "/usr/bin/dbus", line 374, in <module>
    ret = obj.object.get_dbus_method(method.name, iface.name)(*args)
  File "/usr/lib/python3.8/site-packages/dbus/proxies.py", line 141, in __call__
    return self._connection.call_blocking(self._named_service,
  File "/usr/lib/python3.8/site-packages/dbus/connection.py", line 657, in call_blocking
    message.append(signature=signature, *args)
TypeError: 'int' object is not iterable

How does this work ?

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

ndesseauve avatar image ndesseauve commented ·

The solution was simple, I hadn't tried everything :

# dbus -y com.victronenergy.solarcharger.ttyS6 /Devices/0/VregLink SetVreg %0xeeb8 %250,255
error = 0
retval = [250, 255]
0 Likes 0 ·