fkhera / powerwallCloud

30 stars 6 forks source link

Error running script #11

Open psmedley opened 2 years ago

psmedley commented 2 years ago

Hi,

I'm getting the following error running 'python powerwallDriver.py tou'

Opening session with login Coming to non MFA flow: Traceback (most recent call last): File "/home/psmedley/authtoken.py", line 227, in authenticate code_url = resp.headers["location"] File "/home/psmedley/.local/lib/python2.7/site-packages/requests/structures.py", line 54, in getitem return self._store[key.lower()][1] KeyError: 'location' Traceback (most recent call last): File "/home/psmedley/powerwallBackup.py", line 70, in main tpw.productlist() File "/home/psmedley/powerwallBackup.py", line 134, 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

I've created the accounts.txt per the youtube instructions, and also put the local IP of my powerwall in powerwallTimeOfUseCheck.py and powerwallBackup.py

Do I also need to change password = 'ST17I0012345' in those scripts? Should this be the serial number of the Gateway?

psmedley commented 2 years ago

Could this also be as I have two Powerwalls in two different sites, so the script doesn't know which to update?

fkhera commented 2 years ago

If would do both locations but recently tesla uses stricter policy to get tokens. I don’t believe they have fixed it.

On Sat, Jan 8, 2022 at 2:51 PM Paul Smedley @.***> wrote:

Could this also be as I have two Powerwalls in two different sites, so the script doesn't know which to update?

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/fkhera/powerwallCloud/issues/11*issuecomment-1008160544__;Iw!!IKRxdwAv5BmarQ!JOzRK_TZp_WEnmVMaW62uxhxlsXuzIqMc001yvhaGo-MMtBuqKZikajbhjVY1w$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABU4JYCFQROPOMQUHF3OCLDUVCWV3ANCNFSM5LRB7HTQ__;!!IKRxdwAv5BmarQ!JOzRK_TZp_WEnmVMaW62uxhxlsXuzIqMc001yvhaGo-MMtBuqKZikahahtk8KA$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!IKRxdwAv5BmarQ!JOzRK_TZp_WEnmVMaW62uxhxlsXuzIqMc001yvhaGo-MMtBuqKZikagZdQcCVQ$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!IKRxdwAv5BmarQ!JOzRK_TZp_WEnmVMaW62uxhxlsXuzIqMc001yvhaGo-MMtBuqKZikaj5yN_xBA$.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

psmedley commented 2 years ago

So the script is broken for everyone right now?

Is there a way to only update one of my Powerwalls? they are at different sites and on different energy plans

gdotp01 commented 2 years ago

I've been using this for a few months now and its worked really well. However a few days ago it stopped and Im not sure why. Looking at this thread Im assuming that Tesla have changed something or is that a wrong assumption? My error is:

Processing: grahampowell@email.com Invoking mode: tou ('back up attempts count: ', 0) authenticating ('token auth attempts count: ', 0) authenticating Got token details {u'expiredate': u'2022-01-17T00:31:09.702245', u'access_token': u'eu-f9c3c93ed81209f11cd4c013a1a48d5b2fe522a8eb35b3deda2d1659c8da9xxxx', u'created_at': 1638491469, u'expires_in': 3888000, u'token_type': u'bearer', u'user': u'grahampowell@email.com', u'refresh_token': u'f32fdb2863b3521f8c7ec13a2f04f0f537ac1c2cefdbcadf494355a9af1bd8xxx'} Traceback (most recent call last): File "/home/pi/powerwallBackup.py", line 70, in main tpw.productlist() File "/home/pi/powerwallBackup.py", line 134, 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

Any ideas ?

fkhera commented 2 years ago

Token expired and tesla does not allow New tokens but there is apps out there to get a token your token expire date 1-17

On Fri, Jan 14, 2022 at 1:45 PM gdotp01 @.***> wrote:

I've been using this for a few months now and its worked really well. However a few days ago it stopped and Im not sure why. Looking at this thread Im assuming that Tesla have changed something or is that a wrong assumption? My error is:

