Closed Stephen2615 closed 5 months ago
I just made sure that the tesla info is recent as I had to enter my password to get the token so it wasn't using any cached version.
Hi @Stephen2615 can you check to see what version of TeslaPy you have? You will need 2.8.0
.
import teslapy
print(teslapy.__version__)
Hi @jasonacox TeslaPy is at 2.8.0.
Thanks! I found the bug. I'll submit the fix.
I was testing on a dashboard rig which must have had an older cached version of TeslaPy. At some point they dropped support for the .get_site_info() function in favor of the .api() function. Pull the latest and let me know if this fixes it for you too.
wget https://raw.githubusercontent.com/jasonacox/pypowerwall/main/tools/set-reserve.py
Hi @jasonacox, Thanks for your help. I used the set-reserve.py you offered and it didn't fix it. The error is the same.
Try running this script (or run interactively with python3):
import teslapy
# Set variables
TAUTH="set-reserve.auth"
email="your.email@example.com" # replace with your real email you use with Tesla
retry = teslapy.Retry(total=2, status_forcelist=(500, 502, 503, 504), backoff_factor=10)
tesla = teslapy.Tesla(email, retry=retry, cache_file=TAUTH)
# Get site info
battery=tesla.battery_list()[0]
config = battery.api("SITE_CONFIG")["response"]
site = battery.api("SITE_SUMMARY")["response"]
data = {**config, **site}
level = data["backup_reserve_percent"]
pw_count = data["battery_count"]
print(f"READ: Current Battery Reserve Setting: {level}% for {pw_count} Powerwalls")
Hi @jasonacox
It works.
READ: Current Battery Reserve Setting: 25% for 1 Powerwalls
Cheers
Stephen
That's great! That's basically what is in set-reserve.py
so I suspect you have a cached older version. In any case, you can use that one. :)
Updated to 0.8.1 and everything is working nicely. Thanks to all.
Thanks @Stephen2615 ! 🙏
@jasonacox.
A bit off topic but how does the cron.sh work? When I use cron, it runs at specific times but yours doesn't give an example. Eg, every 10 minutes of every hour? I haven't used it as we get a lot of fog here in Winter and "clouds" doesn't really give an indication of fog. I was trying to figure out some way of saying yes, we have fog. The Tesla algorithm won't charge the battery when it is foggy here as it doesn't recognise fog equals clouds. I don't want to force the battery to charge if it doesn't need it but its almost mandatory with fog.
Cheers
Stephen
Interesting use case! I run the cron.sh every 5 minutes using this crontab entry:
*/5 * * * * /home/tesla/cron/cron-powerwall.sh > /dev/null 2>&1
You can edit your crontab with crontab -e
.
@jasonacox
The vagaries of Bash has struck. Us plebs in the Southern Hemisphere means that we can't use the test in cron.sh: if (( "${MONTH}" == "06" )) || (( "${MONTH}" == "07")) || (( "${MONTH}" == "08" )); then
as "08" isn't read properly. ((: 04 == 08: value too great for base (error token is "08")
I had to change it to Jun or Jul or Aug with the MONTH being MONTH=date +%b
if (( "${MONTH}" == "Jun" )) || (( "${MONTH}" == "Jul")) || (( "${MONTH}" == "Aug" )); then
Crazy eh?
Cheers
Stephen
Great fix @Stephen2615 ! I actually like your approach better in general. It is more readable. I don't know why I went with numerics.
@jasonacox Many years ago, I once did a IT contract and found someone had wrote a 25k line shell script to do scheduling. The only comment was the second line where he had his name. It wasn't working and someone told me to fix it. I think I quit at that stage.
Greetings,
Version v0.7.7 Tesla Firmware 23.44.0
I just installed the latest version and I have the right set-reserve.auth and set-reserve.conf. However, when I tried to run the following command, it produces this:
python3 set-reserve.py --read Traceback (most recent call last): File "/home/pi/pypowerwall/tools/set-reserve.py", line 313, in
data = get_level()
File "/home/pi/pypowerwall/tools/set-reserve.py", line 264, in get_level
data = battery.get_site_info()
AttributeError: 'Battery' object has no attribute 'get_site_info'
I can get info out of the battery by using the example.py so it seems the local account is good. This used to work with an older version but I haven't tried recently.
Thanks
Stephen