Closed edsub closed 9 months ago
Indeed has nothing to do with the plug-in.
just creating an api key is enough. My own api key is also not published and works fine
Most likely cause is a typo in the vcc-api-key
It def. is not a typo (long live copy/paste). I get the same error when testing via Postman so there is a consistency here This is my 'full' debug log from your plugin (sensitive strings replaced by 'xyz'):
2024-01-30 23:07:57.833 Status: VolvoCars: Started.
2024-01-30 23:07:57.833 Status: VolvoCars: Entering work loop.
2024-01-30 23:07:58.497 VolvoCars: Debug logging mask set to: PYTHON PLUGIN QUEUE IMAGE DEVICE CONNECTION MESSAGE
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'HardwareID':'22'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'HomeFolder':'/home/pi/domoticz/plugins/Domoticz_VolvoRecharge_Plugin/'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'StartupFolder':'/home/pi/domoticz/'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'UserDataFolder':'/home/pi/domoticz/'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Database':'/home/pi/domoticz/domoticz.db'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Language':'en'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Version':'0.1.0'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Author':'akamming'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Name':'VolvoCars'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Port':'0'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Username':'xyz@gmail.com'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Password':'xyz'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Key':'VolvoEV'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Mode1':'xyz'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Mode2':'900'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'Mode6':'-1'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'DomoticzVersion':'2023.2 (build 15727)'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'DomoticzHash':'e4b171fff'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: 'DomoticzBuildTime':'2023-12-15 08:05:33'
2024-01-30 23:07:58.497 VolvoCars: DEBUG: Device count: 0
2024-01-30 23:07:58.497 VolvoCars: DEBUG: len=1
2024-01-30 23:07:58.497 VolvoCars: DEBUG: Heartbeat() called
2024-01-30 23:07:58.497 VolvoCars: DEBUG: Nog logged in, attempting to login
2024-01-30 23:07:58.497 VolvoCars: DEBUG: LoginToVOC() called
2024-01-30 23:07:58.495 Status: VolvoCars: Initialized version 0.1.0, author 'akamming'
2024-01-30 23:07:59.033 VolvoCars: DEBUG: b'{"access_token":"xyz","refresh_token":"xyz","token_type":"Bearer","expires_in":1799}'
2024-01-30 23:07:59.033 VolvoCars: INFO: Login successful!
2024-01-30 23:07:59.033 VolvoCars: DEBUG: GetVin called
2024-01-30 23:07:59.033 VolvoCars: DEBUG: VolvoAPI(https://api.volvocars.com/connected-vehicle/v2/vehicles,application/json) called
2024-01-30 23:07:59.500 VolvoCars: DEBUG:
2024-01-30 23:07:59.500 Result:
2024-01-30 23:07:59.500 VolvoCars: DEBUG: <Response [401]>
2024-01-30 23:07:59.500 VolvoCars: ERROR: VolvoAPI failed calling https://api.volvocars.com/connected-vehicle/v2/vehicles, HTTP Statuscode 401
2024-01-30 23:07:59.502 VolvoCars: ERROR: Reponse: {'status': 401, 'error': {'message': 'Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application.'}}
2024-01-30 23:07:59.503 VolvoCars: DEBUG: No vin, do nothing
2024-01-30 23:07:59.503 VolvoCars: Acquiring GIL for 'onStartCallback'
2024-01-30 23:08:05.059 VolvoCars: Pushing 'onStopCallback' on to queue
2024-01-30 23:08:05.059 VolvoCars: Processing 'onStopCallback' message
2024-01-30 23:08:05.059 VolvoCars: Acquiring GIL for 'onStopCallback'
2024-01-30 23:08:05.059 VolvoCars: Calling message handler 'onStop' on 'module' type object.
2024-01-30 23:08:05.059 VolvoCars: DEBUG: onStop called
2024-01-30 23:08:05.059 Status: VolvoCars: Stop directive received.
2024-01-30 23:08:05.152 Status: VolvoCars: Exiting work loop.
2024-01-30 23:08:05.159 Status: VolvoCars: Stopping threads.
2024-01-30 23:08:05.159 Status: VolvoCars: Stopped.
There is one thing that puzzles me: I have registered at the dev portal with a different email than my VolvoID email. Within that account I registered my application (vcc-api-key) The access token however is generated based on the VolvoID How does the Volvo Connected Car api know that my vcc-api-key 'belongs' to my VolvoID ? Or am I overlooking something now?
Note: on https://community.home-assistant.io/t/volvo2mqtt-connect-your-aaos-volvo/585699/217?page=9 I read that the registration of the vcc-api-key might take a few days. Anyone else have that expereince as well ? Because that could be a good explanantion . . . .
hmmm.... just did a test by creating a new API key. @first i tought something had changed, cause i had the same issue as you . But a bit later it started working. So apparently indeed it does take some time..
The connected car api is not (and does not have to be linked to your car).
What happens that because the plugin logs in using your volvo id credentials, it has access to your car sensors using the different APIs. Your own API key is just your right to do max 10k calls per day at Volvo for yourself.
It seemed to have taken about 3 days for my API key too get ' activated'. Today things started to work. Unfortunately I accidentally clicked once again on 'add' when I wanted to ' update' the plugin which seemed to have created a duplicate entity in the Domoticz DB that made the plugin crash. As a result, after that happened no data updates reached Domoticz anymore. I also noticed before the crash only ' conventional car' info (maintenance, tyre pressure, etc) and no EV specific info was in Domoticz I fixed the crashes from the duplicate plugin by deleting it and re-installing. Happy days. So now info comes in again, BUT: Now is is just the EV specific info (in ' Utilities') plus the Climatisation (in ' Switches' ). Can it take some time for the other info to be submitted by the car /the vcc systems?
Time is the answer (at least partly):
@akamming Is there a specific reason why you categorized a lot of sensors (ie devices the user cannot change) categorized as 'Switch' ? If I had my choice (might fork and hive it a try ;-) ) I would have chosen for something else (eg Text or Custom Sensor) . . .
I registered myself at the Volvocars developer portal and created an API key. My application status is currently "Only for testing". With every API call (both via postman as well as via the plugin I get an error "Access denied due to invalid VCC-API-KEY. Make sure to provide a valid key for an active application."
I think this error has nothing to do with the plugin (I get the same error when using postman), but as it impacts behaviour of the plugin I decided to log this in order to update once I know what the problem / solution is.
meanwhile any help to get this solves is much appreciated.