How I made my dumb wallbox smart, part 1

How I made my dumb wallbox smart, part 1

As proud owners of a fully electric Volvo XC40, we rely on a wallbox to juice up our ride — but it turns out, it’s not quite as smart as the car itself. Due to our leasing contract, we had no say in the selection of the brand or model of the wallbox. We ended up with the “Advanced” wallbox from Shell Recharge/NewMotion. Despite its name and marketing as “super flexible”, it was anything but flexible. There is no API, no official way to automatically start a charging session, no way to limit the charging speed, etc. Whenever a charging session is initiated, either by swiping our badge or clicking the start button on the Shell website, the wallbox immediately begins charging at 25A, its maximum speed.

In Flanders, a portion of your electricity bill is influenced by your peak usage of the power grid. This “capacity tariff” can be substantial if the wallbox charges at its maximum speed. This is why I tried to come up with a solution.

Slow and steady wins the charge

My initial fix to address the capacity tariff comprises two components: controlling the charging speed and automating the start and stop of charging sessions. Fortunately, the XC40 allows limiting the charging speed from the side of the vehicle. This way, I could easily set a fixed limit of 8A. This leaves 2-3A headroom for the rest of the house and still stay below the 2500W minimum threshold of the capacity tariff.

While the car can be set to charge as slowly as 6A, this of course also results in longer charging times. At 8A, I can charge about 50% of the battery per day, which has been more than enough for the past year.

Puppeteer to the rescue!

To eliminate the need for repeated badge swipes, the next step involved automating the initiation of charging sessions. I used a Puppeteer script for this purpose. Puppeteer is a software tool which enables programmatic control of a web browser. I created a script that logs into the Shell website, navigates to the charging page, and clicks the button to commence a charging session. With this script in place, I could start and stop a charging session using a shell script. The script can be found here as a GitHub Gist.

I then added this script to Home Assistant as a switch, so I could easily toggle charging from my dashboard. One step closer to a smart wallbox.

command_line:
 - switch:
     name: Wallbox charging
     unique_id: wallbox_charging
     scan_interval: 5
     value_template: "{{ states('binary_sensor.wallbox_charging_session') == 'on' }}"
     command_timeout: 30
     command_on: |
       ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no bart@nuc "cd wallbox; node index.js start"
     command_off: |
       ssh -i /config/.ssh/id_rsa -o StrictHostKeyChecking=no bart@nuc "cd wallbox; node index.js stop"

Dodging spikes

This solution worked effectively, but it lacked flexibility. If I activated my oven or heat pump during charging, I would easily surpass the 2500W threshold, resulting in additional charges. Luckily, I already had excellent power monitoring in Home Assistant using the p1 port of my meter in combination with dsmr-reader. I created an automation that temporarily stops charging when it detects high power consumption. While not perfect, this strategy proved to be good enough, in part because the capacity tariff is calculated based on 15-minute peaks.

Charged Up, But Not Fully There

Charging at 8A proved fast enough to fulfill almost all my charging needs. Additionally, the Home Assistant scripts effectively minimized usage peaks. As you can see on the graph below, we successfully stayed below 3.5kW in most months. The only exception was December, where a peak of 6.66kW was recorded due to a New Year’s Eve party.

Peak usage

While I’m happy with the results — and my electricity bill is too — there’s always room for more tinkering. We are now always charging with a fixed speed of 8A, however, there are times when I would like to increase this speed. For instance, during sunny days in spring, my PV panels produce 5kW of electricity but I only use ~2kW to charge the car. The remaining energy is fed into the grid with only a minimal financial compensation. In the second part of this blog, I will explore a more advanced solution to address this issue.