question

Matt Knight avatar image
Matt Knight asked

Home Assistant integration with Victron

I'm a big fan of the open nature of Victron's platform - both the API and the data itself. We've been using this to great effect in our RV, using the rich, real-time data from our Victron CCGX not just for monitoring but also to integrate into our home automation system.

One such use case is bringing the data into Home Assistant. I'm using MQTT via an intermediary MQTT broker so that I can have multiple consumers without increasing the load on the CCGX itself. This has been running flawlessly for almost 2 years now.

Here's an example of the data I'm pulling into Home Assistant and how it appears:

The real power, however, comes from not just displaying the data but using it to make physical changes via automations.

For example, most of the time we have our inverter turned off due to the background power draw which is significant in our modest RV setup (600W solar + 300Ah lithium batteries). When dry camping and all our power is coming from solar, we have it set up to automatically turn on the inverter when the batteries hit 90%. The fridge switches from propane to AC at 95%, and at 98% the electric water heater turns on. There is hysteresis configured to turn each toggle off at lower SoCs too.

We're planning to spend this winter in a very cold climate (northern Vermont where temperatures could reach 0°F). Our RV has a 30A main breaker, which is easily exceeded if we run too many appliances - e.g. water heater, space heater, Instant Pot. I'm planning another automation which will automatically and temporarily turn off the water heater and / or space heater if we're at risk of exceeding the capacity of either our main breaker or MultiPlus output (computed in real-time based on shore power connectivity).

Having the data from the Victron system integrated alongside the data from our other home automation system (10+ environmental sensors, contact sensors, GPS, lights, appliances, media, networking data etc) is an incredibly powerful platform that is helping to make our RV more secure, more efficient and most importantly, more comfortable for us to live in.

As I said earlier, the Victron data is being ingested via MQTT but I'm hoping to find some time this winter to work on a native integration with Home Assistant. If anyone from Victron is interested in being involved in that process, please let me know!

Again, hope this inspires people with a few ideas, and thank you again to the team at Victron for making all this possible!

home assistant
14 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.

ziegler-felix avatar image ziegler-felix commented ·
Are there any news on an official HA integration?
3 Likes 3 ·
Show more comments
hummingbear avatar image hummingbear commented ·

Would you be open to posting some of the configuration.yaml you used for setting up sensors via HomeAssistant?

2 Likes 2 ·
Show more comments
frederikbove avatar image frederikbove commented ·

Any update on this project? I’m currently also using home assistant with a Victron installation.

I found it easier to work with mqtt instead of modbus and also the update rate on mqtt is higher then on modbus in HA

1 Like 1 ·
Show more comments
Erik Aslaksen avatar image Erik Aslaksen commented ·

@Matt Knight Great work! Can you please share your config-files?

0 Likes 0 ·
Show more comments
Drew Strobel avatar image Drew Strobel commented ·
Can you share your yaml for both the mqtt switches and the Lovelace cards?


0 Likes 0 ·
15 Answers
mvader (Victron Energy) avatar image
mvader (Victron Energy) answered ·

Hey @Matt Knight, very interesting! I'm interested in being involved - mainly to help where I can to give tips and tricks of what we'd think is the best approach.

Not so much - I'm afraid - in actual developing.

One thing thats good for you to be aware of is this: https://www.victronenergy.com/live/venus-os:extended.

And otherwise, sounds very promising, Home Assistant. I'm not too familiar with it right now I'm afraid; too little time to play with anything outside direct Victron eco-system :).

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

Matt Knight avatar image Matt Knight commented ·

Looks very interesting - I'll have to read up more on that. I will say I've been using NodeRED very successfully in my setup for a while, but it's got to the point where Home Assistant can do so much of what I need that I'm able to pull some of the more complex logic back out of NodeRED and put it in Home Assistant.

Home Assistant is great, and it'd be great to see Victron amongst the 1,685 integrations they already have! https://www.home-assistant.io/integrations/

I'm happy to do the development - it's just Python, so nice and accessible.

Where some Victron support would be appreciated would be on any best practices for interacting with the Victron GX system. I'm sure I'll discover uncertainties as I go, but for example:

Would MQTT or modbus TCP be the preferred architectural integration for the Victron? Python & Home Assistant can (and do) happily support both.

0 Likes 0 ·
fenix avatar image fenix Matt Knight commented ·

Any progress to integrate Victron to Home Assistant?

2 Likes 2 ·
Jimmy Bergetun avatar image Jimmy Bergetun Matt Knight commented ·

I am soooo looking forward to see Victron integration to Home assistant.

Any progress?

