What's new
Carbonite

South Africa's Top Online Tech Classifieds!
Register a free account today to become a member! (No Under 18's)
Home of C.U.D.

Victron & Home Assistant

J37

VIP
VIP Supporter
Rating - 100%
117   0   0
Joined
Dec 16, 2012
Messages
2,596
Reaction score
1,004
Points
7,335
Location
Northriding
Recently got an inverter installed, specifically the Victron MultiPlus II and the Victron Cerbo GX. Everything in the house runs through the inverter, I wanted to integrate my Victron into Home Assistant to create some automation. To power and not power certain things around the house depending on whether I'm running off battery or not. I've created a guide below on how to pair the Victron inverter with Home Assistant as well as a basic automation to start off. I'm new to Home Assistant... I'll get more creative with this as time goes on. If anyone has input on what I should/could change, please let me know. Most of my guide is a combination of various guides I followed and assumes you know nothing, which is the boat I was in. I typed the below out after doing all of it, hopefully I haven't made any errors, if something is different on your side or confusing let me know.

First, you'll need something to run Home Assistant, I have an ancient Dell Optiplex (running Windows 10 Pro) that currently runs PiHole (another great app worth looking into). This is what I ended up using for Virtualbox/Home Assistant. So far, I've noticed that 8GB of RAM didn't cut it (well just barely), was hovering around 7GB usage with Virtualbox/Home Assistant VM and Docker/PiHole running. Added more RAM, ended up with 12GB in total which gives me more headroom, this shouldn't really affect anything but worth noting.

Setting up your Victron system:
Your Victron system must be connected to the same network/WiFi that your Home Assistant server is on. If they're not on the same network, you won't be able to pull the data across (or at least how I understand it). You'd change the WiFi connection settings in your VRM Remote Console (on the Victron system).
1. Log into your VRM Portal account, this should already be available to you from your installer - VRM Portal - Victron Energy
2. You will need full control over the account and not monitoring rights.
3. Remote Console (on the left side bar).
4. Settings > Services > Modbus TCP > Enable Modbus/TCP. I mention later that if you have a different inverter model / Cerbo, your unit ID's will be different. You'd get these unit ID's within this settings menu.

Setting up Virtualbox & Home Assistant:
1. Download Virtualbox (VirtualBox x.x.xx platform packages > Windows hosts) - Downloads – Oracle VM VirtualBox
2. Download Home Assistant (VirtualBox (.vdi)) - Windows
3. Install Virtualbox.
4. Create a folder on your desktop and extract the Virtualbox .vdi file into it (you'll end up keeping this folder - don't delete it).
5. Open up Virtualbox and click New.
6. Name: homeassistant (must be one word) / Machine Folder: this will be the folder you extracted the .vdi file to / Type: Linux / Version: Other Linux (64-bit) / Memory size: 2048 MB / Select "Use an existing virtual hard disk file" - this will be the folder you extracted the .vdi file to.
7. Create.
8. Open the settings for the homeassistant VM you just created.
9. System tab - Motherboard: make sure you have 2GB / 2048MB of Base Memory and check Enable EFI (special OSes only). Processor: set Processor(s): to 2.
10. Audio tab - Audio Controller: Intel HD Audio.
11. Network tab - Adapter 1: Attached to: Bridged Adapter. Make sure the Name is the NIC on your machine.
12. Highlight the homeassistant VM and click Start.
13. Let it finish setting up and booting. Eventually it'll show a page with Home Assistant typed out by weird characters. You'll see below the Home Assistant text "IPv4 address for enp0s3: <ip address here>".
14. Copy that IP and put :8123 at the end (something like 0.0.0.0:8123) and enter it into your browser.
15. Setup your Home Assistant profile.
16. You'll need to create a batch file to run your Virtualbox (and homeassistant VM) when Windows boots. My Dell is headless, so I don't want to remote in every time to start up the VM.
17. Open notepad and paste the below.
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm homeassistant --type headless
18. Save the file as homeassistant.bat in your start up folder (Start > Run > shell:startup). Shutdown the homeassistant VM and Virtualbox and run the batch file to confirm it works... or just restart your machine.
Source: LINK

Setting up Home Assistant:
1. Settings.
2. Add-ons.
3. Add-on store.
4. Search for "File editor".
5. Install it and check "Show in sidebar".
6. File editor should now be on the left side bar. Open it.
7. On the blue bar at the top-left, click the folder icon and search for configuration.yaml and open it.
8. Below the text that's already there, paste the below (see LINK). - If you want to pull more data have a look at: LINK. Also, worth noting that if you have a different model inverter or Cerbo, your unit ID's will be different. You'll need to change your IP (host - below) to the IP of your cerbo (I got mine from my routers client list).
LINK
9. Developer Tools (on the left side bar) on the YAML tab click Check Configuration, assuming its valid click Restart.
10. Once restarted. Click on Developer Tools (on the left side bar) click on States, scroll until you find your Victron data. Check to see if the state values are changing to confirm data is being brought across.
11. The above data should also be viewable on your Home Assistant dashboard, mine added itself automatically.
12. If "Victron AC Power" = 1 (you don't have loadshedding). 240 = you've got loadshedding and running off battery power.
13. In my case I've got a few Bneta smart plugs (which work with my Smart Life phone app), most of the information that follows will apply to setting them up, I'm not sure what other devices will work here.
14. Settings (on the left side bar) and click Devices & Services.
15. Click + Add Integration.
16. Search for Tuya.
17. Before entering in any information for the above you'll need to setup Tuya and link it to your Smart Life app account. Create a Tuya account here: https://auth.tuya.com/. Follow this guide to link your Tuya account to your Smart Life account: Tuya
18. Once Tuya is setup, you'll be able to view your devices under Settings > Devices & Services.
19. Settings > Automations & Scenes > Create Automation. To indicate when loadshedding has started I setup a RED LED strip in my kitchen to turn on (and turn off when there's no loadshedding).
Automation 1
Loadshedding - Start
*Trigger:
Numerical state
Entity: Victron AC Power
Attribute: <blank>
Above: 120
Below: <blank>
Value template (optional): <blank>
For (optional): <blank>
*Action:
Device
Device: Smart Plug
Action: Turn on Smart Plug
//
Automation 2
Loadshedding - End
*Trigger:
Numerical state
Entity: Victron AC Power
Attribute: <blank>
Above: <blank>
Below: 120
Value template (optional): <blank>
For (optional): <blank>
*Action:
Device
Device: Smart Plug
Action: Turn off Smart Plug

Hopefully this helps any other Victron owners and gives you a good start to doing more automations.
 
Last edited:
Interesting read.
I'm looking at doing something similar with a Sunsynk inverter.
I'm currently considering this: Sonoff Smart LoadSedder | Sonoff Africa
I found very little info for my Victron inverter, any info that did exist was quite dated, or didn't exist at all.

In the long run, I will add in Sonof smart switches (like your link) which will automatically turn off things when there's loadshedding, like the aircons/microwave/kettle/washing machines etc. But for now, at least some indication of when I'm running off battery power will suffice. You really get used to having power all the time you forget to look when you're actually being shedded. :LOL:
 
Interesting guide, thanks for sharing!

Lots of cool stuff to be done with Modbus on these inverters.
I have some basic on/off commands that controls the inverter to be ready for loadshedding (which sets the SoC) and whether I should recharge the batteries with the grid or not. Here's my YAML:
[CODE lang="yaml" title="victron.yaml"]modbus:
- name: victron
type: tcp
host: 192.168.1.243
port: 502
sensors:
- name: Eskom power
unit_of_measurement: "W"
slave: 100
address: 820
- name: Victron Solar power
unit_of_measurement: "W"
slave: 245
address: 789
scale: 0.1
- name: Victron AC Consumption
unit_of_measurement: "W"
slave: 100
address: 817
- name: Pylontech Battery SOC
unit_of_measurement: "%"
slave: 100
address: 843
- name: Pylontech Battery temperature
unit_of_measurement: "°C"
slave: 225
address: 262
scale: 0.1
- name: Eskom input voltage
unit_of_measurement: "V"
slave: 242
address: 3
scale: 0.1
- name: Eskom input frequency
unit_of_measurement: "Hz"
slave: 242
address: 9
scale: 0.01
- name: Solar kWh total
unit_of_measurement: "kWh"
slave: 245
address: 790
scale: 0.1
precision: 2
- name: Grid total kWh
unit_of_measurement: "kWh"
slave: 30
address: 2603
scale: 0.01
switches:
- name: Victron grid override
slave: 100
address: 2700
command_on: 1500
command_off: 20
- name: Loadshedding ready
slave: 100
address: 2901
command_on: 700
command_off: 200
- name: Keep batteries charged
slave: 100
address: 2900
command_on: 9
command_off: 11
- name: Prioritise battery charging
slave: 100
address: 2704
command_on: 30
command_off: 150[/CODE]

Another option for less overhead is to run Home Assistant in Docker, means you don't need an OS within an OS.

There's more detailed documentation on Modbus and how VIctron implement on their site GX Modbus-TCP Manual [Victron Energy] as well as a full register list dbus_modbustcp/CCGX-Modbus-TCP-register-list.xlsx at master · victronenergy/dbus_modbustcp
 
  • Like
Reactions: J37
Interesting guide, thanks for sharing!

Lots of cool stuff to be done with Modbus on these inverters.
I have some basic on/off commands that controls the inverter to be ready for loadshedding (which sets the SoC) and whether I should recharge the batteries with the grid or not. Here's my YAML:
snip*

Another option for less overhead is to run Home Assistant in Docker, means you don't need an OS within an OS.

There's more detailed documentation on Modbus and how VIctron implement on their site GX Modbus-TCP Manual [Victron Energy] as well as a full register list dbus_modbustcp/CCGX-Modbus-TCP-register-list.xlsx at master · victronenergy/dbus_modbustcp
Awesome, thank you.

I did get baited by that video, installing Virtualbox and HA in 3 minutes. Since I run PiHole in a Docker, might as well migrate HA to there as well.

Could you explain your "get the inverter ready for loadshedding" a little further? As in what actually happens when this kicks in (is it manual or automatic)? I'm at a bit of a crossroads at the moment, if my washing machines are running pulling a lot of power, loadshedding starts, I'd assume they'd overload the inverter and trip it. So I thought of running the washing machines off a smart plug, but the smart plug takes 2-3 seconds to update once the power has switched over, increasing the chances of overloading the inverter and tripping it?
 
ould you explain your "get the inverter ready for loadshedding" a little further? As in what actually happens when this kicks in (is it manual or automatic)? I'm at a bit of a crossroads at the moment, if my washing machines are running pulling a lot of power, loadshedding starts, I'd assume they'd overload the inverter and trip it. So I thought of running the washing machines off a smart plug, but the smart plug takes 2-3 seconds to update once the power has switched over, increasing the chances of overloading the inverter and tripping it?
Sure thing! I probably made it sound a lot more exciting than it is. All it does is change the minimum SOC. When the switch is off my SOC is 20%, when it's on and ready for loadshedding it sets it to 70%. That way I'm covered for loadshedding when the sun isn't out. I have a few of these on/off buttons in HA that are mapped to Modbus commands.

I do the same to prioritise battery charging when the forecasted hours of sun on that day is less than 8 hours, I limit the inverter output (when the grid is available) to 300W so any excess PV generation outside of that feeds the battery first. Once the battery gets to 100% it increases the inverter power output.

No idea if things would trip for you, what VIctron inverter, MPPT and battery setup do you have? I only have a 3kVa feeding the house so run critical loads off it, non-critical stuff goes down when the grid does. For me that's my geyser, oven, AC's, dishwasher and washing machine.
 
Sure thing! I probably made it sound a lot more exciting than it is. All it does is change the minimum SOC. When the switch is off my SOC is 20%, when it's on and ready for loadshedding it sets it to 70%. That way I'm covered for loadshedding when the sun isn't out. I have a few of these on/off buttons in HA that are mapped to Modbus commands.

I do the same to prioritise battery charging when the forecasted hours of sun on that day is less than 8 hours, I limit the inverter output (when the grid is available) to 300W so any excess PV generation outside of that feeds the battery first. Once the battery gets to 100% it increases the inverter power output.

No idea if things would trip for you, what VIctron inverter, MPPT and battery setup do you have? I only have a 3kVa feeding the house so run critical loads off it, non-critical stuff goes down when the grid does. For me that's my geyser, oven, AC's, dishwasher and washing machine.
I've got a 5kva inverter with everything in the house going through it, looking at my usage I should be fine, but it would be cool to build Eskom stages/schedules into HA and turn off stuff before loadshedding actually hits.
 
I've got a 5kva inverter with everything in the house going through it, looking at my usage I should be fine, but it would be cool to build Eskom stages/schedules into HA and turn off stuff before loadshedding actually hits.
Why/what do you want to switch off before loadshedding?

My non-critical loads that are on smart plugs switch off when loadshedding starts, and turn on depending on certain criteria. Maybe some ideas to automate switching things off before loadshedding would be to interface with the Eskom Se Push API or manually add calendar entries. This is what I currently do since I have a bunch of calendar automations already.
 
Interesting read.
I'm looking at doing something similar with a Sunsynk inverter.
I'm currently considering this: Sonoff Smart LoadSedder | Sonoff Africa
Bit of a thread resurrection.
I've recently installed this Smart Loadshedding Notification Switch
It works the same as the official Sonoff Loadshedder, but isn't installed in the DB and is therefore a DIY solution for the average person.
You do have to fit a plug to it though and the 5V USB adapter isn't supplied.
 
  • Like
Reactions: J37
Added Discord integration to HA today ... and made a guide. I'm always on Discord, whether I'm at work or at home so a notification to let me know when I am (or not) being loadshedded. I'm sure one could get more creative with webhooks and/or better ways to be notified, but for now this will work great for me.

This was a culmination of various sites with new/outdated information, consolidated into something easier to follow.

Creating a Discord bot:

1. Login to your Discord account via your browser.
2. Go to this page - Discord Developer Portal — API Docs for Bots and Developers
3. New Application.
4. Name + Accept T’s/C’s.
Note: The name you give your application on the Discord My Apps page will determine the name of the notify service. For example: if you enter “Discord Chat”, the service will be named notify.discord_chat.
5. Create.
6. Add APP icon.
7. Bot tab – Deselect Public Bot.
8. OAuth2
> URL Generator
Scopes: bot
Bot Permissions: Send Messages
9. Copy the generated URL at the bottom and paste this in your browser.
10. Select your Discord server (you’ll need full administrator privileges).
11. Continue.
12. Authorize.
13. Confirm that the bot has joined your server.

Discord integration & setup on Home Assistant:

1. Add the Discord integration to Home Assistant with the below URL.
Link to Integrations: Add integration – My Home Assistant
2. OPEN LINK.
3. Do you want to set up Discord? Ok.
4. API Token: Found on your Discord APP/bot creation page.
Bot tab > Reset Token > Yes, do it! > Copy.
5. Submit.
6. Finish.
7. Click the File editor (download this add-on if you don't already have it in Home Assistant) tab in Home Assistant.
8. Ensure /config/configuration.yaml is the selected document.
9. Paste source_1 (seen at the end of this guide) into the text box.
Note: You’ll need to change the bot token under notify.
*remove the < > symbols from the <YOUR BOT TOKEN>
10. Save.
11. Developer Tools tab.
12. Check configuration.
13. If the configuration is approved. Restart Home Assistant.

Discord webhook test via Home Assistant:

1. Developer tools tab.
2. Select the Services tab at the top.
3. Service: Will be the name of your Discord bot.
Eg. Discord bot name: Home Assistant / Service name: notify.home_assistant
4. Fill Example Data (at the bottom).
5. target: [“DISCORD CHANNEL ID”]
delete the “data: platform specific” line.
6. Call Service.
7. Check the relevant Discord channel to ensure it works/sends a message.

Note: If you're having issues using the call service function. View the below URL.

Adding the webhook notification to an automation on Home Assistant:

1. + Add Action.
2. Call Service.
3. Service: Will be the name of your Discord bot.
Eg. Discord bot name: Home Assistant / Service name: notify.home_assistant
4. In your automation's as a trigger.
Message: Loadshedding has **STARTED/ENDED** - <@YOUR DISCORD USER ID>
Select Target and add the following: ["DISCORD CHANNEL ID"]
5. Save.
6. Top right 3 dots, Run.
7. Confirm the message was sent to the relevant Discord channel.

_

source_1
 
Last edited:
Another day another addition/guide.

I've noticed, most of the time if you want to integrate anything with Home Assistant, the guides assume you already have certain things installed or assume you know how to do a certain step which they briefly brush over. Below is how to add (from start to finish) your loadshedding schedule to Home Assistant.

Adding HACS to Home Assistant:


1. In Home Assistant click your profile at the bottom left.
2. Enable Advanced Mode.
3. Go to Settings (in HA).
4. Add-ons.
5. Add-on Store.
6. Install Terminal & SSH.
7. Start Terminal & SSH.
8. Run the below command in the SSH terminal.
wget -O - https://get.hacs.xyz | bash -
Note: CTRL+V not working for you?
Try CTRL+SHIFT+V instead.
Try SHIFT+INS(insert) instead.
Try Right-click instead.
9. Developer Tools.
10. Check configuration.
11. Restart.
12. Settings.
13. Devices & Services.
14. + Add Integration.
15. Search for “HACS”.
16. Accept all and accept.
17. Open the link and log into your Github account.
18. Copy the code in HA and paste on the activation page on Github.
19. Authorize HACS.
20. Select the appropriate room and accept.
21. Go to HACS on your Devices & Services page.
22. Click configure.
23. In HA, click on the HACS tab on the left.
24. Integrations.
25. + Explore & download repositories.
26. Search for “Load Shedding” and download it.
27. Once downloaded click the below link to configure the integration.
28. Get your Eskom Se Push API key.
EskomSePush API Subscription
29. Click subscribe on the right-hand side of the page.
30. Once subscribed – copy your license key at the bottom of the page.
31. Paste your license key into the HA API/Token box.
32. Search for your suburb.
33. Select the correct extension/area of your suburb.
34. Select the area: Home.
35. Restart HA.

Adding Mushroom to Home Assistant:


1. Click the HACS tab on the left.
2. Front-end.
3. + Explore & download repositories.
4. Search for “Mushroom”.
5. Download.
6. Reload your browser.
7. Restart HA.

Setting up your loadshedding card on your overview tab:

1. Developer Tools.
2. States tab at the top.
3. Ctrl + F.
4. Search for ‘area’.
5. Look for a sensor with the following name.
sensor.load_shedding_area_XXXXX_X_XXXXX
6. Copy this and save it in a notepad document.
7. Open the below URL (more cards in the second link).
ha.integration.load_shedding/examples/card3.yaml at master · wernerhp/ha.integration.load_shedding
8. Copy the code from the first link in step 7 and paste this in a new notepad document.
9. Replace “sensor.load_shedding_area_eskde_14_milnertoncityofcapetownwesterncape” with the sensor you saved in step 5/6.
10. Go to your overview tab in HA.
11. Edit dashboard.
12. + Add card.
13. Scroll all the way to the bottom and select Manual.
14. Paste the code from step 9 here.
15. Done.
 
What you'll end up with...

Quota is the amount of times you've pulled the API per day, with 50 being the max.

BVPEK1P.png
 

Users who are viewing this thread

Latest posts

Back
Top Bottom