cyr-ius / hass-audiconnect

Adds an audi connect integration to home assistant
MIT License
32 stars 4 forks source link

Q4 Stuff missing/not working (model 2024) #86

Closed pergolafabio closed 3 months ago

pergolafabio commented 3 months ago

Describe the bug Hi @cyr-ius , i got a new Q4 model 2024 this week, testing your fork, since the original fork doesnt provide all sensors, seems yours can do more First of all, i see the doors/windows/trunk status "open" while its closed? CLimater start/stop doesnt work, see error below

2024-07-24 09:01:56.957 ERROR (MainThread) [custom_components.audiconnect.services] ('Service not found: %s -%s (%s)', 'https://fal-3a.prd.eu.dp.vwg-connect.com/fs-car/bs/climatisation/v1/Audi/BE/vehicles/XXXX/climater/actions', {'error': {'errorCode': 'climatisation.auth.forbidden', 'description': 'The referenced vehicle with VIN: XXXXcould not be found or has no association to the given User'}}, 403)

Location doesnt work, see error below:

2024-07-24 09:05:50.756 ERROR (MainThread) [homeassistant.components.device_tracker] Error adding entity device_tracker.audi_q4_e_tron_position for domain device_tracker with platform audiconnect
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 912, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1362, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1007, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1133, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1068, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1013, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/device_tracker/config_entry.py", line 237, in state
    if self.latitude is not None and self.longitude is not None:
       ^^^^^^^^^^^^^
  File "/config/custom_components/audiconnect/device_tracker.py", line 42, in latitude
    return self.vehicle.position.latitude
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'latitude'

Additional context I have Frida enabled on my Laptop, so i can sniff/trace the API from the myAudi app, i think some endpoints are changed... For climate start/stop for example, i see below:

https://emea.bff.cariad.digital/vehicle/v1/vehicles/xxx/climatisation/start

with request

{
  "targetTemperature": 22,
  "targetTemperatureUnit": "celsius",
  "climatisationWithoutExternalPower": true,
  "climatizationAtUnlock": false,
  "windowHeatingEnabled": false,
  "zoneFrontLeftEnabled": false,
  "zoneFrontRightEnabled": false,
  "zoneRearLeftEnabled": false,
  "zoneRearRightEnabled": false
}

for stop:

https://emea.bff.cariad.digital/vehicle/v1/vehicles/xxx/climatisation/stop

For response:

https://emea.bff.cariad.digital/vehicle/v1/vehicles/XXX/pendingrequests

with response:

{
  "data": [
    {
      "id": "8cf8437d-94a5-49fa-9b12-60ea1bd9c2c3",
      "userId": "0e0f02f7-620c-42e5-87d3-35d76f700a75",
      "vin": "XXXX",
      "httpMethod": "POST",
      "path": "/vehicles/XXXX/climatisation/start",
      "capability": "climatisation",
      "operation": "start",
      "operationGroup": "climatisation",
      "body": "{\"callback\":\"https://emea.bff.cariad.digital/vehicle/v1/vehicles/callbacks/XXXX/climatisation/start/POST\",\"climatisationWithoutExternalPower\":true,\"targetTemperature\":21,\"targetTemperatureUnit\":\"celsius\",\"climatizationAtUnlock\":false,\"windowHeatingEnabled\":false,\"zoneFrontLeftEnabled\":false,\"zoneFrontRightEnabled\":false}",
      "vcfRequestId": "ad460379-da19-443d-bec9-58818ef275ef",
      "status": "in_progress",
      "queuedOperation": null,
      "timestamp": "2024-07-24T11:35:03.723443436Z"
    },
    {
      "id": "ab1cef0e-d047-4fba-9dc3-b3b6691a6336",
      "userId": "0e0f02f7-620c-42e5-87d3-35d76f700a75",
      "vin": "XXX",
      "httpMethod": "PUT",
      "path": "/vehicles/XXXX/climatisation/settings",
      "capability": "climatisation",
      "operation": "settings",
      "operationGroup": "climatisationSettings",
      "body": "{\"callback\":\"https://emea.bff.cariad.digital/vehicle/v1/vehicles/callbacks/XXX/climatisation/settings/PUT\",\"climatisationWithoutExternalPower\":true,\"targetTemperature\":21,\"targetTemperatureUnit\":\"celsius\",\"climatizationAtUnlock\":false,\"windowHeatingEnabled\":false,\"zoneFrontLeftEnabled\":false,\"zoneFrontRightEnabled\":false}",
      "vcfRequestId": "94f83793-6c2d-43ce-9f6f-95098b372d53",
      "status": "successful",
      "queuedOperation": null,
      "timestamp": "2024-07-24T11:30:13.249758808Z"
    }
  ]
}