2 Likes 2 ·
Sam Wutschke avatar image Sam Wutschke Jimmy Bergetun commented ·

Have the same wishes!
Yes the Modbus and the MQTT are pretty easy, but you have to manually configure every sensor.

Would be way easier with an integration, so the sensors are directly seen.

So hope this is going to happen!

2 Likes 2 ·
nickdb avatar image nickdb ♦♦ Jimmy Bergetun commented ·

Using modbus is dead easy, once you get your head around the syntax needed.

Works like a charm in home assistant.


1 Like 1 ·
Jimmy Bergetun avatar image Jimmy Bergetun nickdb ♦♦ commented ·

Thanks @nickdb . Ill have a look at it. The advantage mqtt have is that i can have other clients connected to the HA´s MQTT broker. Also, as far as i understand you manually have to add each device to HA if you use modbus ?

Will Victron also forward device data on the nmea2000 network into modbus ?

0 Likes 0 ·
arminf avatar image arminf Matt Knight commented ·

+1 interested in a HA Add-on and Integration

1 Like 1 ·
mvader (Victron Energy) avatar image mvader (Victron Energy) ♦♦ Matt Knight commented ·

Hi again, yes Home Assistant looks *much* more accessible than Node-RED does.

MQTT vs ModbusTCP: good question. I guess both work for us. MQTT allows the option to implement some sort of security - though we don't currently do that for the MQTT on LAN option.

Both have a CPU penalty when enabled (catching all the D-Bus signal changes).

MQTT is "closer" to the internal databus we use (D-Bus), since there is a one on one mapping between MQTT topics and D-Bus paths [1]. But the disadvantage is that we might change path now and then, which for MQTT is then too bad - any application using it will have to adopt.

Whereas for ModbusTCP we'll make more efforts in keeping it stable.

D-Bus paths, and therewith MQTT topics, won't change often though, a lot things break also internally for us in case we change one.

I'll think about it a bit more - but currently I don't see a clear winner for the Home Assistant application.


[1] https://github.com/victronenergy/dbus-mqtt

0 Likes 0 ·
Keith Weinheimer avatar image Keith Weinheimer Matt Knight commented ·

@Matt Knight would you will willing to share you HA config that produces the screen shot you shared?

0 Likes 0 ·
jeep15cba avatar image jeep15cba Matt Knight commented ·

Wouldn’t it be possible to run both Venus OS and Home Assistant on the ‘same’ Pi making it easy to integrate into HA.

0 Likes 0 ·
fenix avatar image
fenix answered ·

How do we define Unique Id

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.

hummingbear avatar image hummingbear commented ·

Are you referring to the device ID used in the MQTT paths? If so there is no UUID currently but there has been mention that victron will be moving to some kind of UUID to reference the device

0 Likes 0 ·
fenix avatar image fenix hummingbear commented ·

i found this

dbus_modbustcp/CCGX-Modbus-TCP-register-list.xlsx at master · victronenergy/dbus_modbustcp · GitHub

0 Likes 0 ·
hummingbear avatar image
hummingbear answered ·

I didn't know about home assistant until I read this post and I'm fascinated. I've been editing the venus html react app to give me a sudo dashboard to monitor my power and also toggle some custom relays and wifi outlets I have setup. There is some additional logic i've wanted to build out and was going to use NodeRed but it sounds like HA might be a bit more friendly.

I'm curious how you're using MQTT via an intermediary MQTT broker and connecting that to HA? Could you or do you already have a place where you can share how you've setup your current integrations? I'm a developer and would be glad to pair on getting some integrations built out for Victron. One thing I would love to see is a UUID for devices as the device IDs can change and I've had issues with that.


My dashboard below:

1607966149876.png

1607966169456.png


1607966149876.png (111.0 KiB)
1607966169456.png (96.6 KiB)
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.

alnavasa avatar image alnavasa commented ·
how did you edit the HTML5 app, is there any tutorial?
0 Likes 0 ·
David Borg avatar image
David Borg answered ·

There were this Youtube video from Victron https://www.youtube.com/watch?v=9vDSRh6rmis

But no exemple or instructions how to make it?
Cant find any other information either?

For us that dont know modbus, mqtt, node-red, python.

2 |3000

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

Stephen Kunkel avatar image
Stephen Kunkel answered ·

I saw this post while searching as a noob to all of this. I found this blog from a European gentleman that helped me succeed in setting up a nice dashboard for my "V" things. Felt like sharing with all the other noobs that don't have time for courses in coding/automation but have a requirement with a low budget. https://www.imval.tech/index.php/blog/add-your-victron-system-in-home-assistant#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.

