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

Automated back up mode with python and rest

This site may earn commission on affiliate links.
It's pretty well established that Tesla won't configure the PWs to charge from the grid in the US and gives customers no way to force this (API or otherwise), and most utilities won't approve it to be used this way. A couple people on these forums seem pretty confident they can convice Tesla to configure their PWs/Gateway to charge from the grid, but I haven't seen anybody post in regard to "actually" having accomplished this in the US.

Also, in terms of stormwatch, Tesla totally controls when your system will go into stormwatch mode and in turn then when it could charge from the grid on a very limited basis. You can only choose to allow that to happen (On) or not to happen (off) should Tesla trigger a stormwatch condition for your area, which are pretty rare - i.e. only during severe conditions where power his likely to be lost due to major weather situations or other disaster scenarios.

I believe Tesla is forced to limit and totally control grid charging like this in the US due to agreements with regulators and utilities that were required for Tesla to actually be allowed to move forward with installing Powerwalls at scale, and to maintain various required product licenses and certifications that are required to sell PWs in the US for grid connected systems. Even if a given utility says they support grid charging, Tesla may not be able to allow that due to product certification requirements (just a guess here) that limit what has those products operate on the grid in the US. Clearly Tesla otherwise supports charging from the grid because it's possible in other countries.

some people in Arizona do not have solar but have Powerwalls. So the general idea of charge from grid is possible . It’s when you have solar and I think that is more or less tied to tax credit . The tax credit will go away eventually . Then Tesla might revise their firmware for solar units .
 
could you provide some info on how this script works? Does it just toggle modes back and forth every time you call it?

I'm looking to either change to backup mode at a certain time and then back to self consumption at a later time, or adjust the reserve in self consumption up and down to control when PW stops discharging.
 
  • Like
Reactions: niveknow
could you provide some info on how this script works? Does it just toggle modes back and forth every time you call it?

I'm looking to either change to backup mode at a certain time and then back to self consumption at a later time, or adjust the reserve in self consumption up and down to control when PW stops discharging.

Yeah my latest scripts are located here :
Newest powerwall code – Solar Coder

One is called powerwallBackup.py and one is called powerwallTimeofuse.py the back up oke sets the reserve level at 100% and 0percent. You would use some type of task schedule or cron to call the python scripts by issuing command
Python name of script.py

and I would recommend trying them manually. Each script has parameters you must modify like your own energy gateway ip, email account , and installer password.

Cheers
 
You would be proud of me Darwin I used windows scripting and python turn on and off back up mode :) now I can control when full solar charges battery . In need to do a larger write up but here is code and pics : I do think I have to many schedules define since shoulders Define off peak.

Python :
I found a python API as well. This actually worked a lot better, just made few tweaks on the username / password. etc, and then added these as schedule tasks in windows machine to run at 9am and 9pm.

Python :
I found a python API as well. This actually worked a lot better, just made few tweaks on the username / password. etc, and then added these as schedule tasks in windows machine to run at 9am and 9pm.

piersdd/tesla-powerwall-json-py

Then my fork :
My mods are located here:
CodePile | Easily Share Piles of Code

did you know you could use teg controller and make rest calls to it game changing ::
vloschiavo/powerwall2


We started a video channel on strategies and tips with powerwall and Tesla Energy gateway :)
Please subscribe , like and leave comments!
Gilbert Solar
 
You can make it charge from the grid by changing it's settings, I tried it and it works, but it's by no means a clean answer. Put your powerwall into backup mode, then go into the configuration wizard, delete the solar array, and switch the solar solar CT's to "Site" or "None". Voila, it'll charge to 100% from the grid since it thinks it's a non-solar.

I have been researching this question about forcing the powerwall to charge from the grid when you have a solar system connected, and you are the first person I've seen indicate that it is doable without much technical expertise.

My primary interest is in understanding how things would work if a hurricane comes through, you have an extended power outage, and you want to use more electricity than your solar is generating during the day. So the idea would be to have the option of connecting a generator to charge the batteries at some point during the night as needed (ideally on demand, if the generator can auto-start). If the system won't charge from the grid then I understand that to mean you cannot charge from a generator either. Would your method solve that problem?

I understand that storm alert mode is the one exception, but I don't know how long they will leave that active after the storm has passed...
 
  • Like
Reactions: niveknow
Okay we have updated the code to now use the cloud API because Tesla badly locked down the local interface:: in version 1.50.1


Happy to report we migrated our code to cloud automation from local and you can download the newest code here, just change lines 33-35 to your credential for Tesla and let it rip, use at your own risk!
Newest powerwall code – Solar Coder (this code can help you schedule your powerwall if you have double peaks like we do on the SRP powerplan from 5am-9am and 5pm-9pm which as a reminder for Arizona SRP start November 1st)
 
  • Like
Reactions: niveknow
Okay we have updated the code to now use the cloud API because Tesla badly locked down the local interface:: in version 1.50.1


Happy to report we migrated our code to cloud automation from local and you can download the newest code here, just change lines 33-35 to your credential for Tesla and let it rip, use at your own risk!
Newest powerwall code – Solar Coder (this code can help you schedule your powerwall if you have double peaks like we do on the SRP powerplan from 5am-9am and 5pm-9pm which as a reminder for Arizona SRP start November 1st)

Awesome @blueice89 ! Does this still work? Your link has a date of Jan 4 2020 for the code. I'm looking for an automation to trigger the PW charge and you seem to have it working at some point. Thanks!