Skip to content
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

Powerwall Firmware 22.18.6 Upgrade - Flashing Powerflow Animation #23

Closed
jasonacox opened this issue Sep 28, 2022 · 13 comments
Closed

Powerwall Firmware 22.18.6 Upgrade - Flashing Powerflow Animation #23

jasonacox opened this issue Sep 28, 2022 · 13 comments

Comments

@jasonacox
Copy link
Owner

The latest firmware upgrade from Tesla Powerwall has changed the powerflow animation javascript on the gateway. JavaScript error are now being produced for anyone using the pypowerwall proxy to render the animation.

@danisla Let me know if you see the same thing or have any suggestions for a fix. I'm taking a look as well.

Errors:

image

image

image

Issue also raised in Powerwall-Dashboard: jasonacox/Powerwall-Dashboard#88

@jasonacox
Copy link
Owner Author

Ok, the fix is easy! The issue is that pypowerwall proxy caches the responses from the Powerwall, including the setup JS. You just need to restart the pypowerwall proxy server.py and refresh your browser:

# if using a docker container
docker restart pypowerwall

I'll have to look to see if there is an easy way to have the proxy detect version upgrades and flush the cache.

@danisla
Copy link
Contributor

danisla commented Sep 28, 2022

I was gonna say, this looks like a caching issue. We might be able to inject some no-cache headers to prevent it from breaking.

@jasonacox
Copy link
Owner Author

Thanks Dan! Did you happen to see this on your dakboard displays? I suspect this is going to be a rare occurrence. I'll see if there is something simple we can do.

@danisla
Copy link
Contributor

danisla commented Sep 29, 2022

My powerwalls are offline this week because I'm adding another one so I didn't see it when the firmware update went out. However, I did see this behavior a couple times when I was developing the dashboard and it was a caching issue.

I'll see what my dakboard does when my powerwalls come back online later this week.

@danisla
Copy link
Contributor

danisla commented Oct 15, 2022

So I'm still on 20.18.3. I have a first gen gateway. When I check for updated firmware, says I'm up-to-date.

Is there something special I can do to get the newer firmware?

@jasonacox
Copy link
Owner Author

That's interesting! It doesn't seem like Tesla pushes out firmware versions globally. I suspect they have a digital twin of all of our configurations and only apply updates to those systems that need it, or at least the ones they want to "test" with.

@jasonacox
Copy link
Owner Author

Flashing animation due to firmware upgrade raised in jasonacox/Powerwall-Dashboard#112. TODO: Research cause (browser or proxy cache) and solution (no-cache header and/or TTL).

@jasonacox
Copy link
Owner Author

So there are two issues it seems:

  1. The animation and required assets are cached by the browser indefinitely, meaning that a refresh or reload won't fix it.
  2. The pypowerwall proxy caches all the js, css and other assets indefinitely, same problem as above. The fix is to do a pypowerwall proxy restart.

To fix the browser cache, I added the "Cache-Control: no-cache" header to the non-API endpoints (ie. animation css, js, etc).

To fix the local cache, based on some observations from @mcbirse in the discussion jasonacox/Powerwall-Dashboard#112, I made changes to the proxy server to detect when Powerwall Authentication happens (ie. auth token will change during a Firmware update) and then force clear the local cache.

This all seemed to work and I noticed the browser would re-request all the assets when a browser reload was performed (did not happened before). I released Build t20 that contains this update (see diff).

Now, I confess, I tend to over-engineer things. As I watched the debug log during my tests of t20, it occured to me that all the logic I added to provide a local cache was only being used on a browser reload. That is a rare event for a dashboard especially if you are rendering an animation. Removing the local cache removes the need to detect a firmware update. I pulled that code and new logic out and released Build t21 (see diff).

I just need another Firmware upgrade to test this new code. Sadly, a firmware upgrade on my system just happened last night before I made these changes so I won't be able to test this for a while but I'll publish this update so others can report how well it works during firmware updates on their systems. I am going to continue to test the t21 code to ensure I didn't introduce any memory leaks before I update the "latest" tag (currently t19) with this new version (t21).

@jasonacox
Copy link
Owner Author

As part of testing t21, I had an idea. It would be nice to be able to display the Powerwall firmware version or other data using some simple JQ calls. To support the CORS policy, the pypowerwall proxy also needs to set a "Access-Control-Allow-Origin: *" header. I added that and updated the example.html to include firmware version information in Build t22 (see diff):

image

@mcbirse
Copy link
Collaborator

mcbirse commented Nov 23, 2022

Great solution to this issue! Look forward to testing this and providing feedback... whenever my next firmware update happens. Maybe it won't be too long for me as mine hasn't updated to 22.26.4 yet.

Adding the firmware version to the Power Flow animation is a really nice addition too - love it! ❤️

@jasonacox
Copy link
Owner Author

Thanks! Hopefully you can be the first to test it! 😄 I pushed the Build t22 to "latest" if you want to upgrade now.

@mcbirse
Copy link
Collaborator

mcbirse commented Mar 12, 2023

Look forward to testing this and providing feedback... whenever my next firmware update happens.

Confirmed no more issues with the Power Flow animation after a FW update for me. 👍

@jasonacox
Copy link
Owner Author

Thanks @mcbirse ! No issues for me either. Thanks everyone! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants