Dielee / volvo2mqtt

Home Assistant addon for connecting AAOS Volvos
MIT License
157 stars 38 forks source link

New endpoints in Energy API #181

Closed FireWizard52 closed 5 months ago

FireWizard52 commented 7 months ago

@Dielee,

Hi Linus,

For your information!

  1. Volvo actually activated 2FA, today at approx. 11 h. If you log-out from your Volvo Cars app and log-in afterwards a Volvo ID-verification code has to be submitted. This code you receive by email ( maybe sms as well ??).

  2. New endpoints for new functionality in the Energy API. See the Energy API, but new are:

However, these new endpoints have also new "scopes" (energy:charging_current_limit and energy:target_battery_level) These scopes are not in the list of scopes and so I have not been able to test already.

Regards

Dielee commented 7 months ago

Yeah, thanks for this information.

  1. I already developed the 2FA login for my plugin. Are you able to test the changes ?

  2. I will take a look the the new endpoints tomorrow. If they work, I will add two new sensors.

FireWizard52 commented 7 months ago

Hi Linus, you said:

I already developed the 2FA login for my plugin. Are you able to test the changes ?

I saw it, and that you wanted also testers, but as you maybe know I do not use Home Assistant and I'm not a big fan of Docker either. So I'm afraid I will not be of much help.

I work with Node RED and all my automation's are done with that, but as I push them to MQTT, more or less all Home Automation system can be used. Regarding this 2FA I currently work in a little bit different direction.

  1. Check the output from the Volvo Server and in case the Volvo ID verification code is requested, I
  2. Check my email and
  3. Parse the verification code
  4. Put it into the verification flow on the right place.

But cannot test it yet, as Volvo ID server is not working

But let me know if the new sensors work, as my PHEV is still not supported.

Regards

Dielee commented 7 months ago

Check the output from the Volvo Server and in case the Volvo ID verification code is requested, I Check my email and Parse the verification code Put it into the verification flow on the right place

This is what I have done with my last changes.

BertilJ commented 7 months ago

I'm happy to support with testing if needed.

schrej-zz commented 7 months ago

@FireWizard52, I am also using this Tool without HA and without Docker. I just used the folder src and entered my data manually in the const file. Not a big issue.

schrej-zz commented 7 months ago

I'm also happy to Support.

Dielee commented 7 months ago

The new endpoint scopes are currently not working. Sorry guys, we have to wait.

The requested scope is invalid, unknown, malformed, or exceeds that which the client is permitted to request.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days.

schrej-zz commented 6 months ago

Keep it open.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 5 months ago

This issue was closed because it has been stalled for 5 days with no activity.

mhpleite commented 4 months ago

Hi Dielee,

The new endpoints should be available and work now. Would you be so kind to update the endpoints?