Processing: @. Invoking mode: tou ('back up attempts count: ', 0) authenticating ('token auth attempts count: ', 0) authenticating Got token details {u'expiredate': u'2022-01-17T00:31:09.702245', u'access_token': u'eu-f9c3c93ed81209f11cd4c013a1a48d5b2fe522a8eb35b3deda2d1659c8da9581', u'created_at': 1638491469, u'expires_in': 3888000, u'token_type': u'bearer', u'user': @.', u'refresh_token': u'f32fdb2863b3521f8c7ec13a2f04f0f537ac1c2cefdbcadf494355a9af1bd8fc'} Traceback (most recent call last): File "/home/pi/powerwallBackup.py", line 70, in main tpw.productlist() File "/home/pi/powerwallBackup.py", line 134, 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

Any ideas ?

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/fkhera/powerwallCloud/issues/11*issuecomment-1013461721__;Iw!!IKRxdwAv5BmarQ!O-ftLvHs_jQVlDTGA7pLD-d_uq8xZhX-WO7gmqbzFKyvcSzsMWlA6g29XgLuQw$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABU4JYC2JIK4L7JMOFFDP3DUWCDNPANCNFSM5LRB7HTQ__;!!IKRxdwAv5BmarQ!O-ftLvHs_jQVlDTGA7pLD-d_uq8xZhX-WO7gmqbzFKyvcSzsMWlA6g0vJXaR1g$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!IKRxdwAv5BmarQ!O-ftLvHs_jQVlDTGA7pLD-d_uq8xZhX-WO7gmqbzFKyvcSzsMWlA6g0hLDLYXA$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!IKRxdwAv5BmarQ!O-ftLvHs_jQVlDTGA7pLD-d_uq8xZhX-WO7gmqbzFKyvcSzsMWlA6g2gMlMcgQ$.

You are receiving this because you commented.Message ID: @.***>

gdotp01 commented 2 years ago

Hi thanks can you explain a bit more please. How would I get a new token?

gdotp01 commented 2 years ago

Hi again ! I think i've generated a new token but don't know what to do with it now. I can see there is a token.db file and it does contain my previous token but it also contains information that I don't have such as expiredate, createdate etc

How do i refresh the data in this using my new token ?

fkhera commented 2 years ago

Change the token field that starts with like qts and change the expire date to something in future

On Sat, Jan 15, 2022 at 9:46 AM gdotp01 @.***> wrote:

Hi again ! I think i've generated a new token but don't know what to do with it now. I can see there is a token.db file and it does contain my previous token but it also contains information that I don't have such as expiredate, createdate etc

How do i refresh the data in this using my new token ?

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/fkhera/powerwallCloud/issues/11*issuecomment-1013714236__;Iw!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fSf-Rjm8g$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABU4JYAV367363R44SWOTX3UWGQFNANCNFSM5LRB7HTQ__;!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fTwBLv2HA$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fS9JXot0w$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fSmvHzpAA$.

You are receiving this because you commented.Message ID: @.***>

fkhera commented 2 years ago

I got some working code, (I only use Mac currently for this), I installed selenium, chrome driver etc. It appears if you use this combination the browser thinks you are a real user, no captcha none of that. This allows you to easily get the code. THe only downside I have seen is , need to run browser mode, let it open browser not headless. Also if you run too many accounts too quickly the firewall seems to pick up on that, slowly process 1 at a time.

Good luck https://github.com/fkhera/powerwallCloud/blob/master/authtoken.py

Using this code in combination in package then you can get the auth tokens

you can use this file to generate token.db file and replace the token.db file and it should be okay.

On Sat, Jan 15, 2022 at 9:47 AM Farooq Khera @.***> wrote:

Change the token field that starts with like qts and change the expire date to something in future

On Sat, Jan 15, 2022 at 9:46 AM gdotp01 @.***> wrote:

Hi again ! I think i've generated a new token but don't know what to do with it now. I can see there is a token.db file and it does contain my previous token but it also contains information that I don't have such as expiredate, createdate etc

How do i refresh the data in this using my new token ?

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/fkhera/powerwallCloud/issues/11*issuecomment-1013714236__;Iw!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fSf-Rjm8g$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABU4JYAV367363R44SWOTX3UWGQFNANCNFSM5LRB7HTQ__;!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fTwBLv2HA$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fS9JXot0w$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fSmvHzpAA$.

You are receiving this because you commented.Message ID: @.***>

fkhera commented 2 years ago

Here is sample data in token.db file that went bad:

{"expiredate": "2022-03-01T08:59:25.142461", "access_token": "qts-988a973fe27a6e63abcd", "created_at": 1642262364, "expires_in": 3888000, "token_type": "bearer", "user": @.***", "refresh_token": "77d53ace39dfeb70101953ab9d8e913d533b41b626a3083d613ce3e42c31213d"}

So the expiredate may say a date in Jan, needs to change you could use data above if you wish access token is qts-abcd and refresh token can probably leave alone.

-Farooq

On Sat, Jan 15, 2022 at 9:49 AM Farooq Khera @.***> wrote:

I got some working code, (I only use Mac currently for this), I installed selenium, chrome driver etc. It appears if you use this combination the browser thinks you are a real user, no captcha none of that. This allows you to easily get the code. THe only downside I have seen is , need to run browser mode, let it open browser not headless. Also if you run too many accounts too quickly the firewall seems to pick up on that, slowly process 1 at a time.

Good luck https://github.com/fkhera/powerwallCloud/blob/master/authtoken.py

Using this code in combination in package then you can get the auth tokens

you can use this file to generate token.db file and replace the token.db file and it should be okay.

On Sat, Jan 15, 2022 at 9:47 AM Farooq Khera @.***> wrote:

Change the token field that starts with like qts and change the expire date to something in future

On Sat, Jan 15, 2022 at 9:46 AM gdotp01 @.***> wrote:

Hi again ! I think i've generated a new token but don't know what to do with it now. I can see there is a token.db file and it does contain my previous token but it also contains information that I don't have such as expiredate, createdate etc

How do i refresh the data in this using my new token ?

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/fkhera/powerwallCloud/issues/11*issuecomment-1013714236__;Iw!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fSf-Rjm8g$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABU4JYAV367363R44SWOTX3UWGQFNANCNFSM5LRB7HTQ__;!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fTwBLv2HA$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fS9JXot0w$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!IKRxdwAv5BmarQ!PUn7LmzC27AlBFFZWg028CN4-uxj7GD6ImDiuCWdC8HcC3-kaC4s9fSmvHzpAA$.

You are receiving this because you commented.Message ID: @.***>

gdotp01 commented 2 years ago

When you say the token that starts with qts do you mean the "Access Token :"

mine does not start with qts it starts with eu-

There is one in the database that starts QTS but i think it's one of your old ones.

fkhera commented 2 years ago

Yes access_token field

On Sat, Jan 15, 2022 at 10:00 AM gdotp01 @.***> wrote:

When you say the token that starts with qts do you mean the "Access Token :"

mine does not start with qts it starts with eu-

There is one in the database that starts QTS but i think it's one of your old ones.

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/fkhera/powerwallCloud/issues/11*issuecomment-1013716406__;Iw!!IKRxdwAv5BmarQ!OaB35hQ-UKFrGT_aUcmSQ6ivaq86LMY2r5vyYduS-MGEt_QHxPnwWny818N2vQ$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABU4JYC6UHERDPXW4272N2DUWGR2ZANCNFSM5LRB7HTQ__;!!IKRxdwAv5BmarQ!OaB35hQ-UKFrGT_aUcmSQ6ivaq86LMY2r5vyYduS-MGEt_QHxPnwWnxWO_kr2g$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!IKRxdwAv5BmarQ!OaB35hQ-UKFrGT_aUcmSQ6ivaq86LMY2r5vyYduS-MGEt_QHxPnwWnzp2xPEdQ$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!IKRxdwAv5BmarQ!OaB35hQ-UKFrGT_aUcmSQ6ivaq86LMY2r5vyYduS-MGEt_QHxPnwWnwU36xcXw$.

You are receiving this because you commented.Message ID: @.***>

gdotp01 commented 2 years ago

Many thanks for your help. Thats working again with my new token

fkhera commented 2 years ago

Token is only good for 45 days so they say .

On Sat, Jan 15, 2022 at 10:10 AM gdotp01 @.***> wrote:

Many thanks for your help. Thats working again with my new token

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/fkhera/powerwallCloud/issues/11*issuecomment-1013718059__;Iw!!IKRxdwAv5BmarQ!NVHCRqOjTmw0GMSEjQgCvIV6B5XQNTmMCNxPlx8A0BR0_O9PazCCRYIFEdsADA$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABU4JYAT3XNKSWI4UC2V4R3UWGTANANCNFSM5LRB7HTQ__;!!IKRxdwAv5BmarQ!NVHCRqOjTmw0GMSEjQgCvIV6B5XQNTmMCNxPlx8A0BR0_O9PazCCRYL_Z8hJ-w$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!IKRxdwAv5BmarQ!NVHCRqOjTmw0GMSEjQgCvIV6B5XQNTmMCNxPlx8A0BR0_O9PazCCRYKj6CAQaQ$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!IKRxdwAv5BmarQ!NVHCRqOjTmw0GMSEjQgCvIV6B5XQNTmMCNxPlx8A0BR0_O9PazCCRYJbP3LPgQ$.

You are receiving this because you commented.Message ID: @.***>

gdotp01 commented 2 years ago

Yes which is a shame. However by then the weather will be better here and hopefully I won't need to manually set it over the summer.

gdotp01 commented 2 years ago

hi. The script has been running fine but recently stopped. I assumed it was because of the API key had expired so did my normal refresh. However this time i tried it the API key returned as a LOT longer than previously. I added it to the token.db file anyhow and it worked. However 24 hours later it stopped again. It seems now that it expires really quickly. i get the following error when running powerwallDriver.py.

Traceback (most recent call last): File "/home/pi/powerwallBackup.py", line 70, in main tpw.productlist() File "/home/pi/powerwallBackup.py", line 136, in productlist productListItems = result["response"] KeyError: 'response'

Any ideas what has changed ?

gdotp01 commented 2 years ago

After some research it looks like the API key expires now every 5 hours. It’s beyond me to fix this. I’ve seen that the the utility that runs ion smarthings has been updated to work around the problem

jasonacox commented 1 year ago

If you are looking for a way to set-reserve via cron, there is an alternative method using the TeslaPy module that requires some user setup (pasting URL to get token) but doesn't seem to expire (at least as frequently - been using for >month). Here is the implementation I'm using: https://github.com/jasonacox/pypowerwall/tree/main/tools#set-reserve - The same approach may work here.