wittyhat avatar image
wittyhat answered ·

Just wanted to add that I put together a detailed overview of how to integrate victron energy management (via Cerbo GX) into home assistant, on a boat, here:

https://boathackers.com/boat-energy-management-using-victron-and-home-assistant/

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

Martin Vockerodt avatar image Martin Vockerodt commented ·

That's a nice setup you have there. :)

You are supplying data to the home assistant energy distribution dashboard but I don't see in your configuration where you are pulling the data via modbus to feed into it. Can you elaborate on what you have set up for that?

0 Likes 0 ·
peternielsen avatar image peternielsen Martin Vockerodt commented ·

yeah i noticed that too and have same question.....

@wittyhat maybe you could let us know how you did that or even share the homeassistant code ?

0 Likes 0 ·
wittyhat avatar image wittyhat peternielsen commented ·
I'm confused about what you're asking for. The entire post is a step by step guide to how to get the data, including all code and configuration for homeassistant?
0 Likes 0 ·
peternielsen avatar image peternielsen wittyhat commented ·
@wittyhat on your hass dashboard you have the new energy dashboard showing power from PV, grid and battery. which of the sensors have you used for the energy dashboard ?
0 Likes 0 ·
wittyhat avatar image wittyhat peternielsen commented ·

Oh I see, sorry for misunderstanding! You can convert Modbus sensors to integration sensors to calculate energy values which can be ingested by Home Assistant energy-management features. I'll probably do a 2nd post about this, but here's an example of taking the "solar_power" modbus sensor and creating a new "solar_energy" sensor based on it:



- platform: integration

source: sensor.solar_power

name: Solar energy

unit_prefix: k

unit_time: h

method: left

round: 2

0 Likes 0 ·
johan-anderholm avatar image johan-anderholm wittyhat commented ·
In the case of victrons solarchargers they already reports its total lifetime yield which I believe is more suitable since it should be more exact and will keep tickdng when home assistant isn't running.


Not that the integrating sensor isn't a great thing! It's good if there's no other option.


0 Likes 0 ·
sesshoumaru avatar image sesshoumaru commented ·
Cool, that will be a good example for me to start.

By the way, how did you make the distribution graph (energy flow diagram)?

I thought I may use a web-page card to show the native local victron console, but yours looks so stylish ;)

0 Likes 0 ·
d3-energy avatar image d3-energy sesshoumaru commented ·

It is the standard energy card in home assistant:

type: energy-distribution
link_dashboard: true
1 Like 1 ·
sesshoumaru avatar image sesshoumaru d3-energy commented ·
Nice, didn't know that this was already build in. Will try once I made the ModBus config.
0 Likes 0 ·
sesshoumaru avatar image
sesshoumaru answered ·

Once my home assistant is set up I also would like to integrate my Quattro II + Pylontech system into it. I know there is docker grafana ( https://github.com/victronenergy/venus-docker-grafana ) but Home Assistant also uses Grafana with influxDB to record its states. Would be a waste to have it twice.


Would really be a great thing if somebody, maybe even victron, provide a custom component for home assistant. Thats the future and all the automation possibilities would be greatly appreciated.

2 |3000

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

ajm avatar image
ajm answered ·

@Matt Knight do you perhaps have any info regarding an official HA integration I see you have done cool things would be great to have a chat.I recently started using modbus.

2 |3000

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

sesshoumaru avatar image
sesshoumaru answered ·

How is the "preferred" way to integrate Victon in 2022 with HA?
Are there works on an integration? Over ModbusTCP? Over MQTT?


My system is finally up and I would like to integrate now with HA :)

2 |3000

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

dylan-hyslop avatar image
dylan-hyslop answered ·

Just to bump up this thread, I was also very disappointed to not see a Victron integration on the Home Assistant website, A lot of victron's competitors etc are all there.

Has anyone found a step by step instruction on how to do the integration via modbus?


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

sfstar avatar image sfstar commented ·

Just a small heads-up for anyone interested.
I’m working on a modbus GX victron custom integration to simplify the HA → victron integration.

https://github.com/sfstar/hass-victron

Integration for Home Assistant to fetch data from the victron gx device via modbusTCP - GitHub - sfstar/hass-victron: Integration for Home Assistant to fetch data from the victron gx device via mod...

