Dielee / volvo2mqtt

Home Assistant addon for connecting AAOS Volvos
MIT License
127 stars 25 forks source link

No working VCCAPIKEY found & Car Climate Non Functional #122

Closed Rustymage closed 7 months ago

Rustymage commented 7 months ago

Describe the bug

Trying to start the climate, I can see the car and sensors, but the car will not start.

2023 V90, UK.

s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Nov 09 18:24:12 volvo2mqtt [106] - INFO: Starting volvo2mqtt version v1.8.9
Nov 09 18:24:12 volvo2mqtt [106] - DEBUG: MQTT Credentials - Host core-mosquitto Port: 1883 User: addons Pass: ok3Cie1Ih4aezieceegh1iixeis2osheirae1aid5wai7eekieSif0ku8meigohJ
Nov 09 18:24:12 volvo2mqtt [106] - WARNING: VCCAPIKEY 7b59afaf0d5843bab53b9236cd89c824 isn't working! Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
Nov 09 18:24:12 volvo2mqtt [106] - DEBUG: [{'key': '7b59afaf0d5843bab53b9236cd89c824', 'extended': True, 'extended_until': None, 'in_use': False}]
Nov 09 18:24:12 volvo2mqtt [106] - WARNING: No working VCCAPIKEY found, waiting 10 minutes. Then trying again!

&

Nov 09 18:16:29 volvo2mqtt [106] - ERROR: API Call failed. Status Code: 401. Error: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."

&

Nov 09 18:19:13 volvo2mqtt [106] - ERROR: API Call failed. Status Code: 500. Error: {
  "error" : {
    "message" : "INTERNAL_SERVER_ERROR",
    "description" : "Error returned from car"
  }
}

To Reproduce:
Steps to reproduce the behavior:

Try to start car using toggle.

Expected behavior:

Starts car.

Screenshots:
The API key is being used....

image

Version info:
volvo2mqtt 1.8.9 Core 2023.11.1 Supervisor 2023.11.0 Operating System 11.1 Frontend 20231030.1

Logs:

Logs = Not Found via location given.

Rustymage commented 7 months ago
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Nov 09 18:24:12 volvo2mqtt [106] - INFO: Starting volvo2mqtt version v1.8.9
Nov 09 18:24:12 volvo2mqtt [106] - DEBUG: MQTT Credentials - Host core-mosquitto Port: 1883 User: addons Pass: REMOVED
Nov 09 18:24:12 volvo2mqtt [106] - WARNING: VCCAPIKEY API_KEY isn't working! Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
Nov 09 18:24:12 volvo2mqtt [106] - DEBUG: [{'key': 'API_KEY', 'extended': True, 'extended_until': None, 'in_use': False}]
Nov 09 18:24:12 volvo2mqtt [106] - WARNING: No working VCCAPIKEY found, waiting 10 minutes. Then trying again!
Nov 09 18:34:12 volvo2mqtt [106] - DEBUG: [{'key': 'API_KEY', 'extended': True, 'extended_until': None, 'in_use': False}]
Nov 09 18:34:12 volvo2mqtt [106] - DEBUG: VCCAPIKEY API_KEY works!
Nov 09 18:34:12 volvo2mqtt [106] - DEBUG: [{'key': 'API_KEY', 'extended': False, 'extended_until': None, 'in_use': False}]
Nov 09 18:34:12 volvo2mqtt [106] - INFO: Using VCCAPIKEY: API_KEY
Nov 09 18:34:12 volvo2mqtt [106] - DEBUG: [{'key': 'API_KEY', 'extended': False, 'extended_until': None, 'in_use': True}]
Traceback (most recent call last):
  File "/volvoAAOS2mqtt/main.py", line 15, in <module>
    authorize()
  File "/volvoAAOS2mqtt/volvo.py", line 55, in authorize
    get_vehicles()
  File "/volvoAAOS2mqtt/volvo.py", line 104, in get_vehicles
    raise Exception(
Exception: Error getting vehicles: 401. Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
Dielee commented 7 months ago

Your key isn't valid. Only use the primary key.

Rustymage commented 7 months ago

Your key isn't valid. Only use the primary key.

I am using the primary key - that's why I'm a little confused.

I've regenerated a new primary and I get the same issue.

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Nov 09 18:38:44 volvo2mqtt [106] - INFO: Starting volvo2mqtt version v1.8.9
Nov 09 18:38:44 volvo2mqtt [106] - DEBUG: MQTT Credentials - Host core-mosquitto Port: 1883 User: addons Pass: REMOVED
Nov 09 18:38:45 volvo2mqtt [106] - WARNING: VCCAPIKEY API_KEY_2 isn't working! Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
Nov 09 18:38:45 volvo2mqtt [106] - DEBUG: [{'key': 'API_KEY_2', 'extended': True, 'extended_until': None, 'in_use': False}]
Nov 09 18:38:45 volvo2mqtt [106] - WARNING: No working VCCAPIKEY found, waiting 10 minutes. Then trying again!
Dielee commented 7 months ago

Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application. is directly from volvo. There have to be something with the provided key.

Rustymage commented 7 months ago

I now get data with the new key and the following logs:

image
Nov 09 18:48:20 volvo2mqtt [107] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/diagnostics
Nov 09 18:48:20 volvo2mqtt [107] - DEBUG: Response status code: 200
Nov 09 18:48:20 volvo2mqtt [107] - DEBUG: {
  "data" : {
    "serviceWarning" : {
      "value" : "NO_WARNING",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "serviceTrigger" : {
      "value" : "",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "engineHoursToService" : {
      "value" : 607,
      "unit" : "h",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "distanceToService" : {
      "value" : 43077,
      "unit" : "km",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "washerFluidLevelWarning" : {
      "value" : "NO_WARNING",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "timeToService" : {
      "value" : 10,
      "unit" : "months",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    }
  }
}
Nov 09 18:48:20 volvo2mqtt [107] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/diagnostics
Nov 09 18:48:20 volvo2mqtt [107] - DEBUG: Response status code: 401
Nov 09 18:48:20 volvo2mqtt [107] - DEBUG: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Nov 09 18:48:20 volvo2mqtt [107] - ERROR: API Call failed. Status Code: 401. Error: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Nov 09 18:48:20 volvo2mqtt [107] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/diagnostics
Nov 09 18:48:20 volvo2mqtt [107] - DEBUG: Response status code: 200
Nov 09 18:48:20 volvo2mqtt [107] - DEBUG: {
  "data" : {
    "serviceWarning" : {
      "value" : "NO_WARNING",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "serviceTrigger" : {
      "value" : "",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "engineHoursToService" : {
      "value" : 607,
      "unit" : "h",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "distanceToService" : {
      "value" : 43077,
      "unit" : "km",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "washerFluidLevelWarning" : {
      "value" : "NO_WARNING",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    },
    "timeToService" : {
      "value" : 10,
      "unit" : "months",
      "timestamp" : "2023-11-09T13:06:14.484Z"
    }
  }
}
Nov 09 18:48:20 volvo2mqtt [107] - INFO: Mqtt update done. Next run in 60 seconds.

However, when I toggle climate, I don't see the endpoint https://api.volvocars.com/connected-vehicle/v1/vehicles/{vin}/commands/engine-start being called anywhere and the car does not start.

Dielee commented 7 months ago

Please check if the payload is send via MQTT under the following topic: homeassistant/switch/<your vin>_climate_status/command

Rustymage commented 7 months ago

I'm now getting this when trying to start the car with a freshly generated API key and by entering the VIN in the config:

Nov 09 19:06:07 volvo2mqtt [107] - DEBUG: Response status code: 500
Nov 09 19:06:07 volvo2mqtt [107] - DEBUG: {
  "error" : {
    "message" : "INTERNAL_SERVER_ERROR",
    "description" : "Error returned from car"
  }
}
Dielee commented 7 months ago

How do you trying to start the car with the addon ??

Rustymage commented 7 months ago

How do you trying to start the car with the addon ??

Toggle the switch to on and leave it.

Dielee commented 7 months ago

There is no switch to turn on the car...

Rustymage commented 7 months ago

There is no switch to turn on the car...

image

Is it not the climate toggle?

Dielee commented 7 months ago

Anyway...

this:

{
  "error" : {
    "message" : "INTERNAL_SERVER_ERROR",
    "description" : "Error returned from car"
  }
}

comes from volvo, if there is an internal server error, please contact volvo.

Dielee commented 7 months ago

There is no switch to turn on the car...

image

Is it not the climate toggle?

Sure, but this starts the climate, not the car engine.

Rustymage commented 7 months ago

Perhaps I'm misunderstanding start/stop climate? In the Volvo app starting climate starts the engine, is this not the case of the addon?

Dielee commented 7 months ago

Ah, your v90 is a mild hybrid ?

Rustymage commented 7 months ago

Ah, your v90 is a mild hybrid ?

Yes. a B5 V90 mild hybrid.

Dielee commented 7 months ago

Yes, then it should start the engine over the climate switch, thats right. But the API returns an error...

Rustymage commented 7 months ago

I have just tried the developer portal - https://developer.volvocars.com/apis/connected-vehicle/v1/specification/

& even that fails with the same error. Weird, as the Volvo app works...

Could it be the iOS pin/biometrics stopping it :/

Dielee commented 7 months ago

Unfortunately the Volvo app uses a whole other API which is currently unknown.

Edit: I don't think the iOS app pin/biometrics is a problem here...

Rustymage commented 7 months ago

Unfortunately the Volvo app uses a whole other API which is currently unknown.

I see - thanks for the commentary and support. I'll close as both the Volvo website API and this throw the same error so clearly an API problem.

Rustymage commented 7 months ago

V1 doesn't support 2023:

image

I see a V2 API is coming soon....

Dielee commented 7 months ago

This addon works already via V2.

timknowlden commented 5 months ago

I'm getting invalid apikey.. did you resolve? Its doing my head in. Regenerated several times, deleted and recreated developer account

Rustymage commented 5 months ago

I'm getting invalid apikey.. did you resolve? Its doing my head in. Regenerated several times, deleted and recreated developer account

What are you trying to toggle? Does it work at all?

timknowlden commented 5 months ago

I'm getting invalid apikey.. did you resolve? Its doing my head in. Regenerated several times, deleted and recreated developer account

What are you trying to toggle? Does it work at all?

I'm just trying to set up the integration

Rustymage commented 5 months ago

I'm getting invalid apikey.. did you resolve? Its doing my head in. Regenerated several times, deleted and recreated developer account

What are you trying to toggle? Does it work at all?

I'm just trying to set up the integration

What does your docker run command look like? Redact any personal info please.

timknowlden commented 5 months ago

https://github.com/Dielee/volvo2mqtt/issues/162#issuecomment-1899081312

Like the above link. Except for one using primary and not secondary vccapikey

Rustymage commented 5 months ago

The issue I had was resolved by generating a new key, testing it on the website and then loading it into volvo2mqtt - it did take a few goes. Nothing special and likely not what you want to hear.

timknowlden commented 5 months ago

The issue I had was resolved by generating a new key, testing it on the website and then loading it into volvo2mqtt - it did take a few goes. Nothing special and likely not what you want to hear.

Ive tried that, ive created extra api applications, created different accounts too via github or google logins.

I have also tried setting locale to GB, gb and en_GB.

Have you used only the primary key?

Update_interval also set to various different times and it only ever pulls on first start of docker container, it doesnt try to pull data every 300seconds or however it is defined.


Jan 21 10:28:39 volvo2mqtt [1] - WARNING: VCCAPIKEY ****REDACTED**** isn't working! Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.
Jan 21 10:28:39 volvo2mqtt [1] - DEBUG: [{'key': '****REDACTED****', 'extended': True, 'extended_until': None, 'in_use': False}]
Jan 21 10:28:39 volvo2mqtt [1] - WARNING: No working VCCAPIKEY found, waiting 10 minutes. Then trying again!
Rustymage commented 5 months ago

I only use the primary key.

Here's my compose file:

version: '3'
services:
  volvo2mqtt:
    image: ghcr.io/dielee/volvo2mqtt:latest
    env_file:
      - .env

& the .env

CONF_updateInterval=300
CONF_babelLocale='en_GB'
CONF_mqtt='@json {"broker": "{{BROKER IPV4}}", "username": "{{USERNAME}}", "{{PASSWORD}}": "password", "port": 1883}'
CONF_volvoData='@json {"username": "{{VOLVO USERNAME}}", "password": "{{VOLVO PASSWORD}}", "vin": "{{VIN NUMBER}}", "vccapikey": ["{{PRIMARY API KEY}}"], "odometerMultiplier": 1, "averageSpeedDivider": 1, "averageFuelConsumptionMultiplier": 1}'
TZ='Europe/London'
timknowlden commented 5 months ago

I only use the primary key.

Here's my compose file:

version: '3'
services:
  volvo2mqtt:
    image: ghcr.io/dielee/volvo2mqtt:latest
    env_file:
      - .env

& the .env

CONF_updateInterval=300
CONF_babelLocale='en_GB'
CONF_mqtt='@json {"broker": "{{BROKER IPV4}}", "username": "{{USERNAME}}", "{{PASSWORD}}": "password", "port": 1883}'
CONF_volvoData='@json {"username": "{{VOLVO USERNAME}}", "password": "{{VOLVO PASSWORD}}", "vin": "{{VIN NUMBER}}", "vccapikey": ["{{PRIMARY API KEY}}"], "odometerMultiplier": 1, "averageSpeedDivider": 1, "averageFuelConsumptionMultiplier": 1}'
TZ='Europe/London'

Thanks for the config, it matches mine except mine isnt in a .env file, its directly in the docker run.

Im getting entities appear now, but when i toggle the climate start, i get invalid api key returned in the log.


     "value" : 3.5,
      "unit" : "l/100km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "averageFuelConsumptionAutomatic" : {
      "value" : 3.0,
      "unit" : "l/100km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "averageSpeed" : {
      "value" : 40,
      "unit" : "km/h",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "averageSpeedAutomatic" : {
      "value" : 47,
      "unit" : "km/h",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "tripMeterManual" : {
      "value" : 6730.4,
      "unit" : "km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "tripMeterAutomatic" : {
      "value" : 17.3,
      "unit" : "km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "distanceToEmptyTank" : {
      "value" : 402,
      "unit" : "km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    }
  }
}
Jan 22 09:17:36 volvo2mqtt [1] - DEBUG: Response status code: 200
Jan 22 09:17:36 volvo2mqtt [1] - DEBUG: {
  "data" : {
    "averageFuelConsumption" : {
      "value" : 3.5,
      "unit" : "l/100km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "averageFuelConsumptionAutomatic" : {
      "value" : 3.0,
      "unit" : "l/100km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "averageSpeed" : {
      "value" : 40,
      "unit" : "km/h",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "averageSpeedAutomatic" : {
      "value" : 47,
      "unit" : "km/h",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "tripMeterManual" : {
      "value" : 6730.4,
      "unit" : "km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "tripMeterAutomatic" : {
      "value" : 17.3,
      "unit" : "km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    },
    "distanceToEmptyTank" : {
      "value" : 402,
      "unit" : "km",
      "timestamp" : "2024-01-22T09:13:10.838Z"
    }
  }
}
Jan 22 09:17:36 volvo2mqtt [1] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/diagnostics
Jan 22 09:17:36 volvo2mqtt [1] - DEBUG: Response status code: 401
Jan 22 09:17:36 volvo2mqtt [1] - DEBUG: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Jan 22 09:17:36 volvo2mqtt [1] - ERROR: API Call failed. Status Code: 401. Error: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Rustymage commented 5 months ago

What car do you have? Apparently climate start doesn't work on most vehicles - hence the issue.

If you delete the volume/container and any MQTT entities before starting again and see if it reappears.

Either way, it doesn't work on my B5 (Petrol) V90 2023.

timknowlden commented 5 months ago

What car do you have? Apparently climate start doesn't work on most vehicles - hence the issue.

If you delete the volume/container and any MQTT entities before starting again and see if it reappears.

Either way, it doesn't work on my B5 (Petrol) V90 2023.

I have an XC60 b5 petrol 2022. That is a shame, I can start the car on the volvo api sandbox site. Ideally thats the only one featured im really interested in being able to put to use, Starting the car based on wake up alarms and temperatures etc.

I have tried regenerating the Key now around 10 times, so hopefully once it decides it is a valid key ill have some functionality.

Rustymage commented 5 months ago

Check out https://github.com/Dielee/volvo2mqtt/issues/118

timknowlden commented 5 months ago

Check out #118

Ive had a brief read. If the volvo sandbox can lock/unlock and start the car then im sure it can be integrated, im getting more entities now, but waiting to test later if climate start works (wife uses the car more than me)

Rustymage commented 5 months ago

It won't work - the app is missing a certain scope requirement for API usage.

https://github.com/Dielee/volvo2mqtt/issues/118#issuecomment-1823315746

Not 100% if it's being worked or can be worked.

timknowlden commented 5 months ago
image

Still errors in the log, but thats more promising.


Jan 22 15:45:22 volvo2mqtt [1] - DEBUG: Response status code: 200
Jan 22 15:45:22 volvo2mqtt [1] - DEBUG: {
  "data" : {
    "frontLeft" : {
      "value" : "NO_WARNING",
      "timestamp" : "2024-01-22T15:29:08.274Z"
    },
    "frontRight" : {
      "value" : "NO_WARNING",
      "timestamp" : "2024-01-22T15:29:08.274Z"
    },
    "rearLeft" : {
      "value" : "NO_WARNING",
      "timestamp" : "2024-01-22T15:29:08.274Z"
    },
    "rearRight" : {
      "value" : "NO_WARNING",
      "timestamp" : "2024-01-22T15:29:08.274Z"
    }
  }
}
Jan 22 15:45:22 volvo2mqtt [1] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/diagnostics
Jan 22 15:45:22 volvo2mqtt [1] - DEBUG: Response status code: 401
Jan 22 15:45:22 volvo2mqtt [1] - DEBUG: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Jan 22 15:45:22 volvo2mqtt [1] - ERROR: API Call failed. Status Code: 401. Error: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Jan 22 15:45:22 volvo2mqtt [1] - DEBUG: Starting GET call against https://api.volvocars.com/connected-vehicle/v2/vehicles/{0}/diagnostics
Jan 22 15:45:22 volvo2mqtt [1] - DEBUG: Response status code: 401
Jan 22 15:45:22 volvo2mqtt [1] - DEBUG: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Jan 22 15:45:22 volvo2mqtt [1] - ERROR: API Call failed. Status Code: 401. Error: {  
                        "status": 401,
                        "error": {  
                            "message": "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
                        }
                    }
Jan 22 15:45:22 volvo2mqtt [1] - INFO: Mqtt update done. Next run in 300 seconds.
timknowlden commented 5 months ago

It won't work - the app is missing a certain scope requirement for API usage.

#118 (comment)

Not 100% if it's being worked or can be worked.

Ah yes, you are correct, just tested and it doesn't. Such a shame on volvo's part creating an android automotive product, thats so isolated from anything smart!