milanmeu / aioaseko

Async Python package for the Aseko Pool Live API
https://pypi.org/project/aioaseko/
GNU Lesser General Public License v3.0
4 stars 2 forks source link

fix: handle access token expiration #2

Closed hopkins-tk closed 1 year ago

hopkins-tk commented 1 year ago

Use refresh token to obtain fresh access token for use.

In case it is not valid anymore, re-authenticate the user using username/password.

Fixes #1

hopkins-tk commented 1 year ago

Fix will go along with following change in HA in case you would like to test https://github.com/home-assistant/core/commit/a195df265ad451e85288391d5c8c0701a35952b5 - I will create Pull Request later, once we have a version to put there.

ChristianLoacker commented 1 year ago

@hopkins-tk @milanmeu Thank you both for the excellent work you do!! I am wondering how I could download the fix and use it already? ...or do you have a realistic timeline for an official release? Thank you both!

hopkins-tk commented 1 year ago

@ChristianLoacker personally I test this fix along with the change required in Home Assistant itself (https://github.com/home-assistant/core/commit/a195df265ad451e85288391d5c8c0701a35952b5) for past few weeks.

To get it merged & released I will need @milanmeu help, but if you would like to help with testing, you can do so by modifying the files in your Home Assistant.

For the Docker version it is in:

In case you are wondering if it will survive updates - no, unfortunately not (if you do not mount it as a volume from outside to always override the files provided by the Docker image.

ChristianLoacker commented 1 year ago

Thank you very much @hopkins-tk / I absolutley would love to test it on a NUC that runs Generic x86-64 HomeAssistant. Is there a link to install it via Custom HACS repository or a source to download it and run it after uploading to \ local \ config \ custom_components

How can I upload it to my HomeAssistant?

Thank you so much for your support!

milanmeu commented 1 year ago

@hopkins-tk Thanks for the PR. I have suggested some changes. You can commit these suggestions if they look good to you. My first comment has some more info on why I would make these changes.

hopkins-tk commented 1 year ago

Thanks @milanmeu, it makes sense, so I have applied all your suggestions and updated the name of the constant, which was not matching.

ChristianLoacker commented 1 year ago

@milanmeu @hopkins-tk Thank you both for the ongoing support- hope it will be released soon?? Best regards!

ChristianLoacker commented 1 year ago

@milanmeu - since all is reviewed - I really hope you find the time soon to release? Thank you very much!!

OndrejMiko commented 1 year ago

@ChristianLoacker personally I test this fix along with the change required in Home Assistant itself (home-assistant/core@a195df2) for past few weeks.

To get it merged & released I will need @milanmeu help, but if you would like to help with testing, you can do so by modifying the files in your Home Assistant.

For the Docker version it is in:

* /usr/local/lib/python3.10/site-packages/aioaseko/mobile.py (file from this Pull Request)

* /usr/src/homeassistant/homeassistant/components/aseko_pool_live/**init**.py (file from [home-assistant/core@a195df2](https://github.com/home-assistant/core/commit/a195df265ad451e85288391d5c8c0701a35952b5))

* /usr/src/homeassistant/homeassistant/components/aseko_pool_live/config_flow.py (file from [home-assistant/core@a195df2](https://github.com/home-assistant/core/commit/a195df265ad451e85288391d5c8c0701a35952b5))

In case you are wondering if it will survive updates - no, unfortunately not (if you do not mount it as a volume from outside to always override the files provided by the Docker image.

Hello , i used this by your instructions, aseko pools connect, but after 15 minutes its not working again. Dont know which version must used with this module. Can u help me somehow? Thank you very much

Using RPI3 with HA docker image.

hopkins-tk commented 1 year ago

@OndrejMiko thanks for your willingness to help with testing. Please make sure to restart the HA through the UI button in Developer Tools to re-load the aioaseko integration and to use the current version of the files in this Pull Request. Another option would be to mount the files as volumes to the container and then restart the whole container (as the files will be there when the HA starts).

hopkins-tk commented 1 year ago

While we are waiting for a merge - in case you are using Docker to run HA, to apply the necessary changes that will survive restarts of Docker container from this Pull Request and https://github.com/home-assistant/core/commit/a195df265ad451e85288391d5c8c0701a35952b5, you can do it by setting following volumes (update source paths accordingly):

    volumes:
      - ./home-assistant/aseko_pool_live/__init__.py:/usr/src/homeassistant/homeassistant/components/aseko_pool_live/__init__.py:ro
      - ./home-assistant/aseko_pool_live/config_flow.py:/usr/src/homeassistant/homeassistant/components/aseko_pool_live/config_flow.py:ro
      - ./home-assistant/aioaseko/mobile.py:/usr/local/lib/python3.10/site-packages/aioaseko/mobile.py:ro
OndrejMiko commented 1 year ago

@OndrejMiko thanks for your willingness to help with testing. Please make sure to restart the HA through the UI button in Developer Tools to re-load the aioaseko integration and to use the current version of the files in this Pull Request. Another option would be to mount the files as volumes to the container and then restart the whole container (as the files will be there when the HA starts).

It works thank you very much, I dont reboot whole docker last time. Thumbs up for you

ChristianLoacker commented 1 year ago

Hi all - just for my understanding - all is fiixed - why is there no official release yet? Thank you all for your great work, @milanmeu - hope you find some time to release this? Best regards to all

hopkins-tk commented 1 year ago

I have updated the API to v2 as v1 seems to have been decommissioned cca two days ago.

maglerod commented 1 year ago

I'm running HA on RPI4 without any docker. Is there a way for me to get the integration working?.

ChristianLoacker commented 1 year ago

Hi @maglerod - same problem for me. I am waiting for an update of the version since last summer. I have installed the Home Assistant OS on a NUC. I spent many hours but couldnt get the fix to work. I am an absolute OK PC user - but not a developer. I hope that @milanmeu finally releaes the version. I get quite frustrated in the meantime I have to admit...

maglerod commented 1 year ago

So really?, there is a fix for this but still not released. Why is that?. If not beeing fixed, i believe the integration should be removed from HA, right now it's a broken integration. I actually bought the Aseko hardware just because there was an integration in HA...

If i had knew that it was a broken integration, perhaps i would have choose something else.

All integrations should either be updated or removed, that's my opinion...

milanmeu commented 1 year ago

Thanks for you PR @hopkins-tk. I'm sorry it took so long to review and publish the package. The updated version is published on PyPI so you can now make a PR to update the Home Assistant integration.

hopkins-tk commented 1 year ago

Thanks @milanmeu the Home Assistant part is here: https://github.com/home-assistant/core/pull/99495