-
Notifications
You must be signed in to change notification settings - Fork 25
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
Asyncify the API #55
Asyncify the API #55
Conversation
Please be kind, this is my first github contribution! :) Let me know how I can make this change better. I don't have a powerwall myself so I haven't run the integration tests. Is there anybody who would be willing to help me out and try it? |
…y, I shouldn't have removed the logic to automatically create an http client session and the close method. Adds this functionality back.
I can offer to assist with testing, but have no idea how. If you explain any procedure I will try. |
Thanks! I'm on a mac, and I would run:
If you're missing any commands like gh and tox, run:
|
Hey @dh99999 would you be able to help test out this pull request for me? Also could I get you to help me get refreshed fixture data. Seems like there has been some big changes in the data structure as compared to version 0.3.19... maybe this corresponds to updated firmware. I wonder why it isn't a breaking change since it deviates a lot from the fixture data in the powerwall HA integration. |
|
I am on a PC, how do I install gh and tox? Brew is not recognised |
You'll have to find a guide to get python and pip installed. Then install tox. I've never tried getting gh for windows, but perhaps it is available here? Else it might be easier to get this pull request via the github desktop app. |
got to the last command, tox has installed correctly but cant be found??? admin@STUDY MINGW64 ~/tesla_powerwall (asyncify) |
Hmm, you can try this command and maybe the first line shows you the path to the tox binary?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bubonicbob Thank you very much for your PR! I think it already looks quite good, just some minor points that I would like to address before merging it. Additionally, I will also do some testing of your implementation soon, to see if everything works as expected.
Nevertheless, I am quite unsure, about the use of aresponses
for testing, as the project seems to be inactive for over two years now and aiohttp looks like it already has good support for testing. I would prefer the direct use of aiohttp, but I would see this more as a future improvement, than a requirement for this PR, as it might otherwise blow the scope. If you want to take a look, I would be happy to also merge this, otherwise I will take care of this in the future.
Okay I can see the path but how do i incorporate that into the cmd
|
Had a quick look, and saw nothing obviously wrong. Here's what I thought of;
|
It is a good habit to not set passwords into your environment so don't go out of your way to make these global settings, or if you really want to make sure, set your After setting those two variables for your specific shell, you can just run tox by itself:
|
Thank you! Yes merging this will break anything that depends on this library. In my limited experience, it seems typical in python-land that libraries in this situation just hard fork into something with an 'a' in front of the original name and don't bother with maintaining a hybrid api. In the case of this specific library, there's support for taking the plunge and moving the API over. @jrester since this is a major API change, should the version change to 0.5.0? Not sure the official way to do that. |
Much appreciated! I'm pretty new to python so I don't know what are the popular choices for testing. I picked While you're testing, I'd really appreciate help updating the fixture data for the HA integration tests. I've made a draft pull request to use this library and the fixture data breaks tests over there. I saw these samples from a similar project but still the powerwall firmware is a few years old. |
I got tox to run by exporting the PATH using: _This leads to an ambiguous overall configuration. If you want to distribute this ....so I am looking for more help please. |
Weird. The
You can manually run the pip install for it like this:
|
Tried both of the above but failed. Verbose output: [removed verbose output SEE BELOW] |
I am installing Microsoft Visual C++ 14.3 now to see if that is the culprit. EDIT: now the test runs okay but failed due to login error, need to resolve that now. |
Test still fails :( |
Attached output from last test: |
My fault, please try one more time. |
SUCCESS! Ran 10 tests in 27.502s OK |
@ejbatts Sweet. I owe you a beer next time you're in Seattle. 🍻 |
@jrester Sorry for the spammy comments on this. It is ready to land: both integration and unit tests pass. Don't think I have permissions to actually merge it to master. |
Will the changed integration allow me to access individual battery data? The essential thing I want is BATTERY POWER (charge/discharge rate) as individual entities and not the combined value that Tesla provides as default. |
Create an issue on this repo for that and we can all discuss there. Instructions. |
Oh okay. I actually thought this testing was heading in that direction after I posted this on https://github.com/home-assistant/core/issues/100065#top thread.
I'll raise a blank issue. EDIT: DONE! |
Everything seems to be working great after I small fixes I added to home-assistant/core#107164 |
Pretty significant drop in cpu usage for the HA integration observed as well |
There's still a lot of JSON being passed around, which is what's mostly left of the CPU runtime, using orjson to parse would probably solve that, but that's for another PR. |
Added an issue for it. |
I think this looks ready for a release once the typing comments and the aiohttp session comments are sorted The HA PR looks like its good to go after this is released and the tests are updated |
…ated with "unsafe" cookies
I'm ready to get this released. I don't think I'm able to do this myself. |
Retested with latest code. Everything seems to be working as expected |
Thank you very much @bubonicbob for implementing this. Also thank you very much @bdraco, @ejbatts and @quozl for testing and reviewing! |
Version 0.5.0 is now live on PyPi |
No worries. Well done everyone.
|
Change the API to use asyncio to be compatible with Home Assistant. This was discussed here.