audiconnect / audi_connect_ha

Adds an audi connect integration to home assistant
MIT License
231 stars 96 forks source link

Login to Audi service failed: 503, message='Service Unavailable', url=URL('https://app-api.live-my.audi.com/azs/v1/token' #94

Closed titiviking closed 2 years ago

titiviking commented 2 years ago

2021-11-26 10:50:56 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] Login to Audi service failed, trying again in 10 seconds 2021-11-26 10:51:16 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] Login to Audi service failed, trying again in 10 seconds 2021-11-26 10:51:28 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] Login to Audi service failed: 503, message='Service Unavailable', url=URL('https://app-api.live-my.audi.com/azs/v1/token') 2021-11-26 11:00:02 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] Login to Audi service failed, trying again in 10 seconds 2021-11-26 11:00:13 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] Login to Audi service failed, trying again in 10 seconds 2021-11-26 11:00:25 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] Login to Audi service failed: 503, message='Service Unavailable', url=URL('https://app-api.live-my.audi.com/azs/v1/token')

Debug of custom component does not provide more details... HTTP component neither.

providing URL directly in browser does render some error response: no healthy upstream

I have no clue though if it can be fixed through code by providing a new/correct endpoint, or if the problem is at audi side...

derhappy commented 2 years ago

Same here, just as I restarted HA after an update. Login with the credentials in browser and app is working fine

same issue here: https://github.com/davidgiga1993/AudiAPI/issues/13

derhappy commented 2 years ago

BTW, the official way to connect to audi is described here (but very useless, just one update per week is allowed). However, I can't figure out if the document contains some useful information for our use case: https://www.audi.de/dam/nemo/extended-vehicle/ExVe_Technical_Integration_Guide.pdf

JimRnewell commented 2 years ago

same here after a restart today, was fine before

user45876 commented 2 years ago

Unfortunately i have to confirm the issue.

moorboss commented 2 years ago

Same here

tornenen commented 2 years ago

same here

mdshw5 commented 2 years ago

Same. It would be wonderful (and too much to ask) for VW/Audi to give developers API access to their telematics services.

Segran commented 2 years ago

It has been like that for a few days now, since I upgraded to HA 2021.5.

Puppetmaster91 commented 2 years ago

Same error as well, just watching this for a fix

pilot1981 commented 2 years ago

Audi developer changed again API services without any type of communication!

derhappy commented 2 years ago

Well, of course they do. What we use here is not exactly approved by Audi to phrase it carefully ;-) I guess they sell this data instead.

unexxx commented 2 years ago

Same.

PuckeyP commented 2 years ago

Same here. Watching this for a work around...

t0bias-r commented 2 years ago

see #95

user45876 commented 2 years ago

Thank you so much, @t0bias-r !

However, I copied the four changed files into the appropriate folder in HA (twice) and restarted (twice) - for me, it is still giving an error when adding the integration:

On the first try: Ungültige Anmeldeinformationen

Second try: User input malformed

In HA, this is logged: Logger: homeassistant.util.async Source: util/async.py:132 First occurred: 17:37:47 (3 occurrences) Last logged: 17:54:58

Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for audiconnect doing I/O at custom_components/audiconnect/audi_services.py, line 612: markets_rsp = idkproxy_session.get(

Sorry, if I am holding it wrong.

derhappy commented 2 years ago

Thanks for your investigation and quite extensive rewrite @t0bias-r ! Unfortunately I also get the authentication error, both with a limited and the main user. Both are working on the website. It does not make any difference if I provide a region or not (I guess because DE is default in coding). I don't get anything in the logs, but this might be due to the log level I set.

t0bias-r commented 2 years ago

What happens if you run the test.py instead?

derhappy commented 2 years ago

xxx@i3serv:/usr/share/hassio/homeassistant/custom_components$ python3 test.py Traceback (most recent call last): File "test.py", line 5, in from audiconnect.audi_connect_account import AudiConnectAccount File "/usr/share/hassio/homeassistant/custom_components/audiconnect/init.py", line 3, in import voluptuous as vol ModuleNotFoundError: No module named 'voluptuous'

Edit: I resolved the dependencies, but now test.py will not even accept the parameters. Seems like I'm becoming old. python3 test.py --user "x.y@web.de" --password "my-super-password" --spin "9876" --country "DE"

t0bias-r commented 2 years ago

hm...🤔 it seems that there is an issue in test.py. pls change from task = main(main(sys.argv[1:])) to task = main(sys.argv[1:]) and try again

t0bias-r commented 2 years ago

I personally don't use home assistant. I just use the code as a systemd service that forwards the received values using Telnet/SSH to a different home automation system. That means testing on my side is limited. But what I got from the error message is, that Requests class seems to be not usable in that way. So I changed the code to use aiohttp requests provided by AudiAPI class instead of Requests class.

user45876 commented 2 years ago

Thanks again, @t0bias-r . I can confirm that the Login is now working again with the HA integration. There is one small issue, though, that the name and model used to be the same as in the myAudi app - this is now empty.

So now the entities in HA are called 'none'. Does this make sense? I know you do not use HA, but the model / name parameter, which was filled before, seems to be empty now. Does that make any sense? ;)

