diy solar

diy solar

Victron SmartShunt / Home Assistant integration

Like I said I have no experience with SolarAssistant so I could not tell you if it will work together or not. All I can say is what I have done on my own setup to get the data into HA.

There is indeed a big learning curve to master Home Assistant...I have had it running for about 5 years now but only did really basic stuff until a few months ago when I started with Zigbee smart lights....but that's another story. In short I would say that the learning curve is worth it! But try to find the simplest solution for your problem. If there is a plugin already for something...use that instead for example. But for Victron solar equipment there is nothing (yet) so we kind of have to right now.

I am assuming by "slim client" you are actually talking about "Thin Clients" right? That could be a better alternative to a raspberry Pi...but the biggest issue from what I have heard is cheap SD cards. And I would recommend NOT running Home Assistant on a Rpi on an SD card! It need to write A LOT to it's internal event database and that would wear out the SD card. That's why the cheap cards get corrupted easily and the system crashes. There are options to connect SSD's over USB and boot from it. I am running home assistant in docker on a basic intel NUC with a SSD. It's not super powerful but better than a raspberry pi with SD card

I was actually worried about the SD card corrupting on VenusOS too as that IS running on a raspberry pi. But the biggest reason for crashing Rpi's is corrupted SD cards from too many writes...which is what HA is doing. For VenusOS as I understood it's not writing anything to the local SD card unless there is no internet available. Normally it will upload all statistics to VRM and not keep a local copy but when the internet connection is lost you can configure it to keep the records locally on the SD card. When the connection is restored it will upload to VRM and your statistics keep their timestamps.

There are victron devices that run VenusOS but they only make sense if you got the money or need to connect a lot of devices. Once you factor in the cost of 5 VE.direct cables (30 euro x 5) and a VE.BUS MK3-USB (80 euro) then a Cerbo GX that costs about 300 euro is going to be a cheaper option. Plus the Cerbo has more features that might be useful...but I don't have one and run it on a Raspberry Pi 3.

While VenusOS is just a custom Linux image there is no official support from Victron on running it on anything else than a Cerbo GX (or other victron device). The Raspberry Pi image is provided by Victron but they do not support it directly. The idea is to ask support on their forums.

I have no idea if it will run on something else. I am assuming most thin clients would be based on an intel compatible CPU and both the Cerbo and Rpi are ARM CPU's....so that would not work. I do know a lot of the victron services that are run on VenusOS are using python so it's not really depending on the architecture of the CPU...I think.

Hope that helps.
Can you shed any step by step or tips to get the VenusOS loaded on the pi? Merry Christmas!!!
 
Can you shed any step by step or tips to get the VenusOS loaded on the pi? Merry Christmas!!!
sure, it works just like nearly every other rpi image that you download and flash to an SD card. ;)
https://www.victronenergy.com/blog/2017/09/06/raspberry-pi-running-victrons-venus-firmware/
https://github.com/victronenergy/venus/wiki/raspberrypi-install-venus-image

That should point you in the right direction of the instructions. Then it depends on if you have a rpi2,rpi3 or rpi4 which image you need to download. There is a version called venusos-large that includes node-red but I am not sure how well that runs. My install is from before this was available so I don't have that on my venusos rpi. Node-red runs on the same NUC as HA does.
Well thanks for all the advice. I have an Orange Pi that was a Christmas gift and I also have a thin client. Interesting you have your running on a NUC. I have access to those from a local hospital that is replacing theirs. I may grab one or two for future use.
no problem. The NUC is just a really small PC not much bigger than a Victron MPPT in my case. Just remember that Home assistant runs on a system with SSD storage and has enough RAM. That might be a challenge with some thin-clients depending on how old they are.

Merry Christmas!!!
Merry Christmas :)
 
I am using an old Dell desktop for HA, not the best power consumption but it was just hanging around waiting to be used. Bonus is loads of USB ports.
 
sure, it works just like nearly every other rpi image that you download and flash to an SD card. ;)
https://www.victronenergy.com/blog/2017/09/06/raspberry-pi-running-victrons-venus-firmware/
https://github.com/victronenergy/venus/wiki/raspberrypi-install-venus-image

That should point you in the right direction of the instructions. Then it depends on if you have a rpi2,rpi3 or rpi4 which image you need to download. There is a version called venusos-large that includes node-red but I am not sure how well that runs. My install is from before this was available so I don't have that on my venusos rpi. Node-red runs on the same NUC as HA does.

no problem. The NUC is just a really small PC not much bigger than a Victron MPPT in my case. Just remember that Home assistant runs on a system with SSD storage and has enough RAM. That might be a challenge with some thin-clients depending on how old they are.


Merry Christmas :)
The thin client I bought has 8gb ram and 32gb SSD hope that’s big enough.
 

Attachments

  • 4DAFD7F2-8FA2-43E8-B9D6-DB79A76CE6A3.png
    4DAFD7F2-8FA2-43E8-B9D6-DB79A76CE6A3.png
    1 MB · Views: 6
  • A3784A4F-A5C5-46A7-9B35-8C3EB82A3ACB.png
    A3784A4F-A5C5-46A7-9B35-8C3EB82A3ACB.png
    903.4 KB · Views: 4
The thin client I bought has 8gb ram and 32gb SSD hope that’s big enough.
That should be enough. I would be suspicous of the SSD though because of it's size it's either really old or a special type for thin clients. The specs say 32GB SATA so that might mean it's replaceable. I am not saying you have to replace it but it might not be designed for a lot of writes that HA does, and it would be just as bad as an SD card on a rpi.
 
That should be enough. I would be suspicous of the SSD though because of it's size it's either really old or a special type for thin clients. The specs say 32GB SATA so that might mean it's replaceable. I am not saying you have to replace it but it might not be designed for a lot of writes that HA does, and it would be just as bad as an SD card on a rpi.
Well I don’t have much in it. Ended up paying $37 shipped. Worth a go at least.
 
Well I don’t have much in it. Ended up paying $37 shipped. Worth a go at least.
That's a great deal! For that price and for just testing you can't go wrong. Let me know when your setup with VenusOS on a Rpi and Home Assistant with Node-Red on your thin-client. Then I'll try giving the steps to integrate the SmartShunt values into HA with the help of node-red and VenusOS.

But the minimum setup you need working is:
- on the VenusOS Rpi:
- VE.Direct connected SmartShunt
- MQTT on local lan (not sure if it's called exactly that...but really close)
- on HomeAssistant:
- the HACS repository for community plugins
- if using the OS image, node-red is just another plugin but not sure how it integrates automatically.
- inside node red
- an MQTT server configuration pointing at your VenusOS rpi
- you can give this a name and use it for later
- the node-red-contrib-home-assistant-websocket plugin

I did not say it was going to be easy did I ;)

When you have these installed and configured we can continue with building the flow in node-red.

To make things easier and to know what values are available you can use MQTT Explorer to connect to the rpi directly and it should show you the messages and a tree structure which among other things contains your installation ID. NEVER SHARE THIS! It's an identifier that "might" give others access to your installation remotely. At least that is what I understood about it...just treat it like a password you can't change.

And it's this installation ID that we will later need inside node-red to subscribe to the right messages.

I really hope I am not boring anyone at this point...but for now I will stop until you confirm you are ready with all of the above.

EDIT: Just to make it clear...I am not saying node-red is the only way to do this. It can be done directly in HA with configuration of the yaml configuration, I just have not got around to figuring out how exactly. for me node-red was a little more flexible and it seems stable enough for my usage.
 
Last edited:
So my first step I think is to get HA onto the thin client and activate MQTT on Solar Assistant since I have that up and running. I’ll get the integrations working in HA. Once I have my feet wet on that. I have another Pi here and at first I’ll install VenusOS on that use the Victron USB adapter cable from the Smart Shunt to the Pi running VenusOS. Once I get that done then I’ll be in uncharted waters. I’ll reach out once I get to that point. I appreciate all your advice. I see there are lots of integrations available for HA. I have several systems I should be able to bring in like Hue, Yolink, Pentair etc. if it all works like I think it should it will be a great front end for all our automations.
 
my thoughts exactly but it actually doessn't say ssd on the graphic itself.

so i think it's just a standard 32gb hdd drive which should be fine
 
my thoughts exactly but it actually doessn't say ssd on the graphic itself.

