icekream avatar image

Best option to charge EV car off grid in 2022 - OCPP, ModBus or just plain SOC+relay

Dear all,

This will be my first post on this community - reason for reaching out is that I really feel stuck and pretty lonely in this adventure. I've been disconnected from the grid for about 5 years - the setup has evolved, but today is based on Victron charger, additional Fronius inverter due to expansion of solar panels, 16 KWh lithium batteries and a bit over 10 KWp of solar panels installed. I live in Spain so most of the days there is no issue of sun.

My most recent expansion of solar panels was to prepare the arrival of my new hybrid car (which has a 24KWh battery) - but when I asked about installing a wallbox ... all my plans felt apart. The car charger installer told me there was no system on the market for off grid situations, and my Victron reseller told me they have no experience with EV charging

The problems with standard solutions

1) Most EV car charging have a "solar kit" which basically is a device you connect between the inverter and the house, which will continuously instruct the car charger to "suck as much amps as possible" from the solar panels (continuously configure car charger amp level to estimate max PV output minus house consumption). For usual inverter based implementations connected to the grid, no problem, for systems with a charger and batteries - it's a recipe for emptying (and over time killing) batteries as the charger will likely provide the max power possible (e.g. if you have a 10KW charger, the system will provide those 10KW from the batteries even if not available from solar)

-> traditional EV charging solar kits cannot be used

2) When the house lithium batteries are full, Victron will throttle the PV output to the house consumption - so to dynamically program the car charger to maximize PV energy consumption, batteries have to not be completely filled

-> traditional Victron charger behaviour will stop EV charging if coupled with an EV solar kit

3) The solution that will be recommended by most electricians is to install a programmable relay that will only provide electricity to the EV charger if the SOC > value x. The EV car charger vendor is telling me that cutting electricity going to the EV charger will regularly force a hard reset and is a bad idea - as an EV charger is not just a plug.

-> unless if proven otherwise programmable relays based on SOC state is not an option

Looking at this community, this is not the first time someone is looking into this.

I've been looking into this problem and I'm actively working on a solution

- I've got Python scripts getting all required data from the Victron GX over modbus (SOC, PV prod, consumption) - and my EV car charger vendor tells me that adding a Phoenix Contact EM-CP-PP-ETH car charge controller SHOULD work (Python -> Modbus -> Phoenix Contact -> RS485 -> Car charger to set the # amps)

- I've got HomeAssistant pulling the same data again over modbus (much cleaner and scalable approach) - would still need the Phoenix Contact likely.

- I have installed an OCPP server on HomeAssistant (if you are new to OCPP, check:, that IN THEORY should allow me to program dynamically the amount of amps without modbus on OCPP 1.6 smart charger (often smart = programmable in EV charging) ... but again no one able to confirm if this is working.

I am still trying to find the right ev car charger (e.g. wallbox) to start it all, but am wondering

A) Is there a better / less custom way of maximizing green car charging when off grid ? Or did I get any of the 3 problems above wrong ?

B) Has anyone got OCPP to work with a car charger for dynamically SETTING the # amps ?

C) Can someone recommend any programmable car charger that has natively proper ModBus register documentation (or OCPP documentation coming with it even better)

I'll gladly share all working python scripts or working HomeAssistant configurations once I got it working live.

Thanks in advance for any pointer!


battery charging
2 |3000

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

8 Answers
icekream avatar image
icekream answered ·

Dear all, took a while for the technician to come and install the Wallbox Commander 2 I had ordered, but last week it was installed so I finally had time to play with it. In about a day of research and discovery, I got an integration to work within Home Assistant with

- EV Charger control (Wallbox) - through Home Assistant OCPP integration (itself relies on OCPP python libraries)

- Car control (BMW) - through Home Assistant BMW connected drive integration (other brands available as well, just happened to own a BMW)

- PV & Home batteries control (Victron) - through ModBusTCP manual additions to Home Assistant (I wished Victron had web APIs like Fronius)

Bottom line is that it all works and I can do the following from my PC or mobile with Home Assistant

1) Start and stop EV charging from Home Assistant

2) Set dynamically the # amps to charge the car

3) Near real time see all car stats including charge status, # amps, remaining time to charge etc (and even some unrelated actions such has honking from Home Assistant, totally necessary but useless ;-))

4) Near real time see the PV production, house electricity demand & battery SOC

5) Build automation scripts with the possibilities offered by 1) -> 4)

6) Easily retain all data in a time series DB (e.g. Influx) and present the historical data nicely (e.g. Grafana)

7) Easily capture working VMs implementing the solution in Home Assistant and back them up in the cloud.

Usage of Home Assistant makes the overall integration much more easy than doing it all via Python or GoLang. Adding a few screenshots which should be self explanatory

Next steps ... play with automation and have fun to automate the heck out of it