t0bias-r commented 2 years ago

That made sense, yes. I changed the graphql query to retrieve more information --> see new commit.

Beside renderings and technical specs, the following items can be queried:

  "data": {
    "userVehicles": [
      {
        "vin": "WAUZxxxxxxxx",
        "mappingVin": "WAUZxxxxxxxx",
        "csid": "%csid%",
        "commissionNumber": null,
        "devicePlatform": "MBB",
        "mbbConnect": true,
        "userRole": {
          "role": "PRIMARY_USER"
        },
        "vehicle": {
          "classification": {
            "driveTrain": "PHEV"
          }
          "core": {
            "modelYear": 2020,
            "modelCoding": "4KA0WY"
          },
          "hifa": {
            "factoryPickupDateFrom": "2020-xx-yyT06:00:00.000+00:00",
            "factoryPickupDateTill": "2020-xx-yyT08:00:00.000+00:00",
            "fbDestination": "DEU760   B"
          },
          "media": {
            "shortName": "Audi A7 Sportback TFSI e",
            "longName": "Audi A7 Sportback TFSI e 50 TFSI e quattro S tronic"
          },
          "pdw": {
            "pdwVehicle": false
          },
        },
        "nickname": null
      }
    ]
  }
Gunth commented 2 years ago

It is working back also for me in HA, just have somme errors in my logs about support_preheater, support_charger and support_climater. Don't have those options in my car that's maybe the reason ... image

user45876 commented 2 years ago

I have to say that I am struggling - I can not add it anymore, no device and entities get made in HA. This is the error that is logged. I double checked and replaced the new files (2):


Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: homeassistant.config_entries Source: custom_components/audiconnect/audi_models.py:133 Integration: Audi Connect First occurred: 10:21:24 (1 occurrences) Last logged: 10:21:24

Error setting up entry
for audiconnect Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/audiconnect/init.py", line 106, in async_setup_entry return await data.update(utcnow()) File "/config/custom_components/audiconnect/audi_account.py", line 162, in update if not await self.connection.update(None): File "/config/custom_components/audiconnect/audi_connect_account.py", line 113, in update vehicles_response = await self._audi_service.get_vehicle_information() File "/config/custom_components/audiconnect/audi_services.py", line 260, in get_vehicle_information response.parse(vins["data"]) File "/config/custom_components/audiconnect/audi_models.py", line 149, in parse vehicle.parse(item) File "/config/custom_components/audiconnect/audi_models.py", line 133, in parse self.title = nickname NameError: name 'nickname' is not defined

sorry for the big font :-/

derhappy commented 2 years ago

It's in the parent folder. You have to manually download it if you want to use it. If you're running supervised (in Docker), you'll have to resolve some dependencies before you can use it (pip install xxx).

Danke @t0bias-r, for me it's working fine again with those changes done by you! grafik

derhappy commented 2 years ago

I have to say that I am struggling - I can not add it anymore, no device and entities get made in HA. This is the error that is logged. I double checked and replaced the new files (2):

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: homeassistant.config_entries Source: custom_components/audiconnect/audi_models.py:133 Integration: Audi Connect First occurred: 10:21:24 (1 occurrences) Last logged: 10:21:24

Error setting up entry for audiconnect

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup result = await component.async_setup_entry(hass, self) # type: ignore File "/config/custom_components/audiconnect/init.py", line 106, in async_setup_entry return await data.update(utcnow()) File "/config/custom_components/audiconnect/audi_account.py", line 162, in update if not await self.connection.update(None): File "/config/custom_components/audiconnect/audi_connect_account.py", line 113, in update vehicles_response = await self._audi_service.get_vehicle_information() File "/config/custom_components/audiconnect/audi_services.py", line 260, in get_vehicle_information response.parse(vins["data"]) File "/config/custom_components/audiconnect/audi_models.py", line 149, in parse vehicle.parse(item) File "/config/custom_components/audiconnect/audi_models.py", line 133, in parse self.title = nickname NameError: name 'nickname' is not defined

sorry for the big font :-/

You'll have to manually change / copy all 4 files from the commit (ignore test.py). Or wait until @arjenvrh merged it and there's an update in HACS. Then restart HA and it should work.

user45876 commented 2 years ago

@derhappy I replaced all 4 files before, sure. Then i replaced the 2 newly changed. I even replaced all 4 again to double check ;) Which dependencies are you referring to?

t0bias-r commented 2 years ago

I fixed the nickname issue. sorry for that.

derhappy commented 2 years ago

The dependencies only come up when you try to execute test.py "outside" of your HA environment.

PS: Now i've got this error message too: support_preheater set to False: 502 Logger: custom_components.audiconnect.audi_connect_account Source: custom_components/audiconnect/audi_connect_account.py:557 Integration: Audi Connect

user45876 commented 2 years ago

@t0bias-r should there be a new commit?

t0bias-r commented 2 years ago

@t0bias-r should there be a new commit?

This commit https://github.com/arjenvrh/audi_connect_ha/pull/95/commits/ef91bf081d75e39dbc865227b50f0f5199ae86ef / https://github.com/t0bias-r/audi_connect_ha/commit/ef91bf081d75e39dbc865227b50f0f5199ae86ef fixes this error:

File "/config/custom_components/audiconnect/audi_models.py", line 133, in parse
self.title = nickname
NameError: name 'nickname' is not defined
user45876 commented 2 years ago

Yes, with this, for me everything is working again, thank you very much again, @t0bias-r . Your efforts are very much appreciated :) (For the life of me I could not see the commit in the history - maybe it only took some more time.)

JimRnewell commented 2 years ago

thank you, everything is back working again

pilot1981 commented 2 years ago

@t0bias-r should there be a new commit?

This commit ef91bf0 / t0bias-r@ef91bf0 fixes this error:

File "/config/custom_components/audiconnect/audi_models.py", line 133, in parse
self.title = nickname
NameError: name 'nickname' is not defined

I don't have any "nickname" in audi_models.py

t0bias-r commented 2 years ago

@t0bias-r should there be a new commit?

This commit ef91bf0 / t0bias-r@ef91bf0 fixes this error:

File "/config/custom_components/audiconnect/audi_models.py", line 133, in parse
self.title = nickname
NameError: name 'nickname' is not defined

I don't have any "nickname" in audi_models.py

Look at this commit ef91bf0 / t0bias-r@ef91bf0 and ensure that your audi_models.py is up-to-date grafik

SchwarzAxel commented 2 years ago

The dependencies only come up when you try to execute test.py "outside" of your HA environment.

PS: Now i've got this error message too: support_preheater set to False: 502 Logger: custom_components.audiconnect.audi_connect_account Source: custom_components/audiconnect/audi_connect_account.py:557 Integration: Audi Connect

same here

2021-12-03 20:59:53 ERROR (MainThread) [custom_components.audiconnect.util] Unable to start pre-heater of vehicle wauzzzf22mn075394: 502, message='Bad Gateway', url=URL('https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/rs/v1/Audi/DE/vehicles/WAUZZZXXXXXXXXX/action')

pilot1981 commented 2 years ago

How I can force to update it on HA?

adam760222 commented 2 years ago

Thanks again, @t0bias-r . I can confirm that the Login is now working again with the HA integration. There is one small issue, though, that the name and model used to be the same as in the myAudi app - this is now empty.

So now the entities in HA are called 'none'. Does this make sense? I know you do not use HA, but the model / name parameter, which was filled before, seems to be empty now. Does that make any sense? ;)

Can you please explain how you did it, as I still have Invalid credentials info when try to add integration...

user45876 commented 2 years ago

