Control charging for Tesla

I've got a solar panel on my roof and a Tesla to charge.
I'm monitoring the power generation and consumption since a while with node-red.
Just discovered the node-red-contrib-tesla node. This was the start for quite a long trip. And I'm not at the end yet.

The specification (yes, I did some minimal thinking before I linked nodes together):

  • set charging goals (90%|95%|100%) using the dashboard
  • set charging strategy (cheap | fast | until chosen end time)
  • charge immediately if there is enough solar power
  • charge immediately if there is a low tariff period
  • charge immediately, if there is not enough low tariff time until the chosen end charge time

I wanted to share how it looks at the moment in the node-red dashboard and the current development of the flows. More to come when time and energy allows.


Just an update from today:

  • needed to rework many settings, since I chose topic and variable names containing hyphens, which I shouldn't have in the first place
  • wanted to update the dashboard button backgrounds with another color as feedback, that the button is pressed and the command has been received by the tesla. Got tons of looping messages. Tagged them as feedback messages on the input side of the button and got rid of them after the button with a switch node. (I would like to have a setting in the button to disable pass-through.)

Here is how it currently looks:

I used the lunch break for some updates on my project:

  • added buttons for the charging strategy (cheap|fast)
  • added buttons as display for the battery charge level and if it is charging or not

I use buttons for the display too, since I use the background coloring, and the text node seems not to offer this in the same way, or at least I was not able to figure it out.
So far the whole thing is not very complex. All data is sent to the MQTT broker and fetched again from there if needed for actions or display.
What is currently missing is the charging logic, doing this in a flow based manner gives me headaches. But so far this journey was fun.


2 Likes

I do this project for two reasons:

  • to charge our Tesla car as economical as possible with our own solar energy (this is what I tell my wife too)
  • to have a fun project for me spare time (this should be kept secret among us)

The project made progress, therefore I was happy.
Until I had a closer look at the energy usage before and after my tinkering with the charge logic. But see for yourself.
This is the energy usage pattern from two days ago:


Yellow is the energy produced by the solar panels. Red and green is the energy used by the household (hot water starting at 10 o'clock, and Tesla charging at noon)
Quite nice.
Now here is the chart a day later (after my tinkering):

To my dismay I see the red spikes during the night. This is the Tesla recharging. The Tesla computer is quite powerful. Keeping the Tesla computer awake by polling it all five minutes for internal status data uses an enormous amount of energy. Therefore it recharges about every 2 hours or so. :confused:

Conclusions:

  • To save energy, the Tesla needs to sleep as much as possible
  • If the battery is fully charged, the car should sleep

I see two options for an improved charging strategy:

  • control the charging from the outside (buy a wallbox like the go-eCharger which talks MQTT, or a Sonoff POW device) and lets the Tesla sleep
  • continue to control the charging in cooperation with the Tesla, but optimise the charge logic for long sleep times

If you're interested, I will keep you posted with my progress/struggles. I got my vaccine shot, therefore I am now invincible and I will succeed.

3 Likes

Yep very interested in the logic here

Rather than keeping the Tesla awake couldn't you create a series of proposed charge times (particularly for evening)

Then check them if they are cheap- then wake the Tesla and send it into charge mode ?

Craig

Hello Craig
Thanks for your post. This is more or less along the line I'm currently thinking (but I got not past that stage yet).
I just found the discussion about solar forecast, opened an account and added my PV installation. Small steps, I know.

Since we usually do not use the car to commute to work (we prefer public transport and home office), I'm very interested in charging the car during the day when there is excess solar energy. But I need to be careful in the planning area, since this is also the time where there is a higher tarif for the grid energy.

I'm also struggling a bit with the programming side. node-red in my mind is primarily event triggered flows. I still try to wrap my head around the data models needed here. But I'm confident that I will get there in the end, it just takes time.

Have you looked over at the openenergymon.org forum ?

Great bunch of guys over there.

Have at look at the myenergi unit ? You can configure it with CT clamps so it knows how much excess solar you have and will divert that to the car (and no more)

It has an unofficial api also

It also has an add-on unit the Eddi - which lets you divert your unused solar (after the car is charged across to your hot water service.

Very slick

Craig

I used their emoncms as database/display tool for a few years since it was very easy to use.
A year ago I switched to the influxdb/grafana combo. I still follow loosely the OpenEnergyMonitor developments since there is always something to discover and learn.

I do have enough energy measure points in my house, using official technology installed by professional electrician.
What I do not have is a charger station for my electric car which would offer much more control and shorter charging time. I just use the 220V/10A standard plug. A charging station is about EUR1400/USD1600 in Switzerland. It would take years to recover the investment cost by charging more intelligent from solar power or low tariff.
Therefore I decided to use this as a hobby using node-red. With the solarcast information I have another tool at hand.

Interesting project (even though I have an eight year old Audi A6 tdi but fueled with HVO100, a chemical copy of fossile diesel, made from vegetable oils etc, reducing the emission of carbon oxide and particles close to 90% making my car a real environmental friendly car :four_leaf_clover:)

My neighbour has two Tesla car's and solar power plant on his roof of the house. In beginning he also had the idea of charging the cars mainly with solar generated power. After a while he realized it was a better economi for them to sell the solar energi and instead charge the cars during night when the electricity is much cheaper here i Sweden. Maybe is not the same situation in Switzerland?

PS: Re-thinking a bit, if you would charge your car mainly from the supplier, it might be the electricity comes from one of your nuclear power plants and that might be red stop light for you :wink:

In some countries the energy companies are forced to buy from private PV providers at a very high price as a form of subsidy. This holds certainly for Germany and if I read your text correctly this seems to be the case in Sweden too. This is not the case for Switzerland. I'm better off using my produced energy myself instead of selling it off. This is why I try to optimise the charging.

1 Like

OK - no guarantees this would work - but it is worth checking out

On here last week was a thread about someone wanting to control the logic for resistive loads to enable efficient us of available solar.

In it he linked to a device which is essentially a Zero Point crossing variable output relay.

He had printed a very nice 3d enclosure for it to enable turning up.down the amount of current it would put out to a resistive load.

Not sure what a car would do with that if you said i only have 5 amps available rather than 10 - without using the standard communications method.

On the Openenergy forum i thought that had a project for a home built EV charger that enabled a variable load to be provided to the car ?

Craig

You might want to check how environmentally friendly that BioDiesel actually is.

The main method of making BioDiesel (i used to do it) it to use a Caustic (usualy KOH) which is potassium and Methanol - methanol only comes from one source - Petrochecmical !!

yes you do use a lot less - typiially in the 20% range depending on the quality of the feedstock Oil.

Craig

HVO100 is not BioDiesel. It has been tested by independent researchers and the effects have been verified. Up to 90% less emission of Carbon Oxide and particles compared with fossil petro based diesel

VOLVO Cars have, after a long trial period with cab fleets, as one of several car manufacturers approved it for usage in their diesel engine cars (it actually works fine in older cars but you loose warranty if the manufacturer has not officially approved it. For older cars there is no warranty left anyway)

Article in Swedish but I think Google might help in translation

Umm - HVO100 is BioDiesel and is made exactly the same way.

The difference is that they are trying to get away from the bad name Biodiesel had the first time around with deforestation and planting crops (Rapeseed/Canola) purely to make it.

What they have tried to do this time is used waste oil - which is a fantastic use (and how all home made guys used to do it.

Instead of the esterification process they use a Hydrogen based process - i have not read through the whole thing in terms of ratios yet - but suffice to say it is not Green Hydrogen they are using - but rather Hydrogen produced by Fossil Fuels (usually Methane cracking)

Here is a good description from an indepedent site (admittedly back in 2014 - but reading the manufacturers website the process appears to be the same still.

http://www.greenea.com/publication/is-hvo-the-holy-grail-of-the-world-biodiesel-market/

Craig

The whole project got more complex than initially thought.
It is still work in (slow) progress, but here is an update anyhow.

The node-red charge control needs to be manually enabled. I did not find an easy and energy friendly way to figure out if the car is parked by the house and plugged in, because in all other scenarios the node-red charge control should not intervene.

Here is the current dashboard. On the left side I can set the charge limit for the battery. In the middle column I set the charge strategy and enable/disable the node-red based charge control.
If it is enabled, then the right column fills up with status information about the charge progress.

And here are two images of the nodes and the wiring. The first contains the nodes to draw the dashboard. The second one contains the long logic chain for the charging.

1 Like

Urs, a "PV aware and activated" EV-Wallbox can fully take care of PV charging.
Activate it in PV only charge-mode and define a headroom (upper limit of allowed non-PV consumption for a certain time window - i.e 900W for 120sec before charging will be discontinued until PV Power comes back) while charging.

I use an openWB (www.openwb.de) wallbox for this. It enables even capabilities for dynamic 1P/3P charging and several charging modes, including using some dynamic tariffs. Its software is open source and fully mqtt enabled.
I integrate to it via Node-red for monitoring and remote control, but not dynamic PV charging...as this feature is already mature inside the box.

Here's a charging curve for both my EVs from last Wednesday.

...and here a graph from May:

...out of 178.42kWh totally delivered to my EVs, non-PV energy was just 2.79kWh
June was even below 1kWh non PV, out of 152kWh totally charged.

BTW: currently, here in Germany, you will receive government funding of up to 900EUR, when setting up an EV-Wallbox which almost enables you to install it without additional costs. maybe there is a scheme in Switzerland as well (openwb is only GSA market, no english UI available).

Thanks for sharing your solution.
Since buying a more capable wallbox is on hold here, I will struggle forward with my node-red based approach.
And no, in Switzerland there is no funding for a wallbox.

(In my view VW did a really great job for its shareholders. Use the old factories which produce the old cars as long as possible. Let all others build electric charging infrastructure first. At the very latest moment come up with a more or less acceptable line of electric cars, let the tax payers pay via government subsidies their electric cars an wallboxes. Very cleverly maximised shareholder value. But this is definitely off-topic for a node-red forum.)

Yes they have tried to be smart but all of the traditional manufacturers are going to have problems competing with Tesla on price - hence they have all tried to come up with some standard platforms/chassis that they can use across their product lines (and even share amongst manufacturers).

The thing none of them seem to have come up with yet is how their dealer networks are going to survive, once the ratio of electric cars increases compared to ICE - their dealerships are going to lose their major source of revenue through servicing. I am yet to see any of the manufacturers come up with a plan how they intend to handle this.

Craig

I forgot the WAF factor.
Since there were no cables, I thought I'm on the safe side. This is not the case.
I have to admit that I did not check first with my wife, but started enthusiastically to program in node-red and with the dashboard. I got totally lost connecting blocks with wires and watching the messages moving through the flows. But this project is connected with the real world, with people, a car, the weather, etc.
Instead of thinking in node-red flows and dashboard buttons, I need to think in use cases.

The basic use case is this:

  1. we come home with our car and plug it in
  2. we have something in mind about when we will need the car again and what charge level it should have to feel safe
  3. we want this to be cost optimised and we want a direct feedback about what this means

We solved this in the pre-node-red-aera by looking at the sky, checking the Tesla screen on how long the car thinks it needs to charge, and then decide, if we plug it in or not and wait for the sun to come out.

To solve the above use case with node-red (and without a mobile phone (WAF!)) I need a hardware box with buttons and screen near the charging plug. Luckily I have an ESP32 with OLED in my toy box, and ordered a rotary encoder with push button. I plan to use this as the control device, instead of a node-red dashboard.
The default for this box is to be disabled, which means the charge control is manual as before.
If the box is enabled, then it will show the estimated charging times for the three cases: charge with solar power only, charge with solar power and at low tarif times, charge immediately. Then with the rotary encoder you choose the charging strategy.
The box will basically replace the dashboard.
This will take some time, stay tuned.

So here I am with an ESP32 (WEMOS OLED32) and a rotary encoder on a breadboard. I'm more or less happy with the code and the thinking behind it. As you might see, there is no way I get this through customer acceptance test (WAF = 0). Even with a nice case there is still the problem with the very small screen. And then there is the open question with the power supply.