so i think it's just a standard 32gb hdd drive which should be fine
True, the screenshot does not specify it's an SSD. But since these were intended as thin clients they normally are really silent...meaning no HDD and possibly not even a noisy fan. Looking up the specs for a Dell Wyse 5020 Thin Client reveals that it's even worse.....it's FLASH memory!!
1672947461662.png
source: https://objects.icecat.biz/objects/mmo_33718413_1480059440_475_23478.pdf

The good thing though is that is a DiscOnModule apparently (read that somewhere else) that plugs directly into a SATA port on the motherboard. So it should not be that difficult to replace it with a good SSD.
 
I have it working through node-red showing everything and more in HA. ?
View attachment 125473

The flow is a bit complex and took a while to figure out but this is what it looks like:
View attachment 125472

It does require a VenusOS device with MQTT enabled on local LAN, which from your question I guess you do not have. Node red just subscribes to the SmartShunt topics and in a function node I filter and reformat the messages and then use node-red companion entities to send these values to HA.

With the SoC now available in HA I can run automations to turn the charger on at 25% and off again when it's at 50%. This has been working great the last few months and I now don't need to worry about a low SoC anymore.
Hello,

it very good idea to use NodeRED.
Could you please explain what kind of functions you used in this flow?

Sid
 
Well, I've bought me a Raspberry Pi 3 B off fleabay, £51 ? Ordered some usb to ttl serial cables and some jst plugs. Just got to wait for it all to arrive then I can venture in to the Venus OS ?

My solar set up is at the back of the house, I work from the front of the house (typical old 3 bedroom terraced UK house) and I want to see what my solar is doing now the sunnier weather is coming ?

If I get stuck, I'll be back ??
 
Well, I've bought me a Raspberry Pi 3 B off fleabay, £51 ? Ordered some usb to ttl serial cables and some jst plugs. Just got to wait for it all to arrive then I can venture in to the Venus OS ?

My solar set up is at the back of the house, I work from the front of the house (typical old 3 bedroom terraced UK house) and I want to see what my solar is doing now the sunnier weather is coming ?

If I get stuck, I'll be back ??
Come back and share I’m looking at doing the same thing. I’m going to tackle home Assistant first.
 
Hello,

it very good idea to use NodeRED.
Could you please explain what kind of functions you used in this flow?

Sid
Thanks. I was going to post that but I wanted to give @jfpetesn some time to get VenusOS and Home Assistant running before overwhelming everyone with all that technical stuff ?

On the left are MQTT blocks that output a "parsed JSON object". And the topic they subscribe to is in the following format:

SoC = N/{vrm-portal-id}/battery/+/Soc
Voltage = N/{vrm-portal-id}/battery/+/Dc/0/Voltage
Current = N/{vrm-portal-id}/battery/+/Dc/0/Current
Power = N/{vrm-portal-id}/battery/+/Dc/0/Power
ConsumedAmphours = N/{vrm-portal-id}/battery/+/ConsumedAmphours
TimeToGo = N/{vrm-portal-id}/battery/+/TimeToGo

To get your "{vrm-portal-id}" there are three ways that I know of:
- On your VenusOS device go into "menu -> settings -> VRM Online Portal" and your VRM Portal ID is shown there
- Go into the VRM portal -> settings -> general and the VRM Portal ID is shown here
- Connect to your VenusOS device with MQTT explorer and whait a little while for the messages to come in. After a few seconds click on the N topic...and you will see your VRM Portal ID.

Then what I do in the "ReFormat" function block is this:
JavaScript:
// Reformat and normalize the VenusOS values

var topic = msg.topic;
topic = topic.replace("N/{vrm-portal-id}/", "");

if (topic.startsWith("solarcharger")) {
    //venus_handle_scc(topic.replace("solarcharger/", ""), msg);
} else if (topic.startsWith("battery/")) {
    venus_handle_battery(topic.replace("battery/", ""), msg);
}

return msg;