{ "status": 200, "data": { "chargingCurrentLimit": { "value": "32", "unit": "ampere", "timestamp": "2024-05-17T17:42:30Z" } },

gurtjun commented 4 months ago

Hi Dielee,

The new endpoints should be available and work now. Would you be so kind to update the endpoints?

{ "status": 200, "data": { "chargingCurrentLimit": { "value": "32", "unit": "ampere", "timestamp": "2024-05-17T17:42:30Z" } },

Still does not work at my end. When generating a token for scope energy:charging_current_limit or energy:target_battery_level I still get response:

{
    "error_description": "The requested scope is invalid, unknown, malformed, or exceeds that which the client is permitted to request.",
    "error": "invalid_scope"
}

I only get it working when generating test access tokens on developer.volvocars.com

quenthal commented 3 months ago

Hi Dielee, The new endpoints should be available and work now. Would you be so kind to update the endpoints? { "status": 200, "data": { "chargingCurrentLimit": { "value": "32", "unit": "ampere", "timestamp": "2024-05-17T17:42:30Z" } },

Still does not work at my end. When generating a token for scope energy:charging_current_limit or energy:target_battery_level I still get response:

{
    "error_description": "The requested scope is invalid, unknown, malformed, or exceeds that which the client is permitted to request.",
    "error": "invalid_scope"
}

I only get it working when generating test access tokens on developer.volvocars.com

Is this small signal that these would be released for production use also considering the past - what is your take on this?

malrogers7 commented 2 months ago

Hi Dielee. Thanks for your work on this add on, I know it cannot be easy, given how difficult Volvo's API is. When testing on the Volvo website, it generates a 401 result more often than a 200 result for the same details.

However, I can access the full energy API (recharge-status) pasted below. So happy to help test if you are able to get access to it.

Many thanks.

Request: curl -X 'GET' \ 'https://api.volvocars.com/energy/v1/vehicles/[MY IN]/recharge-status' \ -H 'accept: application/vnd.volvocars.api.energy.vehicledata.v1+json' \ -H 'vcc-api-key: [API KEY]' \ -H 'Authorization: Bearer [redacted]

Response: { "status": 200, "data": { "estimatedChargingTime": { "value": "0", "unit": "minutes", "timestamp": "2024-08-13T18:32:33Z" }, "targetBatteryChargeLevel": { "value": "80", "unit": "percentage", "timestamp": "2024-08-10T07:48:10Z" }, "chargingCurrentLimit": { "value": "32", "unit": "ampere", "timestamp": "2024-08-03T10:06:28Z" }, "batteryChargeLevel": { "value": "79.0", "unit": "percentage", "timestamp": "2024-08-13T18:32:33Z" }, "electricRange": { "value": "320", "unit": "kilometers", "timestamp": "2024-08-13T18:32:33Z" }, "chargingSystemStatus": { "value": "CHARGING_SYSTEM_IDLE", "timestamp": "2024-08-13T18:32:33Z" }, "chargingConnectionStatus": { "value": "CONNECTION_STATUS_DISCONNECTED", "timestamp": "2024-08-13T18:32:33Z" } }, "operationId": "d556b6dd-3afb-4aeb-b93c-56d3ebd3dea4" }

gurtjun commented 2 months ago

Hi Dielee. Thanks for your work on this add on, I know it cannot be easy, given how difficult Volvo's API is. When testing on the Volvo website, it generates a 401 result more often than a 200 result for the same details.

However, I can access the full energy API (recharge-status) pasted below. So happy to help test if you are able to get access to it.

Many thanks.

Request: curl -X 'GET' '[https://api.volvocars.com/energy/v1/vehicles/[MY](https://api.volvocars.com/energy/v1/vehicles/%5BMY) IN]/recharge-status' -H 'accept: application/vnd.volvocars.api.energy.vehicledata.v1+json' -H 'vcc-api-key: [API KEY]' -H 'Authorization: Bearer [redacted]

Response: { "status": 200, "data": { "estimatedChargingTime": { "value": "0", "unit": "minutes", "timestamp": "2024-08-13T18:32:33Z" }, "targetBatteryChargeLevel": { "value": "80", "unit": "percentage", "timestamp": "2024-08-10T07:48:10Z" }, "chargingCurrentLimit": { "value": "32", "unit": "ampere", "timestamp": "2024-08-03T10:06:28Z" }, "batteryChargeLevel": { "value": "79.0", "unit": "percentage", "timestamp": "2024-08-13T18:32:33Z" }, "electricRange": { "value": "320", "unit": "kilometers", "timestamp": "2024-08-13T18:32:33Z" }, "chargingSystemStatus": { "value": "CHARGING_SYSTEM_IDLE", "timestamp": "2024-08-13T18:32:33Z" }, "chargingConnectionStatus": { "value": "CONNECTION_STATUS_DISCONNECTED", "timestamp": "2024-08-13T18:32:33Z" } }, "operationId": "d556b6dd-3afb-4aeb-b93c-56d3ebd3dea4" }

Did you do the request via Volvo's Developer Portal? When I request a bearer token for scope energy:target_battery_level I still get the following response:

{
    "error_description": "The requested scope is invalid, unknown, malformed, or exceeds that which the client is permitted to request.",
    "error": "invalid_scope"
}
malrogers7 commented 2 months ago

Yes, on the Volvo Developer Portal here: https://developer.volvocars.com/apis/energy/v1/specification/

gurtjun commented 2 months ago

Yes, on the Volvo Developer Portal here: https://developer.volvocars.com/apis/energy/v1/specification/

Please read the comments above, that's a known issue

malrogers7 commented 2 months ago

Ok. I did read them, but it wasn't clear to me, so thought I'd try to help.

gurtjun commented 2 months ago

Ok. I did read them, but it wasn't clear to me, so thought I'd try to help.

Sadly we can't do anything about it I believe, waiting for Volvo to fix this.