eventually:

"status": "successful",

@moritzwiechers : What is still working/nor working for you?

pergolafabio commented 3 months ago

The Wakeup/refresh doesnt work either, i get 404 errors ... I can help you with the new endpoints if you want ..., just tell me what you need? WHat car do you have btw?

pergolafabio commented 3 months ago

For the door status, i see the Q4 entities are unsupported in the diag file, however, the overal doorlock is "locked", see below, in diag file, but the entitty itself says "unlocked"

        "async_get_selectivestatus": {
          "access": {
            "accessStatus": {
              "value": {
                "overallStatus": "safe",
                "carCapturedTimestamp": "0001-01-01T00:00:00Z",
                "doors": [
                  {
                    "name": "bonnet",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "trunk",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "rearRight",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "rearLeft",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "frontRight",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "frontLeft",
                    "status": [
                      "unsupported"
                    ]
                  }
                ],
                "windows": [
                  {
                    "name": "sunRoof",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "roofCover",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "sunRoofRear",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "frontLeft",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "frontRight",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "rearLeft",
                    "status": [
                      "unsupported"
                    ]
                  },
                  {
                    "name": "rearRight",
                    "status": [
                      "unsupported"
                    ]
                  }
                ],
                "doorLockStatus": "locked"
              }
            }
          },

image

Tough i see in the appn the states of windows/doors/ ... not sure where its coming from...

image

pergolafabio commented 3 months ago

Also usefull, command to set the climate temp, seems different also? here is from toolkit...

URL:

https://emea.bff.cariad.digital/vehicle/v1/vehicles/XXX/climatisation/settings

Request:

{
  "targetTemperature": 21,
  "targetTemperatureUnit": "celsius",
  "climatisationWithoutExternalPower": true,
  "climatizationAtUnlock": false,
  "windowHeatingEnabled": false,
  "zoneFrontLeftEnabled": false,
  "zoneFrontRightEnabled": false
}

After fort state if succesfull:

https://emea.bff.cariad.digital/vehicle/v1/vehicles/WAUZZZFZ9RP076552/pendingrequests

response:

{
  "data": [
    {
      "id": "ab1cef0e-d047-4fba-9dc3-b3b6691a6336",
      "userId": "0e0f02f7-620c-42e5-87d3-35d76f700a75",
      "vin": "XXXX",
      "httpMethod": "PUT",
      "path": "/vehicles/XXXX/climatisation/settings",
      "capability": "climatisation",
      "operation": "settings",
      "operationGroup": "climatisationSettings",
      "body": "{\"callback\":\"https://emea.bff.cariad.digital/vehicle/v1/vehicles/callbacks/XXXX/climatisation/settings/PUT\",\"climatisationWithoutExternalPower\":true,\"targetTemperature\":21,\"targetTemperatureUnit\":\"celsius\",\"climatizationAtUnlock\":false,\"windowHeatingEnabled\":false,\"zoneFrontLeftEnabled\":false,\"zoneFrontRightEnabled\":false}",
      "vcfRequestId": "94f83793-6c2d-43ce-9f6f-95098b372d53",
      "status": "in_progress",
      "queuedOperation": null,
      "timestamp": "2024-07-24T11:30:13.249758808Z"
    }
  ]
}

After a few, the status changes to:

"status": "successful",

jlatvala commented 3 months ago

@pergolafabio Just FYI, the "original" Audi integration (https://github.com/audiconnect/audi_connect_ha ) works with my 2023 Q4. At least I can see 39 entities. Maybe restarting HA after logging in into Audi integration will solve your problems too? I have newer tried any services, not sure if they work.

The only problem with that integration (and with other Audi/Audi Q4 integrations I have tested) is that it loses the connection to the Audi servers after some days (I suppose, re-authentication is needed, haven't checked though). I know when this happens because Q4 location updates don't work anymore. Then I need to restart HA and everything works again few days. Luckily there are HA upgrades few times a month, and for me it is usually often enough to keep my Audi connection live.

pergolafabio commented 3 months ago

Hey, i started with that one, but i dont get 39 entities at all , jus a few also climate/door status doesnt work, gps location is missing

What model of car do you have? i have a 2024 model, brand new, maybe stuff is changed ? My endpoints are different if i sniff the app , i also see 404 errors when i use this or the other fork, so audi must have changed something

cyr-ius commented 3 months ago

ok, I'll do that for you next week

pergolafabio commented 3 months ago

ok, I'll do that for you next week

Let me know if you need more info/endpoints? Maybe its only needed for 2024 models? not sure

pergolafabio commented 3 months ago

@pergolafabio Just FYI, the "original" Audi integration (https://github.com/audiconnect/audi_connect_ha ) works with my 2023 Q4. At least I can see 39 entities. Maybe restarting HA after logging in into Audi integration will solve your problems too? I have newer tried any services, not sure if they work.

The only problem with that integration (and with other Audi/Audi Q4 integrations I have tested) is that it loses the connection to the Audi servers after some days (I suppose, re-authentication is needed, haven't checked though). I know when this happens because Q4 location updates don't work anymore. Then I need to restart HA and everything works again few days. Luckily there are HA upgrades few times a month, and for me it is usually often enough to keep my Audi connection live.

for info, if i use that integration, i can only see these entities...

image

jlatvala commented 3 months ago

My Q4 is model year 2023.

audi_connect_ha integration is more active nowadays, they implemented support for Q4 (at least for older model years) few months ago. Maybe you want to ask if they want to add support for 2024 Q4 so that there would be only one common audi integration?

My diagnostics part has more entities (mainly related to doors, windows and position): q4temp

image

pergolafabio commented 3 months ago

Yeah, i also have a issue open there to provide more info about the API , probably something changed in API for 2023 vs 2024 models What i'm missing in your sensor list , is the climate state? like "off"/ "heating" ? ... ? do you also have the "device" entity with GPS coordinates?

Where are you located btw?

jlatvala commented 3 months ago

I can't find anything related to the climate, but I have this: image

My position entity has latitude and longitude as attributes.

And the location is Finland.

pergolafabio commented 3 months ago

Can you do a remote lock/unlock? I don't have that feature on my car... The climate state is possible in the fork, I request to add it also on the other integration

jlatvala commented 3 months ago

Can you do a remote lock/unlock?

As far as I know lock/unlock has never been possible for Q4 using myAudi app. I just tested unlocking via HA and didn't work: Unable to unlock xxx: object of type 'NoneType' has no len()

Also start climatisation (as a service call 'Audi Connect: Execute Vehicle Action') did not work (404, ...vwg-connect.com)

pergolafabio commented 3 months ago

yeah, they are also fixning it now in this fork : https://github.com/audiconnect/audi_connect_ha

they already fixed the climatisation state already, that wasnt working either

pergolafabio commented 3 months ago

quick update , my GPS location is now working, seems an issue with my license!

pergolafabio commented 3 months ago

hey @cyr-ius , you dont need to add it here, its already be worked on in the official repo once added there, maybe you can compare the code to integrate it later, so you know the other endpoints as well for other regions.., gonna close here