Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No longer able to set Powerwall to self_consumption mode #136

Open
HeraldCoupe opened this issue Jul 31, 2023 · 6 comments
Open

No longer able to set Powerwall to self_consumption mode #136

HeraldCoupe opened this issue Jul 31, 2023 · 6 comments

Comments

@HeraldCoupe
Copy link

I am no longer able to set the Powerwall to 'self_consumption' mode. I'm still able to set it to 'autonomous' mode.
I'm guessing something has changed at Tesla's end.

Anyone got any ideas?

@rob0101
Copy link

rob0101 commented Aug 17, 2023

I'm new to teslaPy and not fluent in python.

I've had no luck getting a simple script to toggle between the two states. I was able to change the minimum reserve, so it may be I'm hitting a similar issue to HeraldCoupe.

Can someone share a simple code sample that changes the state as a starting point.

Thanks

@rob0101
Copy link

rob0101 commented Aug 17, 2023

Got this working:

`
import sys
new_mode = sys.argv[1]
new_MRL = int(sys.argv[2])

import teslapy
from teslapy import Tesla, Battery
with teslapy.Tesla('[email protected]') as tesla:
batteries = tesla.battery_list()
batteries[0].command('BACKUP_RESERVE',backup_reserve_percent=new_MRL)
batteries[0].command('BATTERY_OPERATION_MODE',default_real_mode=new_mode)
`

but bizarrely it'll only set the mode if I also set the backup reserve. Remove that line and stop working.

@HeraldCoupe
Copy link
Author

Thank you Rob0101. From my limited testing it seems that in addition, the backup reserve also needs to be different to that currently set otherwise it doesn't change modes.

@DaveTBlake
Copy link

Interesting experiences guys, I've not been setting mode since last winter (switching to autonomous to get the faster charge rate over the cheap electricity supply period that I am tricking the Powerwall into charging from the grid by changing the reserve percentage). I always set both reserve percentage and mode so maybe I would not notice this issue.

I wonder if this is another aspect of the Tesla API randomly deprecating the powerwalls endpoints in favour of energy_sites. The endpoints I use are:

  "OPERATION_MODE": {
    "TYPE": "POST",
    "URI": "api/1/energy_sites/{site_id}/operation",
    "AUTH": true
  },
  "BACKUP_RESERVE": {
    "TYPE": "POST",
    "URI": "api/1/energy_sites/{site_id}/backup",
    "AUTH": true
  },

Note I'm using energy_sites for both, and first I get api/1/energy_sites/{site_id}/site_info ("SITE_CONFIG" in endpoints.json) using a routine I added to the battery class (which maybe populates the {site_id} ?) .

@rob0101 in your example you use a mix of energy_sites and powerwalls since

"BATTERY_BACKUP_RESERVE": {
    "TYPE": "POST",
    "URI": "api/1/powerwalls/{battery_id}/backup",
    "AUTH": true
  },

Maybe that is significant? Of course it could all change tomorrow. Hope this could be of use to either of you.

@tdorssers
Copy link
Owner

Commit 50bdbfb removed the depricated powerwall API. Please use the energy site API.

@rob0101
Copy link

rob0101 commented Oct 8, 2023

I've updated to the new teslapy code and my revised script (below) is working.

import sys
new_mode = ""
new_MRL = ""
if len(sys.argv)>1 : new_mode = sys.argv[1]
if len(sys.argv)>2 : new_MRL = int(sys.argv[2])

import teslapy
from teslapy import Tesla, Battery
with teslapy.Tesla('[email protected]') as tesla:
batteries = tesla.battery_list()
battery = batteries[0]
if new_MRL != '':
battery.set_backup_reserve_percent(new_MRL)
if new_mode != '':
battery.set_operation(new_mode)

battery.get_site_info()
print("Mode:" + battery["default_real_mode"])
print("Reserve:" + str(battery["backup_reserve_percent"]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants