Open oldironUK opened 3 years ago
So I mostly use time based cost savings mode I just use the scripts to change the reserve percent .
There is an Api to change the mode but i never coded it cause I was able to just use time based cost savings mode and then in my Tesla app I define a very long peak 5am-9pm and that worked okay for us .
On Sun, Feb 7, 2021 at 5:22 PM oldironUK notifications@github.com wrote:
Firstly - thank you so much for taking the time and effort to publish this work. I think it's stunning that you managed to code the new Tesla oa3 in such a short time.
For the benefit of other users even though I am a complete beginner (never set eyes on Python code before this!) - I got a successful result within about half-an-hour of downloading. (I did have to add file 'accounts.txt' with contents: user@email.com:password ) Note I have not enabled mfa on my account.
('Setting Operation for Site Id: ', xxxxxxx) ('Trying URL: ', ' https://owner-api.teslamotors.com/api/1/energy_sites/xxxxxx/backup') Setting mode: {"backup_reserve_percent": 0.0} ('Set result output: ', '{"response":{"code":201,"message":"Updated"}}')
And of course the Tesla app showed the result on the 'Customize' page!!
I think that I am misunderstanding how the code is intended to work.
I thought that the mode of operation would change: that is powerwallBackup.py would alter mode to 'Backup-only' with reserve 100% that is powerwallTimeOfUse.py would alter mode to 'Time-based control' with reserve 0% but it doesn't.
If the battery is running in self powered mode then it stays in that mode and the "Reserve for Power Outages" changes as above. I expect this is your intention and I just misunderstood.
Would it be an easy modification to allow change of mode ie - self-powered to TOU and TOU to self-powered - the code seems to reference such an action?
The reason I'm asking is that I get much faster charging rate in TOU mode and therefore can achieve a full recharge in my low cost time slot.
Thanks again for the work and regards from the UK
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fkhera/powerwallCloud/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABU4JYEGWMCJ3ROOB6SJLQTS54VFRANCNFSM4XIATITA .
Okay so yeah it looks like its a different API you would have to write up: It appears its under energy_sites/{}/operation , as opposed to backup So if you can write a handler for that as I wrote the other handlers, you should be able to call it with the "mode" https://community.home-assistant.io/t/add-support-for-tesla-powerwall/142280/35
Possible mode values:
OperationModes = {SELF_CONSUMPTION: "self_consumption", TIME_OF_USE: "autonomous", BACKUP: "backup", AGGREGATION: "scheduler"}
operation_url = tesla_base_url + '/api/1/energy_sites/{}/operation'.format(energy_site_id) headers = { 'Content-type': 'application/json', 'Authorization': 'Bearer '
On Sun, Feb 7, 2021 at 9:21 PM Farooq Khera fkhera@asu.edu wrote:
So I mostly use time based cost savings mode I just use the scripts to change the reserve percent .
There is an Api to change the mode but i never coded it cause I was able to just use time based cost savings mode and then in my Tesla app I define a very long peak 5am-9pm and that worked okay for us .
On Sun, Feb 7, 2021 at 5:22 PM oldironUK notifications@github.com wrote:
Firstly - thank you so much for taking the time and effort to publish this work. I think it's stunning that you managed to code the new Tesla oa3 in such a short time.
For the benefit of other users even though I am a complete beginner (never set eyes on Python code before this!) - I got a successful result within about half-an-hour of downloading. (I did have to add file 'accounts.txt' with contents: user@email.com:password ) Note I have not enabled mfa on my account.
('Setting Operation for Site Id: ', xxxxxxx) ('Trying URL: ', ' https://owner-api.teslamotors.com/api/1/energy_sites/xxxxxx/backup') Setting mode: {"backup_reserve_percent": 0.0} ('Set result output: ', '{"response":{"code":201,"message":"Updated"}}')
And of course the Tesla app showed the result on the 'Customize' page!!
I think that I am misunderstanding how the code is intended to work.
I thought that the mode of operation would change: that is powerwallBackup.py would alter mode to 'Backup-only' with reserve 100% that is powerwallTimeOfUse.py would alter mode to 'Time-based control' with reserve 0% but it doesn't.
If the battery is running in self powered mode then it stays in that mode and the "Reserve for Power Outages" changes as above. I expect this is your intention and I just misunderstood.
Would it be an easy modification to allow change of mode ie - self-powered to TOU and TOU to self-powered - the code seems to reference such an action?
The reason I'm asking is that I get much faster charging rate in TOU mode and therefore can achieve a full recharge in my low cost time slot.
Thanks again for the work and regards from the UK
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fkhera/powerwallCloud/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABU4JYEGWMCJ3ROOB6SJLQTS54VFRANCNFSM4XIATITA .
Thanks for the replies above - I've been running your code as is. I think you are correct if that you don't really need to change modes. Just running TOU during the winter months and self-powered mode during the summer seems to be a good solution.
Just as a heads up - the code stopped running last night - I tried 2 different raspberry pi's both had previously run the code successfully. I get ValueError("No JSON object could be decoded") - so it looks like the url request is bombing out. Have you seen the same? I'm wondering if Tesla has changed something again?
People say to set the headers empty tesla changed something
On Sat, Feb 20, 2021 at 5:32 PM oldironUK notifications@github.com wrote:
Thanks for the replies above - I've been running your code as is. I think you are correct if that you don't really need to change modes. Just running TOU during the winter months and self-powered mode during the summer seems to be a good solution.
Just as a heads up - the code stopped running last night - I tried 2 different raspberry pi's both had previously run the code successfully. I get ValueError("No JSON object could be decoded") - so it looks like the url request is bombing out. Have you seen the same? I'm wondering if Tesla has changed something again?
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/fkhera/powerwallCloud/issues/3#issuecomment-782771475, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABU4JYD5AF4HNTEYBSN2OVDTABIA3ANCNFSM4XIATITA .
What version of your powerwalls are you on? I recently got 20.49.0. I don't run this code but wanted to ask in case that may be the issue
Brilliant - just - brilliant - removed the headers as you suggested and all working again (my PW version is 20.49.0 tested 21Feb21 - Tesla must have changed something a few days ago without changing the PW version rev)
The fix for anyone else looking - this code at line 136 works for me:
auth_url = self.authUrl();
headers = {}
resp = session.get(auth_url, headers=headers)
Thanks again for your help
UPDATE:
Just checked - code is running again: UK time 23:00
Tesla must have fixed something
Thanks again
================================================================ I've been running twice a night since February - has worked every time - so thanks again.
However I think Tesla changed something last night. I ran successfully at 00:30 (UK time) but failed at 04:30. Interestingly the Powerwall took about an hour to react to the 00:30 request. I wonder if the Tesla servers were off line around that time. (my PW version is 20.49.0)
Looks like a header problem??:
Anyone else seen a failed response
Thanks in advance
Error messages:
authenticating authenticate method getting url https://auth.tesla.com/oauth2/v3/authorize?code_challenge=47wxxx_hidden_xxxxxxxxJi-AE8LKUg8hsNmA&client_id=ownerapi&state=tesla_exporter&redirect_uri=https%3A%2F%2Fauth.tesla.com%2Fvoid%2Fcallback&response_type=code&code_challenge_method=S256&scope=openid+email+offline_access Traceback (most recent call last): File "/home/pi/powerwallTimeOfUse.py", line 144, in authenticate csrf = re.search(r'name="_csrf".+value="([^"]+)"', resp.text).group(1) AttributeError: 'NoneType' object has no attribute 'group' Traceback (most recent call last): File "/home/pi/powerwallTimeOfUse.py", line 67, in main tpw.productlist() File "/home/pi/powerwallTimeOfUse.py", line 363, in productlist result = json.loads(result.text) File "/usr/lib/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded
Same story as above!! I've been running twice a night since May - has worked every time - so thanks again.
However Tesla changed something last night. I ran successfully at 00:30 (UK time) but failed at 04:30. (my PW version is 21.20.2)
I've been successfully running your old code prior to the introduction of recaptcha modules.
Anyone else seen a failed response??
Looks like location is missing/changed: code_url = resp.headers["location"] KeyError: 'location'
Any comments
You may need to use captcha but tesla did this a couple months ago then disabled captcha. I added newer code in May to process captcha but the captchasolver.py needs flag set to true and api key.
On Thu, Jul 8, 2021 at 2:54 AM oldironUK @.***> wrote:
Same story as above!! I've been running twice a night since May - has worked every time - so thanks again.
However Tesla changed something last night. I ran successfully at 00:30 (UK time) but failed at 04:30. (my PW version is 21.20.2)
I've been successfully running your old code prior to the introduction of recaptcha modules.
Anyone else seen a failed response??
Looks like location is missing/changed: code_url = resp.headers["location"] KeyError: 'location'
Any comments
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/fkhera/powerwallCloud/issues/3*issuecomment-876301466__;Iw!!IKRxdwAv5BmarQ!LMjAvWKxOv7o9nZba-Qt52FoBo3pyP7_LuOKfJ9GTxK2r8v0-TbAbLLlcV5JfQ$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABU4JYHSKSTD2MDDQ2JP4IDTWVYVXANCNFSM4XIATITA__;!!IKRxdwAv5BmarQ!LMjAvWKxOv7o9nZba-Qt52FoBo3pyP7_LuOKfJ9GTxK2r8v0-TbAbLLgiOpZmw$ .
Thanks for the reply I'll take a look at the captcha module, although I might wait 24hrs to see if the current code magically starts working - Tesla seem to have a habit of performing an update and breaking something unrelated!!
Regards
Let me know if you get it working .
On Thu, Jul 8, 2021 at 8:31 AM oldironUK @.***> wrote:
Thanks for the reply I'll take a look at the captcha module, although I might wait 24hrs to see if the current code magically starts working - Tesla seem to have a habit of performing an update and breaking something unrelated!!
Regards
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/fkhera/powerwallCloud/issues/3*issuecomment-876536622__;Iw!!IKRxdwAv5BmarQ!LNsZzNM-rW_SSjER9Wa5Z1bXdcY9Ron1ohtP8DQiIo_sdd4wAFiZZW-GTegzbQ$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABU4JYH2H6RQTMEG52EHDG3TWXADLANCNFSM4XIATITA__;!!IKRxdwAv5BmarQ!LNsZzNM-rW_SSjER9Wa5Z1bXdcY9Ron1ohtP8DQiIo_sdd4wAFiZZW--lXbcOw$ .
I added a new issue that seems to be similar to this, but not exactly the same results:
https://github.com/fkhera/powerwallCloud/issues/5#issue-941268304 My Powerwall 2 version is still 20.49.0 and I have no idea how to force an update, or even if it's possible to do that.
In any case, I doubt the firmware has anything to do with this. Must be something to do with the API in the site.
My Powerwall has been downgraded from 21.20.2 back to 20.49.0 but I still get the error I listed above. So I'm still hoping that Tesla is fixing something in the background!
Firstly - thank you so much for taking the time and effort to publish this work. I think it's stunning that you managed to code the new Tesla oa3 in such a short time.
For the benefit of other users even though I am a complete beginner (never set eyes on Python code before this!) - I got a successful result within about half-an-hour of downloading.
(I did have to add file 'accounts.txt' with contents: user@email.com:password ) Note I have not enabled mfa on my account.
('Setting Operation for Site Id: ', xxxxxxx) ('Trying URL: ', 'https://owner-api.teslamotors.com/api/1/energy_sites/xxxxxx/backup') Setting mode: {"backup_reserve_percent": 0.0} ('Set result output: ', '{"response":{"code":201,"message":"Updated"}}')
And of course the Tesla app showed the result on the 'Customize' page!!
I think that I am misunderstanding how the code is intended to work.
I thought that the mode of operation would change: that is powerwallBackup.py would alter mode to 'Backup-only' with reserve 100% that is powerwallTimeOfUse.py would alter mode to 'Time-based control' with reserve 0% but it doesn't.
If the battery is running in self powered mode then it stays in that mode and the "Reserve for Power Outages" changes as above. I expect this is your intention and I just misunderstood.
Would it be an easy modification to allow change of mode ie - self-powered to TOU and TOU to self-powered - the code seems to reference such an action?
The reason I'm asking is that I get much faster charging rate in TOU mode and therefore can achieve a full recharge in my low cost time slot.
Thanks again for the work and regards from the UK