tesla: Powerwall gets http 410 response with null data and does not update due to API change
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:
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":""}
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 5
- Comments: 136 (12 by maintainers)
Commits related to this issue
- fix: update powerwall endpoints Thanks to @gkwok1 for the work closes #724 closes #475 closes #600 closes #296 — committed to llamafilm/tesla by alandtse 9 months ago
I think I got everything working again by migrating all battery_data and battery_summary to site_config, site_summary, and site data.
Here is my fork and please let me know if something is not working. This is my first attempt at python.
https://github.com/gkwok1/teslajsonpy
I’ve created an issue over there, linking to this thread: https://github.com/timdorr/tesla-api/issues/761
fingers crossed!
Instead of “+1” the issue and not adding anything new, please subscribe instead otherwise the thread gets long and details missed
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.
Teslajsonpy must be bumped. For example https://github.com/alandtse/tesla/commit/d7044737ba6d0aeeabb046b01268174a9c7b357c. You can’t really do it in GH interface as we expect the build environment to be bumped too using poetry. I’ll get to it eventually; I’m working on other things.
@Avatar1976 I don’t have “buy me a coffee”. Just trying to pay it forward for all the coders before me who did most of the heavy lifting. I think @alandtse is working with @jaymunro in straightening my code so it can be merged to the main repo. I don’t think setting up another HACS repo would be necessary as I will be removing my repo once it’s merged with the main branch.
Please remember if you are copying a custom teslajsonpy in, you need to revert it once we release. Otherwise you will break in the future because you will not receive any updates and your custom copy will override future updates.
I am also having this issue as of around 07:30 this morning UK time.
The update in HACS is live and working.
Operation mode is now working and the false zero readings on SoC appear gone.
Hi guys just a BTW, noticed an improvement my Powerwall Wh remaining now doesn’t see saw between 0 and the actual amount now. The breakage may have had an symptom previously.
@Jonesnetwork if its referencing the STE than its most likely coming from the same link that i said but its using warp_site_number instead. its all above my head how it works aswell.
i can confirm that using the /energy_sites points, i can change my backup reserve that i use in my node red scripts.
This is the way
If you have both vehicles and energy products this custom integration will not load.
You can restore partial functionality (vehicles only) if you delete the integration and then add excluding energy sites in the configuration dialog.
Unfortunately the localAPI no longer (over 12 months ago) allows changing modes with the exception of going off-grid, changing modes needs to occur through the cloudAPI.
Same here, No powerwall integration. Watching
This issue is not related to a Home Assistant update. Same for me and I’m on 2023.7.3.
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
I wish I feel like the app has like 80% success rate to make changes. If it was all local it would be amazing.
@GeorgeIoak Discussion would probably be the best place to start.
https://github.com/alandtse/tesla/discussions
I am not an active participant here but wanted to give it a shot to fix the integration since it’s something I rely on.
@GeorgeIoak Delete your integration and add it back in, you are trying to poll an ID that is not linked to your user.
Amazing work 😃 - thats now working for me and im back in business
drop the teslajsonpy folder in /config and restart HA.
Hiya
Have reloaded this integration within HomeAssistant with the code changes from an hour or so ago and I’m still getting a “Failed to set up” error.
Digging deeper I get these messages;
…line 272 seems to point to this
Regards.
Andrew
Oh man, this is bad news!
I noticed my integration wasn’t capturing the energy usage figures, so I reloaded and now of course I’ve lost the control services.
My main automation figures out how much to charge the Powerwall overnight from the grid based on the upcoming day’s solar forecast. It was pretty much the main reason I started using HA.
Keeping fingers crossed for a solution!
wouldn’t just using the “https://owner-api.teslamotors.com/api/1/energy_sites/” end points instead resolve the issue?
https://www.teslaapi.io/energy-sites/commands
I’ve fallen back to my old code with Node-Red and i cant still set the reserve via this end point, although Tesla had updated my site id for my powerwall, not sure when as i had not used this code for ages.
Thank you. Didn’t realize that really helpful and much appreciated.
Appologies, my post was confusing, I just leave the reserve at 100%. The combination of on/off grid, and grid charging on/off enables forced charge/discharge and synchronisation with the Agile pricing. I’ve only just added solar so I’m still experimenting with the PW charge limit, but that can be resolved with the current charge sensor in an automation, it doesn’t need the limit to be changed. If that makes sense.
Edit: To qualify what I mean. If current battery charge > x And Solar prediction is > y Then set Grid Charging to Off. That way, if the reserve is 100%, HA has total control over Solar and Agile and there’s no setting in the Tesla App, other than the changing the time based setting ( though I’m not sure that’s relevant ), that overrides.
The /powerwalls routes are no longer available, but /energy_sites routes should still be. Integrations should probably move to that!
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.
I did a pcap at my firewall, and plucked out these names:
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.
Same Problem here.
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
All ok here.
@ChillV2L
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.
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…
Good point. Sorry about that.
This problem has seemed to happen with the Home Assistant 2023.10.0 update, I’m having the same issue.
You are now my hero 😃
Solar management is back online for me
With regards to the Power wall… use the other interface, thats still working fine…
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