Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

Charging from Excess Solar with Teslapy

This site may earn commission on affiliate links.
I finally got around to playing with some Python code and the Teslapy module to use the excess solar to charge my car. My daughter (11 yo) helped out over the school holidays to get her more involved in programming. We started off by using ChatGPT to generate sample code for extracting the data from my Fronius inverter and then we borrowed bits of code from the Teslapy documentation, TesSense by @israndy and Suncatcher by @Haselsmasher.

Today was a good test of the code as there was intermittent cloud cover. I check for the solar, house power draw and export data every 60 seconds, changing the amps accordingly. If I have to stop charging then I wait 5 minutes before evaluating whether to charge again or not. There is also some buffer to allow for 1,500 W, but I'm going to increase the to 2,000 W to see if that helps with some grid usage creeping in. Ultimately the clouds are annoying! I saw 13 kW drop to 3kW as clouds pass over.

Anyway, here is the output from today. The grey is solar production, blue line is house consumption and yellow is solar consumption.

1681889080355.png


The bump from 6 am is the heat pump coming on for the hot water. Then I started charging the car after 9 am and finished before 1 pm. The block of usage that drops off after 3 pm is the pool pump. The solar system is 15 kW and I have 3 phase.

I'll clean up the code (my first Python program) and post it to Github for others to look at over the weekend.
 
The other part of "excess solar", though, is finding out when my PowerWalls are nearly full. Is there a branch of this solution that can request SoC status info from the PowerWalls to help me decide when to charge the car? The car and PowerWalls are all in my garage within BLE range of each other, and perhaps even the Gateway if that's where the info is hosted.

Yep… you can directly interrogate the PW2 Gateway without going via the Tesla API.

You need to find the IP address of your Gateway on your local network (often something like 192.168.0.xxx or 10.0.1.xxx) - the admin page of your home internet Router should reveal it as one of the connected devices (TEG - Tesla Energy Gateway). I’ve set mine to have a fixed IP address so that it can always be interrogated.

The device you are using to interrogate the Gateway must be connected to the same network as the Gateway e.g. WiFi or Ethernet to the same modem your Gateway is connected to. You will be asked to enter your Tesla account email address and the password is the last 5 characters (numbers & letters) of the serial number of your Gateway (at least on mine it is).

After authenticating, to get the current state of charge, you need to fetch this URL using your favourite coding language:

https://192.168.0.xxx/api/system_status/soe

This will return a JSON object containing the SOE:

{"percentage":100}

An unofficial document explaining the PW2 Gateway API and all its commands is below. But beware - if you don’t know what you’re doing you could easily mess up your PW2 settings, shut it down, or take it offline.

 
Same idea for us, we went electric mower many many years ago now 😉

We have gone low to no meat consumption and embarked on minimalism on our purchases (waste bin goes out once a month and generally 75% empty) etc.

Once the changes are made and habit kicks in it’s really not hard “to do”.

Next up will be 3 times water re-use (if the Stonnington Council will let me!)
Is the electric mower any good? I tried a ryobi battery powered one that would constantly bog down when the grass was longer or slightly wet. Eventually just got a petrol mower so that I could power through and get the job done and not look like an idiot in front of the neighbours.
 
Is the electric mower any good? I tried a ryobi battery powered one that would constantly bog down when the grass was longer or slightly wet. Eventually just got a petrol mower so that I could power through and get the job done and not look like an idiot in front of the neighbours.
I have a Milwaukee, due to being well invested in their battery ecosystem. IMO it's awesome.
 
  • Like
Reactions: Way69
The EGO electric mowers are supposed to be the business.
My Ego mower is approaching 10 years old and is still going strong. The battery died under warranty but was replaced by a slightly higher capacity one by the manufacturer.
I have some areas of the garden that are constantly wet and it gets through them okay if I’m careful, but you can bog it if you rush straight in and don’t give the mower some time in the dry areas around it. However the previous Honda petrol mower struggled with that section too.
Overall I’m very happy with it, the only cons are I wish it had a metal deck as I have a couple of small holes and the clips for the handle extension mechanism can come loose and stop the mower and require re-clipping into place.
Newer models are self propelled too And it would have been nice to have that feature on my sloping block.
Returning to topic, the energy for my mowing is always from solar, which is a good feeling.
 
The EGO electric mowers are supposed to be the business.
I have just changed from an 18V Ryobi to a 56V EGo mower. The difference is incredible. I bought one with the steel deck for durability.

Yesterday I cut 3“ high wet buffalo grass and it went through it like a hot knife though soft butter. More than half a battery charge left. The old mower would have given up as soon as it hit the first bit of grass.
 
  • Like
Reactions: Vostok
I guess he's sequestering that fossil carbon.

(It only becomes a fuel if he burns his lawn!)
I honestly wonder how that works.. how much of the dug up oil used to produce the plastic, ends up in the plastic.. and then does it get released as it degrades in the sun? like a log?

Should i be storing my 3d print waste in archive like conditions to stop it re-releasing it's carbon?
 
Looks like new cars being delivered already have no access to the old undocumented APIs, with it being removed for all cars by January 2024.
Charge HQ have a timeline on their website -

Tesla have announced that the old API will stop working on vehicles as follows:

  • November 2023 -newly delivered vehicles will only support the new API
  • Nov - Dec 2023 - the old API will stop working on existing vehicles that have not used the old API in the preceding 30 days
  • January 2024 - the old API will stop working on all vehicles
How will the new official third party Tesla API impact Charge HQ?

Still no mention of pricing on the Tesla website yet - Tesla Fleet API
 
  • Informative
Reactions: Vostok
Looks like new cars being delivered already have no access to the old undocumented APIs, with it being removed for all cars by January 2024.

Ah well, looks like I’ll have a new holiday project to do. Assuming Telsa offer a hobbyist tier or similar for their new API 🤞

I have a few Cron jobs running on my server that use the Tesla Owner API:
  • Smart vehicle charging using excess solar
  • Smart PW2 charging to arbitrage grid rates
  • PW2 logger to track capacity degradation over time
 
Ah well, looks like I’ll have a new holiday project to do. Assuming Telsa offer a hobbyist tier or similar for their new API 🤞

I have a few Cron jobs running on my server that use the Tesla Owner API:
  • Smart vehicle charging using excess solar
  • Smart PW2 charging to arbitrage grid rates
  • PW2 logger to track capacity degradation over time
For a local solution use BLE with the patch from a few posts ago. No need for Tesla cloud/fleet API at all. And also no potential for API rate limiting.

$ tesla-control -ble lock
$ tesla-control -ble unlock
$ tesla-control -ble climate-on
$ tesla-control -ble sentry-mode on
$ tesla-control -ble sentry-mode off
$ tesla-control -ble steering-wheel-heater on
$ tesla-control -ble charging-set-limit 80
$ tesla-control -ble charging-set-limit 90
$ tesla-control -ble charging-start
$ tesla-control -ble charging-set-amps 10
$ tesla-control -ble charging-set-amps 11
$ tesla-control -ble charging-set-amps 5
$ tesla-control -ble charging-set-amps 6
$ tesla-control -ble charging-stop

[Edit: 'charging-set-amps' is now in master, no need to apply patch, just git clone and go]
 
Last edited:
  • Like
Reactions: OzVic
If they end up allowing us to create apps that run in the car, we can definitely pull our solar creation and turn on and off the Tesla charging in response to it right in the car. Otherwise, a little car computer could talk to the car and talk to the home Wi-Fi from the car.
 
For a local solution use BLE with the patch from a few posts ago. No need for Tesla cloud/fleet API at all. And also no potential for API rate limiting.

OK, but that sounds like more work since it requires BLE hardware. I’ll just update my Python scripts hoping that Fleet API will have a hobbyist tier. API rate limiting is something I’ll never threaten so it’s not a concern.

Also I download my 5-minute PW2 data on a regular basis. That is possible only through the Owner API. That data is not accessible through the Gateway. I plan to, but not yet have, set up a script to download the Model 3 charging data as well. Again, only available through the Owner API.
 
It's a shame you can't just control via the wifi - any time my car is charging at home it's on my wifi.. - or via the tesla charger..

When your car is on WiFi the API works through the WiFi 🤔. I think what you mean is you’d like the vehicle to have its own local API accessible by devices connected to the same local network subnet, like the PW2 Gateway has.

I did portscan my Model 3 once and there aren’t any open ports.