question

subby28 avatar image
subby28 asked

Home Assistant control of Relay 2

Hi,

I currently have the Victron integration working perfectly in Home Assistant.

However i don't seem to have a control to toggle the Cerbo Relay 2 on and off to allow me to use in automations.

I found the following on another post, but i have no idea where to input this data into Home Assistant. Please forgive my ignorance, i've only really dabbled with the UI based parts of HA and not text based etc. Any advice for a novice would be much appreciated. Thanks.

1680037748051.png

Multiplus-IIcerbo gxRelayhome assistant
1680037798275.png (43.6 KiB)
2 |3000

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

5 Answers
matt1309 avatar image
matt1309 answered ·

Hi @Subby28,


I'm not familiar with home assistant (only openhab) but i can explain what the information above is trying to show you if that's helpful.

The integration above appears to be using Modbus TCP to connect to Victron system and is sending a 1 or 0 to the cerbo relay Modbus address to turn relay on/off.

It may be worth checking what your other Victron integrations are using ModbusTCP or MQTT as I think both will work and you may want to use all the same to be consistent within home assistant.


The Modbus information above is saying homeassistant is going to send a 1 or a 0 (on or off) message via ModbusTCP to address 807 on slave 100. You'll need to check the modbusTCP address is correct for what you want to control: (you want Modbus TCP registers)

Technical information - Victron Energy

I've had a quick look and it seems to be correct in the excel, you just need to make sure the UnitID is correct in VRM devices. I think that's what slave 100 is in the above example you've provided. The unique ID I'm unfamiliar with potentially arbitrary, I also cant see an IP address/Port input in the above snip you've provided.


A far more detailed explanation of Modbus can be found here: GX Modbus-TCP Manual [Victron Energy]

The above snip will make far more sense once you've read that.


If however you go the MQTT route, you'll need to send a 0 or 1 to the cerbo relay topic within the victron MQTT server. The MQTT topics are explained here:

GitHub - victronenergy/dbus-mqtt: Venus OS service mapping the D-Bus on Venus OS to MQTT


but essentially it's the same as DBUS path with a bit added at the front:

You can find DBUS paths here: dbus · victronenergy/venus Wiki · GitHub


MQTT Topic are in the form:

N/{ VRM ID}/{ dbus path} Use this topic for reading

W/{ VRM ID}/{ dbus path} Use this topic for writing

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.

subby28 avatar image subby28 commented ·
Thankyou for taking the time to reply. I had just about got my head around the Modbus side of things and made a modbus.yaml file with the switch i wanted in it, but it was just what i did next to use the switch in HA. i was just being stupid in the end, and it was in plain sight. I now have use of Relay 2 in HA to disable AC IN. I have an automation that disables AC IN during daytime hours when there is low solar, so if i charge EV, it doesnt drain battery.
1 Like 1 ·
Alan avatar image
Alan answered ·

sounds like what i need too

2 |3000

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

iain2252 avatar image
iain2252 answered ·

@Subby28 I know this is over a year old but I am trying to do the same thing and failing. Similar to you I have limited HA experience, I’ve got all the data via modbus but can’t work out how to switch the relay. I’ve tried the above code in the configuration yaml but not understanding what else I need to do. Can you give me any pointers? Thanks

2 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.

subby28 avatar image subby28 commented ·

I can't for the life of me remember what it was I couldn't do. As it's all very basic. Using the Victron integration, the control for relays is under the settings device, and relay 2 is actually called relay 1, and relay 1 is relay 0.

Also what behaviour are you trying to achieve ? I found it was actually better to change the inverters mode to charger only when EV charging rather than disabled AC IN. I don't use this relay or disable AC IN anymore.

0 Likes 0 ·
iain2252 avatar image iain2252 subby28 commented ·
Thanks @Subby28 for the response. Still not figured out how to do it because my understanding is not good enough. I can see the relays but can’t control them.

I just need the relay to turn on once a dc temp of another temperature is hit. The relay then turns on a fan. Think I need to go back to basics to understand how to write a switch and the code behind it. Thanks

0 Likes 0 ·
subby28 avatar image
subby28 answered ·

I assume you've unchecked the read only box in the Victron configuration? I've just double checked and when creating an automation, it's just under the settings, and then you can turn the relays off and on there. 1000030888.png


1000030888.png (211.5 KiB)
2 |3000

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

iain2252 avatar image
iain2252 answered ·

@Subby28 thank you. I missed the write box. All makes sense now. Should have realised!!! Cheers again for answering

2 |3000

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