-
Notifications
You must be signed in to change notification settings - Fork 26
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
Support multiple local Tesla Energy Gateways (Powerwall/Inverters) using the server for local or cloud access #119
Comments
The first step was to solve the ability to query two Tesla Energy Gateways on a LAN by using variations in NAT: #128 (comment) The second is to get the pypowerwall proxy server to be able to handle multiple gateways. I am working on this, but it's not done yet: Draft PR Essentially the proxy server needs to compartmentalize each inverter into its own separate proxy server and then route each request from the virtual IPs configured in the scripts above. That simply requires a ton of refactoring and modularization. |
@Nexarian 🙇 The draft looks good! Thanks for kicking that off and for the much needed refactoring. I'll put my additional comments in the PR. |
@jasonacox Still not quite finished! I've been going through it line-by-line, doing my best to preserve functionality while increasing modularity and maintainability. I also haven't actually tested this yet, because this refactor is so invasive I can't really do that until I'm finished. The main points in the PR are:
A few things things I'm still not sure yet is how to handle:
However, we could conceivably move this to JSON or YAML as well, but that's likely to break many things. Thanks for your support on this, it's taking me forever to get this honed in! Several late nights of coding so far! Also: I understand that a massive refactor like this is a big pill to swallow. I'm happy to "part out" the finished version into more digestible chunks so we migrate the server to the final result slowly, while I continue to test the full version on my own systems. |
Thanks @Nexarian - I haven't seen anything otherwise, but please keep these project design principles in mind:
Note on your suggested refactoring - for the most part I think these make it more readable, just to be clear.
We should target MVP so that each incremental is still a working proxy, backward compatible, but could slowly walk toward the final outcome. What is in scope for MVP? I'm having some difficulty thinking what would be broken out unless you are thinking about deeper refactoring. |
For me, at least, the MVP is the proxy can handle two simultaneous calls (using the virtual IPs above) to retrieve internal TEG/string data in such a way that two sets of string data/internal TEG data can show up on the Powerwall dashboard. Each inverter has its own TEG rather than a standalone Gateway like most Powerwall setups have. Why Tesla chose that route, I'm not sure, but it's what makes my situation harder. As you mentioned the other way to do this might be to simply have two containers that report into InfluxDB, or to multiplex them with my earlier solution that alternates static routes. My solution is certainly "fancier" and thus may violate simplicity over cleverness. Still, I don't think it unreasonable to say the system should support querying multiple TEGs simultaneously without fancy Docker manipulation (which might ALSO be a violation of that principle). MVP is As to the config, I will write it such a way that a simple "one TEG" setup will work, but it will also read multiple as well. Similar to how a black & white TV can read a color signal :) I am actually not planning on changing the API other than supporting multiple TEGs. |
As to how to part it out, I think there are multiple phases:
In no step would the API or functionality change, except for the expansion in the last one. |
Yes, I agree with you. There are several in the community that have multiple gateways (very larger systems) so this enhancement would work for them as well. The complexity concern is more related to the code readability than the functions. I think your proposal is very reasonable. |
The server.py refactor now works on my Raspberry PI; at least, it does for local access. I decided against using a config file given the way that environmental variables are used. You can simply do this:
I will continue testing. Feel free to check it out now! |
I love that approach @Nexarian - I was worried about the config file as well. |
I'm referencing this line:
TODO: Add support for multiple Powerwalls
As I have two side-by-side (SxS) Tesla 7.6 kw inverters, this feature is a must for me if I'm going to monitor my system using Powerwall dashboard, especially important is TEDAPI mode and a facility to alternate network routes to interleave data from the two.
This issue is to track development. I intend to tackle this myself.
The text was updated successfully, but these errors were encountered: