question

stefann avatar image
stefann asked

Venus GX command relay

Hi,

Running the latest version OS.

Closing the relays works OK, but opening them not working. Result in terminal shows 0 after all commands.


dbus -y com.victronenergy.system /Relay/0/State SetValue 1

dbus -y com.victronenergy.system /Relay/1/State SetValue 1

The above works ok.


dbus -y com.victronenergy.system /Relay/0/State SetValue 0

dbus -y com.victronenergy.system /Relay/1/State SetValue 0

Does NOT work.


Please advise!

Thx,

S.

Venus OSRelay
2 |3000

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

7 Answers
splash avatar image
splash answered ·

Hi Stefann,


I had the same issue, After some digging around my solution was to use dbus-send.


ON

dbus-send --system --print-reply --dest=com.victronenergy.system /Relay/0/State com.victronenergy.BusItem.SetValue variant:int32:1

OFF

dbus-send --system --print-reply --dest=com.victronenergy.system /Relay/0/State com.victronenergy.BusItem.SetValue variant:int32:0

GetValue

dbus-send --system --print-reply --dest=com.victronenergy.system /Relay/0/State com.victronenergy.BusItem.GetValue

Returns:

method return time=1577563971.665778 sender=:1.33 -> destination=:1.912 serial=19248 reply_serial=2

variant int32 1


If you want the command to only return the value of the switch use:

dbus-send --system --print-reply --dest=com.victronenergy.system /Relay/0/State com.victronenergy.BusItem.GetValue | awk -F'int32 ' '{printf "%s",$2}END{print '\n'}'

Returns:

1


dbus-send is far faster for issuing commands and returning values.


Kind Regards


Paul

2 |3000

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

Ingo avatar image
Ingo answered ·

@mvader (Victron Energy Staff) suggested using %0 and %1 to force the values written to be INT. It seems to work perfectly on both VenusGX and RaspberryPi.

dbus -y com.victronenergy.system /Relay/0/State SetValue %0

dbus -y com.victronenergy.system /Relay/0/State SetValue %1

*Hopefully it's the right mvader from the Venus DEV list... :-)

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.

Ingo avatar image Ingo commented ·

Ok, so I fixed the relaystate.py file by removing the BOOL conversion. I don't know if it broke anything else but both VenusGX and RaspberyPi works now as it should. Maybe someone from Victron can just doublecheck it and work it into their next fixes.

def _on_relay_state_changed(self, dbus_path, value):
		try:
			state = int(bool(value)) <- This one here!!!
		except ValueError:
			traceback.print_exc()
			return False
		try:
			return self.__on_relay_state_changed(dbus_path, state)
		finally:
			# Remember the state to restore after a restart
			self._settings[dbus_path] = state
0 Likes 0 ·
rainerb avatar image
rainerb answered ·

Hello Stefann,

I hope I understand your issure right, but the result "0" in the terminal only indicates a successful dbus command. Did you check the relay switching with a measuring device?

If you want to read out the state of the relay, you may use the ".../State GetValue" command.


Regards

Rainer


2 |3000

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

stefann avatar image
stefann answered ·

Hi Reiner, Happy Holidays


Thx for the reply.

Never placed a MultiMeter on the physical relays. I can energize / de-energize the relays ok from Rem Console.


Maybe other suggestion would help me.

Do you know where the script is for Rem Console - relay trigger page? I want to see how is done from the html page. Maybe name of the qml file.


Want to control the 2 relays from a bash + cron: 1st to ON/OFF a Fan evac; 2nd to ON/OFF an ATS.


I am placing a copy of the terminal bellow - exec and response sequence.

root@Venus:~# dbus -y com.victronenergy.system /Relay/1/State GetValue
0
root@Venus:~# dbus -y com.victronenergy.system /Relay/1/State SetValue 1
0
root@Venus:~# dbus -y com.victronenergy.system /Relay/1/State GetValue
1
root@Venus:~# dbus -y com.victronenergy.system /Relay/1/State SetValue 0
0
root@Venus:~# dbus -y com.victronenergy.system /Relay/1/State GetValue
1


Thx,

S.

4 comments
2 |3000

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

Ingo avatar image Ingo commented ·

I can confirm your results. Relay 2 can be Switched On but never Off via the command-line. From the GUI it works perfectly, even the State updates correctly on the Remote Console. Using Modbus it also works for both On and Off states.

It has to be a bug, I suspect the code was introduced to enable Relay 2 but the commandline utility might not have been finished - or I could be totally wrong :-)

Edit: Running 2.42

0 Likes 0 ·
rainerb avatar image rainerb Ingo commented ·

Hi,

could anyone of the Victron Energy Staff perform a short test (and eventually confirm) that there could be a bug in newer GX versions regarding switching off the relays via dbus commands - maybe Daniël Boekel (Victron Energy Staff) ?

With my v2.31 it works, according others, in v2.42 it does not work anymore.


Thanks.

Rainer

0 Likes 0 ·
Show more comments
rainerb avatar image rainerb commented ·

Hi,

I am using Relay 2 in my bash script to switch my Fronius inverter to standby and it works.

I am running Venus version v2.31 - maybe they implemented a bug in newer versions.

I testet it and I can switch the relay On AND OFF via dbus commands.

regards

Rainer

0 Likes 0 ·
1577347324254.png (27.2 KiB)
stefann avatar image
stefann answered ·

Hey guys,


Both relays have the same error from terminal/dbus.

I am running latest version - 2.42


Anyone knows the location of th qlm file for the relays.


S.

2 |3000

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

stefann avatar image
stefann answered ·

Nicy nice!

It works with percent in front. I just tested it on both relays - latest version 242

However dbus-send seams a bit faster - suggested by Splash


Thx,

S.

2 |3000

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

stefann avatar image
stefann answered ·

I will test this myself

Thx,

S.

2 |3000

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

Related Resources

Victron Venus OS Open Source intro page

Venus OS GitHub (please do not post to this)

Additional resources still need to be added for this topic