function venus_handle_battery(topic, message) {
    var id = topic.substring(0, 3);

    topic = topic.replace(id + "/", "");
    switch (topic) {
        case "Soc":
            message.payload.value = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_soc";
            break;
        case "Dc/0/Voltage":
            message.payload.value  = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_voltage";
          break;
        case "Dc/0/Current":
            message.payload.value = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_current";
            break;
        case "Dc/0/Power":
            message.payload.value = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_power";
            break;
        case "ConsumedAmphours":
            message.payload.value = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_consumed_amp_hours";
            break;
        case "TimeToGo":
            if (message.payload.value===null) {
                message.payload.value = NaN;
                //message.payload.data = message.payload;
            } else {
                message.payload.value = parseFloat(message.payload.value).toFixed(2);
            }
            message.payload.sensor = "victron_battery_time_to_go";
            break;
    }
}

Next is a delay node to limit the number of messages and updates that go to Home Assistant.
1673954847679.png

I had hoped it would be possible to use a single output for each value and just put the name of the HA entity in the payload. But I could not find a way. As a workaround I put in a switch node that takes the reformatted values and has an output for each one. Those are then connected to the individual HA Sensor Node's. I can explain the configuration for each of them later if required, but it should be obvious I think ;)

Since I figured out a way to calculate the remaining charge time for the current going into the battery I also wanted that in home assistant. So I take the values for Voltage, Current, Power and ConsumedAmpHours and send those to a second function block:
JavaScript:
switch(msg.payload.sensor) {
    case "victron_battery_voltage":            flow.set("charge_voltage",  msg.payload.value); break;
    case "victron_battery_current":            flow.set("charge_current",  msg.payload.value); break;
    case "victron_battery_power":              flow.set("charge_power",    msg.payload.value); break;
    case "victron_battery_consumed_amp_hours": flow.set("charge_consumed", msg.payload.value); break;
}

var voltage = flow.get("charge_voltage");
var current = flow.get("charge_current");
//var power   = flow.get("charge_power");
var consumed = flow.get("charge_consumed");

var time = Math.abs(consumed) / current;

if(time>0) {
    msg.payload.sensor = "victron_battery_charge_time"
    msg.payload.time   = (time * 3600).toFixed(2);
} else {
    msg.payload.sensor = "victron_battery_charge_time"
    msg.payload.time = NaN
}
return msg;

This basically stores the incoming values as flow variables to "remember" earlier values of other sensors. Then with some math this is calculated into "seconds remaining to charge" and HA will show actual hours and minutes based on this. If the value is negative a NaN is outputed (Not A Number) so HA will not freak out over the value. This also goes into a limiter to only send a value to HA every 5 seconds

And that for the most part is what my flow is doing to get this data into Home Assistant. ?

Hope that helps.
 
Thanks. I was going to post that but I wanted to give @jfpetesn some time to get VenusOS and Home Assistant running before overwhelming everyone with all that technical stuff ?

On the left are MQTT blocks that output a "parsed JSON object". And the topic they subscribe to is in the following format:

SoC = N/{vrm-portal-id}/battery/+/Soc
Voltage = N/{vrm-portal-id}/battery/+/Dc/0/Voltage
Current = N/{vrm-portal-id}/battery/+/Dc/0/Current
Power = N/{vrm-portal-id}/battery/+/Dc/0/Power
ConsumedAmphours = N/{vrm-portal-id}/battery/+/ConsumedAmphours
TimeToGo = N/{vrm-portal-id}/battery/+/TimeToGo

To get your "{vrm-portal-id}" there are three ways that I know of:
- On your VenusOS device go into "menu -> settings -> VRM Online Portal" and your VRM Portal ID is shown there
- Go into the VRM portal -> settings -> general and the VRM Portal ID is shown here
- Connect to your VenusOS device with MQTT explorer and whait a little while for the messages to come in. After a few seconds click on the N topic...and you will see your VRM Portal ID.

Then what I do in the "ReFormat" function block is this:
JavaScript:
// Reformat and normalize the VenusOS values

var topic = msg.topic;
topic = topic.replace("N/{vrm-portal-id}/", "");

if (topic.startsWith("solarcharger")) {
    //venus_handle_scc(topic.replace("solarcharger/", ""), msg);
} else if (topic.startsWith("battery/")) {
    venus_handle_battery(topic.replace("battery/", ""), msg);
}

return msg;