1649598756015.png (297.3 KiB)
1649598783228.png (194.4 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.

shaneyake avatar image
shaneyake answered ·

Simple Solution is to install the Victron EV charger and you are done.

2 |3000

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

Bogdan Nedelcu avatar image
Bogdan Nedelcu answered ·

@IceKream given your setup, completely off-grid I imagine that the variations in provided power from the PV should be compensated from the battery, I don't think that a continous loop which dynamically adjusts the current requested by the car is possible to be in real-time sync with the PV power. Not sure even if this is OK for the car battery to have fluctuations in the charging process.

My system is grid connected and I use the above mentioned script ( to increase setpoint in order to draw needed power from the grid and not batteries when excess PV is not there to fill the car requirements. After some tests using the python script I see that reading from registers is a 1-second step process, I could not get faster than this. So basically I am always one second late with all measurements. This is why I used a running average of the measurements, as to avoid getting in oscillating states.

Looking forward to your progress and if I can be of any help please let me know.

2 |3000

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

icekream avatar image
icekream answered ·

@Bogdan Nedelcu, thanks for the first answer! I had a look at your script, and indeed you can adjust the power drawn from grid (your slave id 2700) whilst I can't - and yes if we minimize the power drawn from home batteries it's close to what I need. Building a similar script logic was one option I had considered (i.e. adjust car charging # amps based on most recent PV production read minus house consumption, temporarily drawing a minimum amount from house battery in for gaps in between measurements - just unsure of whether I should prefer a python modbus, ocpp or homeassistant plugins implementations).

Interestingly, if I understood your script correctly, it is mimicking what the solar kits of EV chargers do (They are an option of smart car chargers for many brands, whilst it's in Spanish, check the following video as of Min 6:10 (the icons should be self explanatory on the power generated/drawn), and if I understood your script correctly, the native solar kit app pretty well does the same

On the feasibility. If (and only if) you have a smart EV charger whose charge can be adjusted in theory it's possible. The native app allows you to set the EV charger outgoing amps from 6A (i.e. 1,380W @ 230v) to whatever power possible (in the case of the EV charger I'm looking at 32A = 7,360W @ 230v). Whilst setting it on the EV charger I'm considering is undocumented (except they state OCPP 1.6 compatibility), as the EV charger on my mind is a smart charger supporting RS 485, I could add a phoenix contact EV controller (250 euros more ...) which has clean documented ModBus. (but again ... if your EV charger supports RS 485 and if is a smart charger meaning you can adjust load in amps - which entry level EV charger never do)


Currently I've asked various people (this community, HomeAssistant communities, and various EV charging resellers) - and I'm collecting the answers. Pretty well though it's likely to be that no one knows - and that I'll have to purchase a smart charger and try out for myself.

I'll keep this thread live as I make progress and also publish all scripts I build.


1642063708076.png (20.8 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.

Gabriel-Adrian Samfira avatar image
Gabriel-Adrian Samfira answered ·

So funny thing. A friend of mine who is completely off the grid, asked me to write an app that does exactly what you describe. He wanted a way to adjust the maximum amps set on the charger, in a way that would not impact his batteries.

He wanted that any excess electricity (after subtracting household usage and batteries being charged in the morning) produced by the solar array to be sent to the EV. I ended up writing this:

This app was tested on a Color Control GX, connected to a Victron Energy inverter with a go-eCharger. The app runs on the ccgx itself, and listens to events from dbus and mqtt (the go-eCharger sends status updates via mqtt), then at a configurable time interval, if needed, sends an update to the charger, adjusting the amps to match the current solar panel excess.

It has 2 configurable thresholds to turn the charger on or off. If the available power dips bellow a configured value, it will turn off the charger, and another setting that allows you to set a threshold for when to turn the charger back on.

For example, if you dip bellow 3 amps, it will turn it off, and if you pass 6 amps, it turns it back on. This way you won't flap your charger, causing your EV to go into error state. As soon as solar irradiation goes down, the app will turn off the charger for the night.

As mentioned, this was only tested on his specific setup, but works quite well, with a decent memory footprint. With some modifications, it will probably work with other chargers as well. The license is Apache 2.0, so feel free to grab it, modify it, do whatever you want :).

Hope it helps. Cheers!

2 |3000

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

@Gabriel-Adrian Samfira thanks, really helpful.


Please let us know how you get on with this. Might help many more.

here is some sample output from the app, as it adjusts the amps:

Bogdan Nedelcu avatar image Bogdan Nedelcu Gabriel-Adrian Samfira ·

Nice script. Do you have any idea how to connect to this device?

AMPEVO from EV-MAG chargerswhatsapp-image-2022-01-14-at-125252.jpeg

If the charger has any kind of API the app can hook into (mqtt, dbus, modbus, etc), and has any kind of status (how much power it's drawing), the needed changes should be simple. If you have any kind of developer documentation I can look at, please share a link.

For example, the go-eCharger has this:

icekream avatar image icekream Gabriel-Adrian Samfira ·
I decided to move away from custom solutions relying on ModBus EV Controllers, too much danger in my view of things breaking some day over a firmware upgrade, I decided to focus on OCPP which is an industry standard that will work with all EV charger vendors.
Jens Rephöhler avatar image
Jens Rephöhler answered ·

I use a "OpenWB" for that. It is communicating with victron quite well and most ob the time it uses only solar power to charge (or otherwise is told to charge from battery). Works quite well !

Maybe an option for you ?


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.

Nice option! I was ideally looking for open standards based solutions, so I preferred the OCPP solution. Nevertheless, great to see it works for you.
tnt369 avatar image
tnt369 answered ·

Wallbox with modbus: Schneider Electric EVLINK

Also have a look at openEVSE Project. Works with MQTT.

Where are you located in Spain? I'm in Alicante area and have PV and EV.

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.

I'm in Alicante too ... how do we get in touch ;-)? Unable to find a way to PM you

jurekz avatar image
jurekz answered ·

Best solution is... a simple solution. You could use OpenEvse charger ( which is typically controlled by MQTT with energy send to grid data. But this is only a MQTT topics - you could create any data you need by NodeRed/any_data_IOT_tool to control yours charger.

Of course algorithm needs to be analysed - what is obvious: if you have fully charged battery, frequency shifting mechanism start limiting power from PV - and you could not calculate how much power is excessed (ok,you could increase charging PV until frequescy is below 50Hz, but is complicated) I think so you shpuld split the power between charging battery and the car untill battery reach 90% SOC - and than charge car with full PV power. That algorithm have to be tuned for yours needs.

This is not true that you unable to charge from battery storage - PV charger is normal load as any other - that guy normally charging his car that way in off-grid garrage (

2 |3000

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