-
Notifications
You must be signed in to change notification settings - Fork 25
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
POST /api/operation #20
Comments
Try to perform the request manually with |
Thanks for the feedback. Will try that though a sequence of curl commands to gain access and then perform a command isn't very helpful from a reproducibility point of view and it isn't clear how up-to-date the vloschiavos documentation is. Have you tried to change the powerwall charge state (i.e. to ask the powerwall to charge) using your library? I would have thought that it was the main thing that is useful to automate. |
Using Before the rewrite the feature was implemented but quite unstable as telsa often changed the API. As such I removed it from the library. But if you find a way to use this endpoint correctly, I would be happy readd this feature. |
Has there been any success with this as the code from mlowijs/tesla_api#43 seems to now have an problem. |
I would also really appreciate this feature! i had hoped i could use the solar predictions from solcast.com.au to allow me to estimate more accurately the likely solar power for the day and then adjust the backup% so i could force the powerwall to charge during cheap rate power from 12:30am to 4:30am to a level which would then avoid me having to touch the grid again during peak times. |
looks like there is a viable way to do it @jrester...
any chance of adding this to a future release? |
It's really hard to understand what the original poster is asking for here (perhaps it is an update to this repo), but here is the current status.
My code at https://github.com/BJReplay/PowerwallService/blob/master/PowerwallService/PowerwallService.vb#L825 and https://github.com/BJReplay/PowerwallService/blob/master/PowerwallService/PowerwallService.vb#L915 gives you a bit of an idea. It's VB.Net. Sorry. Not Sorry. I also use https://github.com/tomhollander/TeslaAuth but pull that in as source as I ran into a .Net versioning conflict that prevented me from pulling it in as a package. |
@omaliphant What you are referring to is the external Tesla API but this library uses the local API which works differently afik. @BJReplay I currently don't have access to a powerwall to test this. If you like to help out I would be happy to merge a PR implementing this functionality. Vloschiavo also has an example for this in his repo but I am unsure if this is up to date. Any help regarding this feature would be greatly appreciated! |
@jrester I have a Powerwall 2 and would be happy to test this functionality. This was a function that I had in my previous cloud implementation but it broke when Tesla change the oauth earlier this year. I'm using your current version for local access. |
Great! I will prototype an implementation for you to test. |
@jrester how are you going with the implementation? |
A test implementation is on the |
Getting an error when trying to do post_operation. Getting information from the API seems to be working just fine with the same login.
File "/opt/tesla_powerwall/tesla_powerwall/api.py", line 210, in post_operation |
It seems like you have to be logged in as installer to change the operation mode. |
@dailow @scienceintheshed could you try this when being logged in as installer? |
Unfortunately I have a PW+ and it needs physical access each time to get into installer mode so I couldn’t get it to work. |
Any updates on this? |
As long as you need physical access to switch to installer mode I don't believe this is realy usefull. |
Closing this. May be reopened if you don't need physical access anymore. |
A few updates here that might enable setting mode and backup reserve without physical access. Tesla is now promoting the Tesla Pros app on the gateway web login page. I was testing the app and noticed it has the ability to set operation mode and backup reserve. To log in, the app uses the TEG wifi network but does NOT require flipping the Powerwall switch. So as long as a Raspberry Pi is in range of the TEG wifi, setting the operation mode and reserve should be automatable. It would require reverse-engineering the new API calls however, since the Tesla Pros app uses a different |
I had to flip the switch to log in. Once I'd logged in, I could leave and re-enter the Powerwall in the app without flipping the switch again. However, if I Force Stopped the app, and started it again, I had to flip the switch to log in again. I have an older (V1) gateway, so it may differ depending on what version gateway you have whether or not you need flip the switch to log in, but I definitely did need to. |
@zigam that sounds interesting. If you can reverse engineer the protocol and you can confirm that the operation mode can be controlled this way, I would be happy to implement that feature in this library/accept a PR. @BJReplay interesting behavior and also something that must be considered and investigate more in depth, if we add that feature. |
@BJReplay interesting, I didn't need to flip the switch after restarting the app (this is on iOS and with GW2). The flow I used: kill and reopen the app (already logged in using my Tesla credentials), then: More importantly: looking at the Starting to unpack the API:
The last request will return the full configuration of the gateway, a large config.json file. Configuring reserve and mode seems to be modifying that json and posting it back (I'm not including details here yet, wanted to confirm first that this works for others too). Maybe others can test this with their own systems. Replacing the din in the |
@zigam Where do I sore the request.bin file to run the command? When I go to replace the din I see this: 9�������� How should I be edting the file? |
@ejbatts the updated process for |
It would be really useful if I could locally instruct my powerwall to change operating mode, e.g. to force the battery to charge by changing the backup_reserve_percent.
I've tried adding the following to powerwall.py (should use enumeration for opmode in the final version):
def set_operation_mode(self, opmode: str, pc: int):
return self._api.post_operation_mode({"mode": opmode, "backup_reserve_percent": str(pc)})
and to api.py:
def post_operation_mode(self, body: dict) -> dict:
return self.post("operation", body, needs_authentication=True)
But I get the response:
tesla_powerwall.error.AccessDeniedError: Access denied for resource /api/operation: Unable to POST to resource
Though it appears that vloschiavo has gotten this to work:
https://github.com/vloschiavo/powerwall2/blob/master/README.md#apioperation
Any ideal how to fix this?
The text was updated successfully, but these errors were encountered: