CJNE / ha-porscheconnect

Porsche Connect custom component for Home Assistant
MIT License
28 stars 11 forks source link

Stops working after a couple of days #199

Closed woozar closed 2 months ago

woozar commented 1 year ago

Version of the custom_component

0.0.16

Configuration

Describe the bug

I installed the integration through HACS. Then i added my credentials and it was working for a couple of days and then it stopped working. I removed everything and reinstalled it and tried to add it again and now I get the error message mentioned below in my core logs.

Debug log

Logger: homeassistant.config_entries
Source: custom_components/porscheconnect/__init__.py:94
Integration: Porsche Connect ([documentation](https://github.com/CJNE/ha-porscheconnect), [issues](https://github.com/CJNE/ha-porscheconnect/issues))
First occurred: August 28, 2023 at 6:46:26 PM (2 occurrences)
Last logged: August 28, 2023 at 6:49:20 PM

Error setting up entry ***my-em@ail*** for porscheconnect
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 388, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/porscheconnect/__init__.py", line 94, in async_setup_entry
    access_tokens = await controller.getAllTokens()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/client.py", line 32, in getAllTokens
    return await self._connection.getAllTokens()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 195, in getAllTokens
    token = await self._requestToken(application)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 202, in _requestToken
    await self._login()
  File "/usr/local/lib/python3.11/site-packages/pyporscheconnectapi/connection.py", line 167, in _login
    resume_url = resp.headers['Location']
                 ~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'Location'
woozar commented 1 year ago

After trying to readd it a couple of times, i got an email from porsche about suspociouse activities and i had to change my password and now the integration is working again - I am curious if it will keep working...

danielpervan commented 1 year ago

If you get that email again, I don't think you actually need to change the password. Merely clicking on the link in the email should be sufficient.

Actually, I don't know whether this is true or not, but according to some discussions I've seen, changing the password might even be worse since just clicking on the link will allegedly whitelist the IP, while changing the password will then reset everything and the IP might get blocked again.

xibix-fp commented 1 year ago

I have the same problem with my account, so I raised now a ticket to Porsche.

woozar commented 1 year ago

As of now, it is all still working perfectly. I will update the issue if it fails again.

woozar commented 12 months ago

I have the issue now for 3 days. If I only klickt there link in the mail but do no change the pw, I cannot log into the porsche dashboard. Now i changed the PW and asked Porsche support to whitelist my IP. I will get a call, as soon as the telefon-guy reaches the it-guy. The sensor is still offline, but I guess it only tries to log back in once an hour, so I will keep you posted. The guy on the phone said, that not answering the capture is the main issue...

woozar commented 12 months ago

I still do not get any values. If I try to add the integration again, I get some auth error. Even if i delete the existing devices and entities and try to add it again, i get that very same error as in the first post :(

tonycoupland commented 12 months ago

My integration seems to stay syncing for a few days before triggering the email from Porsche about suspicious activity.

Last night I clicked the link in the email, entered my email address and clicked Reset Password... I didn't follow the link the subsequent email so my password should be the same. At this point I was able to login again using a Python script and so recreated the integration in HA and at the moment everything is working again.

I think I did this same process before and things didn't reactivate on their own so it might not be an entirely reliable process.

woozar commented 11 months ago

Thanks you - sadly the whole thing is pretty unstable.

This is not blaming the author of the plugin but Porsche for not providing a useful API. I will never understand, why companies will not simply provide the data, that is already available on their website, through some public API. I personbally would also provide some support for it to create a good user experience, but this would not even be necessary...

SteveRCottrell commented 11 months ago

I came across this thread as I have experienced the same issue, the Integration worked perfectly and then after a couple days it stopped working. I have contacted Porsche Connect to see what they can do on their side and am awaiting a response. In the meantime, I noticed that there was a update to Home Assistant available, which I installed and upon restarting the Porsche Connect Integration kicked back to life. It will be interesting to see if the Integration stays active for more than a couple more days.

woozar commented 10 months ago

Hm. My login is active without capture but the integration is not working. As porsche updated their webportal, maybe they also changed their api or the code so the integration does no longer work properly? Ok I just realized, that I do not get notified for available hacs updates so after updating it started working again :)

davidjac commented 10 months ago

I see there is a new version. My version has been this stops and starts working. It appears Porsche closely controls the API and any external queries it will block ALL connection and require a reset making the plugin useless. No fault of author as already explained. However I still see another update has this problem therefore been resolved? THanks

woozar commented 10 months ago

Porsche does a capture every "n" (I don't know the number) logins and the integration cannot solve it, so it cannot read any more data. Then the capture comes again on the next try. If there are too many tries without solved capture, the account gets locked, which is a pretty standard fraud detection mechanism. It is the very same thing on the porsche website. I started logging into the website whenever the integration stopped working and I did nopt yet receive an "account locked" email and then after some time, the plugin continues to work, as the capture is assumed "solved" and will not show for some time. I hope this will help to understand what the issue is and why the author cannot solve it except adding "capture cracking", which I actually don't want to have. @CJNE it would be really cool, if you could check for the presence of a capture and stop logging in, if one appears and maybe even show some message. The message could tell the user to manually log into the account from the same ip and then the integration will hopefully work again after some tries.

aryanakh commented 9 months ago

Porsche does a capture every "n" (I don't know the number) logins and the integration cannot solve it, so it cannot read any more data. Then the capture comes again on the next try. If there are too many tries without solved capture, the account gets locked, which is a pretty standard fraud detection mechanism. It is the very same thing on the porsche website. I started logging into the website whenever the integration stopped working and I did nopt yet receive an "account locked" email and then after some time, the plugin continues to work, as the capture is assumed "solved" and will not show for some time. I hope this will help to understand what the issue is and why the author cannot solve it except adding "capture cracking", which I actually don't want to have. @CJNE it would be really cool, if you could check for the presence of a capture and stop logging in, if one appears and maybe even show some message. The message could tell the user to manually log into the account from the same ip and then the integration will hopefully work again after some tries.

The LG thinQ HACs does something similar. Would a web scraper or sometime solve this or perhaps what they do with the LG ThinQ integration? I wish Porsche allowed API access to this data natively...

fredriklj commented 2 months ago

We're back to square one, cf. #242 and reopen any new issues.