alandtse / tesla

Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.
Apache License 2.0
594 stars 100 forks source link

Powerwall gets http 410 response with null data and does not update due to API change #724

Closed Viss closed 1 year ago

Viss commented 1 year ago

Version of the custom_component

3.17.1 - current as of yesterday

Configuration

Describe the bug

I updated this integration yesterday, and noticed that the automations I have to switch my powerwalls configs around never fired, and upon investigation I found the integration had stopped working:

image

I am thinking that it just needs to have a token refresh happen, but it appears that I can't update the refresh token without completely removing and reconfiguring my powerwall. Is there a way to update the refresh token without tearing out the integration?

Debug log

2023-10-05 17:53:37.518 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/powerwalls/STE20201009-00492 {}
2023-10-05 17:53:37.780 DEBUG (MainThread) [teslajsonpy.connection] 410: {"response":null,"error":"https://powergate.prd.sn.tesla.services:443/api/powerwalls/1232100-00-E--TG1202500029KL/fullstatus => Gone","error_description":""}
2023-10-05 17:53:37.781 WARNING (MainThread) [teslajsonpy.controller] Unable to get battery data during setup, battery will still be added. 410: UNKNOWN_ERROR_410
2023-10-05 17:53:37.781 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 2:57:54
2023-10-05 17:53:37.782 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/powerwalls/STE20201009-00492/status {}
2023-10-05 17:53:37.898 DEBUG (MainThread) [teslajsonpy.connection] 410: {"response":null,"error":"https://powergate.prd.sn.tesla.services:443/api/powerwalls/1232100-00-E--TG1202500029KL/status => Gone","error_description":""}
2023-10-05 17:53:39.062 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 2:57:52
2023-10-05 17:53:39.062 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/powerwalls/STE20201009-00492/status {}
2023-10-05 17:53:39.157 DEBUG (MainThread) [teslajsonpy.connection] 410: {"response":null,"error":"https://powergate.prd.sn.tesla.services:443/api/powerwalls/1232100-00-E--TG1202500029KL/status => Gone","error_description":""}
2023-10-05 17:53:42.013 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 2:57:49
2023-10-05 17:53:42.015 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/powerwalls/STE20201009-00492/status {}
2023-10-05 17:53:42.120 DEBUG (MainThread) [teslajsonpy.connection] 410: {"response":null,"error":"https://powergate.prd.sn.tesla.services:443/api/powerwalls/1232100-00-E--TG1202500029KL/status => Gone","error_description":""}
2023-10-05 17:53:46.235 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 2:57:45
2023-10-05 17:53:46.236 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/powerwalls/STE20201009-00492/status {}
2023-10-05 17:53:46.328 DEBUG (MainThread) [teslajsonpy.connection] 410: {"response":null,"error":"https://powergate.prd.sn.tesla.services:443/api/powerwalls/1232100-00-E--TG1202500029KL/status => Gone","error_description":""}
2023-10-05 17:53:52.783 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 2:57:39
2023-10-05 17:53:52.784 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/powerwalls/STE20201009-00492/status {}
2023-10-05 17:53:53.071 DEBUG (MainThread) [teslajsonpy.connection] 410: {"response":null,"error":"https://powergate.prd.sn.tesla.services:443/api/powerwalls/1232100-00-E--TG1202500029KL/status => Gone","error_description":""}
akballow commented 1 year ago

I reinstalled with a new token and still have the issue. This seems like an API issue as the response comes back but has null info

Viss commented 1 year ago

oh! so its not just me!

On October 5, 2023 6:30:02 PM PDT, akballow @.***> wrote:

I reinstalled with a new token and still have the issue. This seems like an API issue as the response comes back but has null info

-- Reply to this email directly or view it on GitHub: https://github.com/alandtse/tesla/issues/724#issuecomment-1749866893 You are receiving this because you authored the thread.

Message ID: @.***>

Avatar1976 commented 1 year ago