I replaced the 4 recently changed files from t0bias latest commit in the audiconnect folder on ha. You can also wait, until @arjenvrh merges the pull request and then update via hacs, restart ha and be done.

vj80 commented 2 years ago

Has anyone gotten this to work in the US?

t0bias-r commented 2 years ago

Thanks again, @t0bias-r . I can confirm that the Login is now working again with the HA integration. There is one small issue, though, that the name and model used to be the same as in the myAudi app - this is now empty. So now the entities in HA are called 'none'. Does this make sense? I know you do not use HA, but the model / name parameter, which was filled before, seems to be empty now. Does that make any sense? ;)

Can you please explain how you did it, as I still have Invalid credentials info when try to add integration...

I captured the network traffic of the latest Android myAudi app. Then I did some crypto analysis to understand which headers and requests are required

To me it looks like that Audi has changed all APIs not only the login. E.g. the API to enable/disable the climater is completely different to the current implemenation. I suspect that sooner or later these APIs will be disabled, too and have to be re-programmed.

thorsten commented 2 years ago

The location doesn't return anything with the patch from @t0bias-r, everything else is currently working.

adam760222 commented 2 years ago

I replaced the 4 recently changed files from t0bias latest commit in the audiconnect folder on ha. You can also wait, until @arjenvrh merges the pull request and then update via hacs, restart ha and be done.

ok, so:

  1. Replace 4 files in audiconnect folder
  2. Add integration into Configuration -> Integration
  3. insert Audi login data

For me I got invalid credential info.

t0bias-r commented 2 years ago

The dependencies only come up when you try to execute test.py "outside" of your HA environment. PS: Now i've got this error message too: support_preheater set to False: 502 Logger: custom_components.audiconnect.audi_connect_account Source: custom_components/audiconnect/audi_connect_account.py:557 Integration: Audi Connect

same here

2021-12-03 20:59:53 ERROR (MainThread) [custom_components.audiconnect.util] Unable to start pre-heater of vehicle wauzzzf22mn075394: 502, message='Bad Gateway', url=URL('https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/rs/v1/Audi/DE/vehicles/WAUZZZXXXXXXXXX/action')

To me it looks like that Audi has changed all APIs not only the login. E.g. the API to enable/disable the climater is completely different to the current implemenation. I suspect that sooner or later these APIs will be disabled, too and have to be re-programmed. Currently, enabling the climater does not work on my Audi, too. I just can stop it.

t0bias-r commented 2 years ago

Has anyone gotten this to work in the US?

I've added a piece of code for US support. Please try after applying these changes: https://github.com/t0bias-r/audi_connect_ha/commit/2ade26f26972139e7b3f34d7ab2c6570616588b2

user45876 commented 2 years ago

I replaced the 4 recently changed files from t0bias latest commit in the audiconnect folder on ha. You can also wait, until @arjenvrh merges the pull request and then update via hacs, restart ha and be done.

ok, so:

  1. Replace 4 files in audiconnect folder
  2. Add integration into Configuration -> Integration
  3. insert Audi login data

For me I got invalid credential info.

Have you restarted HA? I also deleted the pycache files for good measure but I think that does absolutely nothing 😉

adam760222 commented 2 years ago

I replaced the 4 recently changed files from t0bias latest commit in the audiconnect folder on ha. You can also wait, until @arjenvrh merges the pull request and then update via hacs, restart ha and be done.

ok, so:

  1. Replace 4 files in audiconnect folder
  2. Add integration into Configuration -> Integration
  3. insert Audi login data

For me I got invalid credential info.

Have you restarted HA? I also deleted the pycache files for good measure but I think that does absolutely nothing 😉

Thanks! After restart works fine. Just I have missed oil level entitie, do you have the same?

Segran commented 2 years ago

Thanks for the "fix", it looks like a total re-write.

I still get these 2 errors: 2021-12-04 10:35:46 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] support_climater set to False: 403 2021-12-04 10:35:46 ERROR (MainThread) [custom_components.audiconnect.audi_connect_account] support_charger set to False: 403

Why?

titiviking commented 2 years ago

I got those too. My guess is that the API attempt to discover all functionalities, and that those are unavailable for your car.

I'm ignoring those as I don't have preheat or charger anyway, so even on error I don't care about it.

Segran commented 2 years ago

I don't have a support_charger, so that may be a correct error, but I do have a heater - or is it a heater that exists only in e-cars?