This integration automatically discovers devices that are part of your victron setup and will make all registers available as entities.
Read only support works without any issues.
Write support is mostly working but needs some finetuning and better limiting (in order to prevent you from setting too high or low power,voltage and current values in your system.

7 Likes 7 ·
sfstar avatar image sfstar sfstar commented ·
The integration is now mature enough to be considered in an acceptance state.

This means you can use all functionalities without any issues expected.
Although (since I don't have all victron gear to test with and the demo modus also don't cover all devices) you might run into small bugs.
If this occurs please open a issue so that I can resolve that issue as well.


There are currently no breaking changes planned anymore.
Only connection loss resiliancy and code refactoring needs to happen for the release to become production ready

2 Likes 2 ·
tinovieira avatar image tinovieira sfstar commented ·
Is it possible to configure this using the Energy page on Home assistant? I was able to use the integration and have access to a lot of entities ill use to do some automations ... But now i would like to use the production/consume/bateries ... to have that info on the Energy page like i have on VRM app or the GX console.
0 Likes 0 ·
peregrines avatar image peregrines sfstar commented ·
This is fantastic! Thank You very much and keep up your great work :)
1 Like 1 ·
heleb avatar image heleb sfstar commented ·

Wow, thanks ! Works well so far. Use it to read out min. cell temperature via HA and the turn on a heating pad (via a Shelly plug) if temperature gets too low.

1 Like 1 ·
Juha Tuomala avatar image Juha Tuomala sfstar commented ·
Thank you!
1 Like 1 ·
arminf avatar image arminf sfstar commented ·
Works nicely! Thanks!

I had HACS installed and went this route. Took me 3 minutes to get it running.

0 Likes 0 ·
Juha Tuomala avatar image
Juha Tuomala answered ·

Correct if I'm wrong, but there is no Home Assistant topic in this forum? Who could make it happen?

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

nickdb avatar image nickdb ♦♦ commented ·
There are plenty of topics about home assistant. You are welcome to open your own.

I suspect something is being lost in translation.

Just search for it..

0 Likes 0 ·
Juha Tuomala avatar image Juha Tuomala nickdb ♦♦ commented ·
I meant this forum topic, it's a technical concept in this software. It helps to follow topics that you select.
1 Like 1 ·
Juha Tuomala avatar image Juha Tuomala Juha Tuomala commented ·

Now there is https://community.victronenergy.com/topics/70470/home%20assistant.html

0 Likes 0 ·
Patrick avatar image
Patrick answered ·

Lots of Victron posts on the HA community site ...

https://community.home-assistant.io/search?q=Victron

2 |3000

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

Holger Winkelmann avatar image
Holger Winkelmann answered ·

Would it not help, Victron Simply adds MQTT Discovery Topics to the already existing MQTT they have?

2 |3000

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

lsgv avatar image
lsgv answered ·

As this is the first thread that comes up when searching for home Assistant here are my 2 cents.

I started working on integrating Victron data into Home Assistant back in 2017 using the VRM API and have since tried MQTT and more recently modbus. Here is a short summary of what I've learned about the different methods available:

1. Use the VRM API as explained in this thread

When? If your Victron installation is remote and it's only connection to the "world" is via VRM and your HA instance is running somewhere else

2. Use MQTT as explained in many threads including this one but also here

When? If you're familiar with MQTT and envision the use of, for instance, Node-Red, for logic programming and automations

3. Use modbusTCP either using DYI config or using the excellent HACS integration from @sfstar (thank you so much for your work)

When? If you're familiar with modbus and like to keep it simple

After having used all 3 methods I am now and for the foreseeable future using modbus because I have other modbus integrations in my HA such as for instance swimming pool filters/clorinator, Fronius inverter, etc. which reduces the number of integrations and keeps it simple. But this is a purely personal choice, feel free to test and try and break and share your experiences.

If you want Victron's opinion please read Matthys' opinion on the subject on this very post

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.

sesshoumaru avatar image sesshoumaru commented ·
MQTT or Modbus (using this myself at the moment). No cloud APIs, no thanks :)
0 Likes 0 ·
hofy avatar image hofy commented ·
Hello lsgv,


it seems to be that you have spend already a lot of time in this topic.
I am confused to "not" find something about MQTT auto-discovery and Victron.

Is their a reason to not map the default victron stuff on MQTT auto-discovery so that its direct solved on the GX device and working out of the box?

All what I find is to export MQTT into home assist und add the sensors via config. I do not see the benefit for it.

Do I miss something?

Best regards

Sebastian

0 Likes 0 ·
seanwin23 avatar image
seanwin23 answered ·

Hello everyone just reading these awesome ides and just wondering has anyone got any information on using Alexa with MQTT with Victron cerbo and the after burrner diesel heater control

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

Additional resources still need to be added for this topic