Add me to the list, same issue, tried same fixes too.

Avatar1976 commented 1 year ago

Further information, this specifically relates to Powerwall / Energy Site integrations. If you delete your configuration from the devices are in Home Assistant, and then add back again but deselecting energy sites and leaving only vehicles selected. This will allow you to at least have cars visible to HA. Sad to see though as I used this to control my Powerwall a lot.

akballow commented 1 year ago

Further information, this specifically relates to Powerwall / Energy Site integrations. If you delete your configuration from the devices are in Home Assistant, and then add back again but deselecting energy sites and leaving only vehicles selected. This will allow you to at least have cars visible to HA. Sad to see though as I used this to control my Powerwall a lot.

Yeah even if you select both you can see in the logs that the car discovery comes in fine it just fails on getting the powerwall info and repeats a few times before it quits

DUNKENBLITHS commented 1 year ago

Ah so this isn't just me ! - usually i have to reboot the router when something isn't connected, but didn't fix it, so....

Just can't access the car through HA, will just use phone now, as I need all PowerWall control

SalisburyLad commented 1 year ago

It just appears to be Powerwall changing operational mode for me. Backup reserve and grid charging are working. I only have Powerwall.

quietlikeninja commented 1 year ago

Mine stopped talking to my powerwall about 6 hours ago. I saw there was an update to kicked that off but now have this issue :-(

I only noticed when I saw I had exported 11kwh of solar at -4c/kWh because my automation thought I needed an extra 5kWh to charge my battery as it was only at 37% :-(

Viss commented 1 year ago

i wonder if theres a way to change the powerwall settings locally, without having to use the api, making this integration not have to use cloud...

On October 5, 2023 7:10:14 PM PDT, Avatar1976 @.***> wrote:

Add me to the list, same issue, tried same fixes too.

-- Reply to this email directly or view it on GitHub: https://github.com/alandtse/tesla/issues/724#issuecomment-1749890175 You are receiving this because you authored the thread.

Message ID: @.***>

Viss commented 1 year ago

oh it wrecked the whole thing for me. im using this integration to draw all my charts for consumption and solar - everything. basically my whole electric setup went offline

On October 5, 2023 9:19:31 PM PDT, SalisburyLad @.***> wrote:

It just appears to be changing operational mode for me. Backup reserve and grid charging are working.

-- Reply to this email directly or view it on GitHub: https://github.com/alandtse/tesla/issues/724#issuecomment-1749961711 You are receiving this because you authored the thread.

Message ID: @.***>

DUNKENBLITHS commented 1 year ago

With regards to the Power wall.. use the other interface, thats still working fine...

image

akballow commented 1 year ago

With regards to the Power wall.. use the other interface, thats still working fine...

image

I use both the official one reads data straight from the gateway. The custom one is the api to the app which gives you the ability to modify the settings which the official one never can do since you can not make those changes if you visit your gateway web ui even.

akballow commented 1 year ago

i wonder if theres a way to change the powerwall settings locally, without having to use the api, making this integration not have to use cloud... On October 5, 2023 7:10:14 PM PDT, Avatar1976 @.> wrote: Add me to the list, same issue, tried same fixes too. -- Reply to this email directly or view it on GitHub: #724 (comment) You are receiving this because you authored the thread. Message ID: @.>

I wish I feel like the app has like 80% success rate to make changes. If it was all local it would be amazing.

quietlikeninja commented 1 year ago

With regards to the Power wall.. use the other interface, thats still working fine...

image

You are now my hero :-)

Solar management is back online for me

daniel-simpson commented 1 year ago

Same issue for me. Logged on to the powerwall local portal directly to get some diagnostics. I'm assuming it's probably a system update that has knocked it out, so here's my "Customer Version": 23.28.2 27626f98

When looking at the local Powerwall's API it looks like they're spruiking a new "Tesla Pros" app to commission new Powerwall installs... so I'd guess there is a decent chance some breaking changes have occurred in the APIs this code is using 😭

image

andrew2408 commented 1 year ago

Also stopped working for me as of 8.40am Brisbane time.

Interestingly I have a third party 'Powerwall' app on my phone that I can only assume relies on the same cloud API and it is updating fine still. Does anyone have any other set ups that rely on the cloud API to see if these are down to (i.e. is it an issue with the API or the integration?)

Viss commented 1 year ago

i spent a bit of time troubleshooting. this integration calls a host named "powergate.prd.sn.tesla.services".

All of those subdomains stopped working, only the apex domain 'tesla.services' remains.

So this integration has broken because the host it phones home to so that it can interact with the tesla API is "just gone". We'll have to disassemble the new APK or do a pcap or dns dump of it so that we can fish out the new host it's talking to.

ChillV2L commented 1 year ago

was this after the core update for you all above ? this has also happened to me after the core update but it could just be a coincidence

bmsrecycle commented 1 year ago

This problem has seemed to happen with the Home Assistant 2023.10.0 update, I'm having the same issue.

NickSills1 commented 1 year ago

This issue is not related to a Home Assistant update. Same for me and I'm on 2023.7.3.

Viss commented 1 year ago

it happened to me today, I think it was right after I updated this module.

though i wager thats just a coincidence, because the debug logs say its trying to poke a host to do an api call, and that host straight up doesnt exist.

at first, glance it appears telsa rugged us all.

On 2023-10-06 00:25, NickSills1 wrote:

This issue isnot related to a Home Assistant update. Same for me and I'm on 2023.7.3.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/alandtse/tesla/issues/724#issuecomment-1750110570 [2] https://github.com/notifications/unsubscribe-auth/AANMYX6FTZONEDW6SNVYZELX56W7DAVCNFSM6AAAAAA5VCLEBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJQGEYTANJXGA

JasSmiths commented 1 year ago

Another +1 here which is not unexpected if they’ve killed the targets.

Fingers crossed this can sorted as my setup depends on it

jaymunro commented 1 year ago

+1

Duff-Box1 commented 1 year ago

Same issue, any fix's would be much appreciated as I also drive many automations from this.

rickpoisson commented 1 year ago

+1

skipishere commented 1 year ago

Instead of "+1" the issue and not adding anything new, please subscribe instead otherwise the thread gets long and details missed image

jaymunro commented 1 year ago

Good point. Sorry about that.

DUNKENBLITHS commented 1 year ago

If I hadn't done so many changes today, I would roll back the Core to see if that fixes it...but as someone says looks like the subdomain address has changed...

sandyman44 commented 1 year ago

another +1. Not a home assistant issue, no changes to HA my side. this integration just "stopped working" last night around 2340 GMT+1.

Alona23 commented 1 year ago

Same here, No powerwall integration. Watching

ChrisJ60 commented 1 year ago

I am also having this issue as of around 07:30 this morning UK time.

ChillV2L commented 1 year ago

Has anyone’s Teg connection to 192.168.91.1 also failed

ChrisJ60 commented 1 year ago

@ChillV2L

Has anyone’s Teg connection to 192.168.91.1 also failed

Do you mean a direct connection to the local gateway? If so then no, mine is working just fine. I have three scripts (outside of HA) that connect to that very regularly and all are working fine.

ChillV2L commented 1 year ago

@ChillV2L

Has anyone’s Teg connection to 192.168.91.1 also failed

Do you mean a direct connection to the local gateway? If so then no, mine is working just fine. I have three scripts (outside of HA) that connect to that very regularly and all are working fine.

I normally use it all the time but today it failed and will no longer connect

![Uploading IMG_7895.jpeg…]() ![Uploading IMG_7896.jpeg…]()

JohnKG72 commented 1 year ago

@ChillV2L

Has anyone’s Teg connection to 192.168.91.1 also failed

Do you mean a direct connection to the local gateway? If so then no, mine is working just fine. I have three scripts (outside of HA) that connect to that very regularly and all are working fine.

I normally use it all the time but today it failed and will no longer connect

![Uploading IMG_7895.jpeg…]()

![Uploading IMG_7896.jpeg…]()

All ok here.

ChillV2L commented 1 year ago

This might be worth mentioning but after i couldent connect to 192.168.91.1 when on my TEG network i reset my gateway, after i did this the powerwall went in to standby mode, i then went in to the tesla app and put it on self powered and the powerwall is working again

there has definitely been something going on over the last few days , yesterday i also kept loosing connection within HA with custom integration

Ottmar0815 commented 1 year ago

Same Problem here.

Avatar1976 commented 1 year ago

'tesla.services' remains.

So this integration has broken because the host it phones home to so that it can interact with the tesla API is "just gone". We'll have to disassemble the new APK or do a pcap or dns dump of it so that we can fish out the new host it's talking to.

Happy to help on that Viss, anyone know good pcap tools to run on Android OS?

Avatar1976 commented 1 year ago

If I hadn't done so many changes today, I would roll back the Core to see if that fixes it...but as someone says looks like the subdomain address has changed...

Agreed Dunken most promising is for someone to pcap or DNS dump as Viss says.

Viss commented 1 year ago

I did a pcap at my firewall, and plucked out these names:

ec2-34-213-227-184.us-west-2.compute.amazonaws.com
ec2-34-214-128-46.us-west-2.compute.amazonaws.com
ec2-52-12-169-42.us-west-2.compute.amazonaws.com
ec2-52-208-42-237.eu-west-1.compute.amazonaws.com
ec2-54-69-227-149.us-west-2.compute.amazonaws.com

i rubbed the request string from the logs against every one of them, and only the last one (ec2-54-69-227-149.us-west-2.compute.amazonaws.com) returned any kind of api data, and it seemed to be complaining that i did a get not a post.

My guess is that we're all stuck until someone properly reverses the tesla app using JEB or another android apk decompiler and pulls out the specific queries the new version of the app is doing to twiddle the settings.

this is more or less a cat-and-mouse game with tesla. they muck up the api, we have to slog through the apk sourcecode to figure out what changed, then update the hacs integration.

bmsrecycle commented 1 year ago

What I do not understand is that the integration is working for some people, I messaged a friend and he said his is working fine with the same set up as mine.

Viss commented 1 year ago

What I do not understand is that the integration is working for some people, I messaged a friend and he said his is working fine with the same set up as mine.

your friend is able to use home assitant to make changes to his powerwalls, and can change grid charging modes and backup reserve amounts?

monkga1 commented 1 year ago

It seems that until you reload the integration you can still change the settings via HA automation even though it is not displaying them correctly. Once integration is reloaded it no longer works at all.


From: Viss @.> Sent: Friday, October 6, 2023 7:47:49 PM To: alandtse/tesla @.> Cc: monkga1 @.>; Manual @.> Subject: Re: [alandtse/tesla] Powerwall gets http 410 response with null data and does not update due to API change (Issue #724)

What I do not understand is that the integration is working for some people, I messaged a friend and he said his is working fine with the same set up as mine.

your friend is able to use home assitant to make changes to his powerwalls, and can change grid charging modes and backup reserve amounts?

— Reply to this email directly, view it on GitHubhttps://github.com/alandtse/tesla/issues/724#issuecomment-1751263120, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5DS2A745M6YNJ7YE6CNUSTX6BG5LAVCNFSM6AAAAAA5VCLEBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJRGI3DGMJSGA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

bmsrecycle commented 1 year ago

It seems that until you reload the integration you can still change the settings via HA automation even though it is not displaying them correctly. Once integration is reloaded it no longer works at all. ____ From: Viss @.> Sent: Friday, October 6, 2023 7:47:49 PM To: alandtse/tesla @.> Cc: monkga1 @.>; Manual @.> Subject: Re: [alandtse/tesla] Powerwall gets http 410 response with null data and does not update due to API change (Issue #724) What I do not understand is that the integration is working for some people, I messaged a friend and he said his is working fine with the same set up as mine. your friend is able to use home assitant to make changes to his powerwalls, and can change grid charging modes and backup reserve amounts? — Reply to this email directly, view it on GitHub<#724 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5DS2A745M6YNJ7YE6CNUSTX6BG5LAVCNFSM6AAAAAA5VCLEBCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJRGI3DGMJSGA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

That makes sense then, so effectively its broken for everyone.

alandtse commented 1 year ago

Please note this is the defacto location for sharing API data. https://github.com/timdorr/tesla-api as I don't have a powerwall, it'll have to be a PR to resolve this. This thread may become unmanageable with the "me too" posts, so if someone wants to volunteer to help manage it, I'd be willing to add. I'd prefer someone who has a history working on other repos given the increased rights. I'll open up a discussion thread if you're interested.

NickSills1 commented 1 year ago

I'm using this integration and the local Powerwall integration to manage charge and discharge inline with Octopus Agile half hourly pricing. The only Powerwall switch that's missing from the local integration that I need is the 'Grid Charging' switch. Without it I can't force charge by setting the the backup reserve to 100% and setting Grid Charge on.

Does anyone know if the Grid Charging switch is available at all on the local Gateway API?

Viss commented 1 year ago

I've created an issue over there, linking to this thread: https://github.com/timdorr/tesla-api/issues/761

fingers crossed!

alexguichet commented 1 year ago

The /powerwalls routes are no longer available, but /energy_sites routes should still be. Integrations should probably move to that!

Viss commented 1 year ago

The /powerwalls routes are no longer available, but /energy_sites routes should still be. Integrations should probably move to that!

have you validated that those api endpoints can be used to twiddle the powerwall controls?

purcell-lab commented 1 year ago

SITE_DATA endpoint is still functional for monitoring of Powerwall:

python3 ./cli.py -e mark@purcell.id.au -z SITE_DATA
{
    "response": {
        "solar_power": 3108,
        "energy_left": 24302.526315789473,
        "total_pack_energy": 42112,
        "percentage_charged": 57.70926651735723,
        "backup_capable": true,
        "battery_power": -2600,
        "load_power": 508,
        "grid_status": "Active",
        "grid_services_active": false,
        "grid_power": 0,
        "grid_services_power": 0,
        "generator_power": 0,
        "island_status": "on_grid",
        "storm_mode_active": false,
        "timestamp": "2023-10-07T06:48:13+10:00",
        "wall_connectors": [
            {
                "din": "1529455-02-E--PGT22325086977",
                "wall_connector_state": 2,
                "wall_connector_fault_state": 2,
                "wall_connector_power": 0
            }
        ]
    }
}

BATTERY_DATA endpoints is broken:

$ python3 ./cli.py -e mark@purcell.id.au -z BATTERY_DATA
Traceback (most recent call last):
  File "/home/mark/./cli.py", line 221, in <module>
    main()
  File "/home/mark/./cli.py", line 122, in main
    print(product.api(command, **command_data))
  File "/usr/local/lib/python3.9/dist-packages/teslapy/__init__.py", line 726, in api
    return self.tesla.api(name, pathvars, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/teslapy/__init__.py", line 363, in api
    return self.request(endpoint['TYPE'], uri, serialize,
  File "/usr/local/lib/python3.9/dist-packages/teslapy/__init__.py", line 155, in request
    response.raise_for_status()  # Raise HTTPError, if one occurred
  File "/usr/lib/python3/dist-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 410 Client Error: https://powergate.prd.sn.tesla.services:443/api/powerwalls/1152100-14-J--CN321293G4J50D/fullstatus => Gone for url: https://owner-api.teslamotors.com/api/1/powerwalls/STE20220321-00093