function venus_handle_battery(topic, message) {
    var id = topic.substring(0, 3);

    topic = topic.replace(id + "/", "");
    switch (topic) {
        case "Soc":
            message.payload.value = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_soc";
            break;
        case "Dc/0/Voltage":
            message.payload.value  = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_voltage";
          break;
        case "Dc/0/Current":
            message.payload.value = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_current";
            break;
        case "Dc/0/Power":
            message.payload.value = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_power";
            break;
        case "ConsumedAmphours":
            message.payload.value = parseFloat(message.payload.value).toFixed(2);
            message.payload.sensor = "victron_battery_consumed_amp_hours";
            break;
        case "TimeToGo":
            if (message.payload.value===null) {
                message.payload.value = NaN;
                //message.payload.data = message.payload;
            } else {
                message.payload.value = parseFloat(message.payload.value).toFixed(2);
            }
            message.payload.sensor = "victron_battery_time_to_go";
            break;
    }
}

Next is a delay node to limit the number of messages and updates that go to Home Assistant.
View attachment 130075

I had hoped it would be possible to use a single output for each value and just put the name of the HA entity in the payload. But I could not find a way. As a workaround I put in a switch node that takes the reformatted values and has an output for each one. Those are then connected to the individual HA Sensor Node's. I can explain the configuration for each of them later if required, but it should be obvious I think ;)

Since I figured out a way to calculate the remaining charge time for the current going into the battery I also wanted that in home assistant. So I take the values for Voltage, Current, Power and ConsumedAmpHours and send those to a second function block:
JavaScript:
switch(msg.payload.sensor) {
    case "victron_battery_voltage":            flow.set("charge_voltage",  msg.payload.value); break;
    case "victron_battery_current":            flow.set("charge_current",  msg.payload.value); break;
    case "victron_battery_power":              flow.set("charge_power",    msg.payload.value); break;
    case "victron_battery_consumed_amp_hours": flow.set("charge_consumed", msg.payload.value); break;
}

var voltage = flow.get("charge_voltage");
var current = flow.get("charge_current");
//var power   = flow.get("charge_power");
var consumed = flow.get("charge_consumed");

var time = Math.abs(consumed) / current;

if(time>0) {
    msg.payload.sensor = "victron_battery_charge_time"
    msg.payload.time   = (time * 3600).toFixed(2);
} else {
    msg.payload.sensor = "victron_battery_charge_time"
    msg.payload.time = NaN
}
return msg;

This basically stores the incoming values as flow variables to "remember" earlier values of other sensors. Then with some math this is calculated into "seconds remaining to charge" and HA will show actual hours and minutes based on this. If the value is negative a NaN is outputed (Not A Number) so HA will not freak out over the value. This also goes into a limiter to only send a value to HA every 5 seconds

And that for the most part is what my flow is doing to get this data into Home Assistant. ?

Hope that helps.
Thank you I’m peddling just a little behind.
 
Come back and share I’m looking at doing the same thing. I’m going to tackle home Assistant first.
So the Pi arrived a day earlier than expected, that was nice ?

I followed off grid garages tutorial on how to set it all up (google his website). Was very easy to follow too. I had 1 issue, the Pi I got, the wifi doesnt work on it ?

Luckily I’ve got a spare TP Link wifi extender with ethernet port, so its connected with ethernet to the wifi extender.

Venus OS is ok, its just the app but bigger graphs for example. I am happy I can monitor my PV Yield and battery levels from my works laptop now ? Venus OS also works through the Victron App, just swipe to VRM, tap on the GX, and it’s the devices I already have using the Bluetooth connection. Only difference tho, you can scroll back through history in the trends tab.

I’ve only got 2 panels connected to my 100/30, the other 2 panels are connected to my Iconica AIO, so I cant monitor their usage. So what have I gone and done? Bought another 100/30! ? Was on offer too, £169.00 on amazon.co.uk. I can then use the AIO as just the inverter. Needs must hey! ?
 
Ugh, sorry all. Not sure why that 404’d…

Here is the GitHub link again:
https://github.com/KalebTheMaker/VictronSmartShunt-ESP8266-MQTT

Kaleb is there any way to connect the SmartShunt directly to a RPI using Home Assistant? (ve.direct to USB cable)

I've had two RPI's in my off grid cabin, one running Venus OS and one HA. But I just screwed up trying to update my Venus OS and can't get it to work (surely some crap with the partitions of my SD card). I tried to plug in my Victron devices directly to the HA RPI, but nothing shows up.
 
Back
Top