Dielee / volvo2mqtt

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

Add "Target Battery Charge Level" and "Charging Current Limit" #183

Closed gurtjun closed 2 months ago

gurtjun commented 3 months ago

Not sure if this is all that's needed to get the 2 new sensors into Home Assistant.

gurtjun commented 3 months ago

This should resolve #181

FireWizard52 commented 2 months ago

Hello @gurtjun,

Just a simple question.

Did you test your PR? And if so, did it work?

It is not possible to add new scopes to the list of scopes. However, you can remove existing scopes, if you want that. So, you cannot add: energy:charging_current_limit and energy:estimated_charging_time

If you add it to the list of scopes the Volvo API will return an error:

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

It does not match with the "client" authorization.

Sorry for that, but it is the way it currently is.

Regards

gurtjun commented 2 months ago

Hello @gurtjun,

Just a simple question.

Did you test your PR? And if so, did it work?

It is not possible to add new scopes to the list of scopes. However, you can remove existing scopes, if you want that. So, you cannot add: energy:charging_current_limit and energy:estimated_charging_time

If you add it to the list of scopes the Volvo API will return an error:

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

It does not match with the "client" authorization.

Sorry for that, but it is the way it currently is.

Regards

No, did not test this yet. Therefore the pull request.

FireWizard52 commented 2 months ago

Sorry,

It will not work

Regards

gurtjun commented 2 months ago

Ok, will try manually tomorrow

gurtjun commented 2 months ago

Sorry,

It will not work

Regards

Indeed, just did several tests and get the same result when adding the new scopes...

Maybe this gets resolved in version v1.9.0b1 (when using OTP authentication). But I'm unable to install the beta version. When logging into Volvo's developer portal I'm able to retrieve the charging current limit and target battery percentage using my Volvo ID and the VCC-API-KEY

gurtjun commented 2 months ago

@Dielee I was able to install version v1.9.0b1 but I don't get the OTP code in my mailbox 🙁 I can see the following logs but eventually the add-on fails to start

volvo2mqtt [106] - INFO: Waiting for otp code... Please check your mailbox and post your otp code to the following mqtt topic "volvoAAOS2mqtt/otp_code". Retry 3/15
gurtjun commented 2 months ago

@Dielee seems that there was quite a delay on receiving the email at my side, eventually filled in the OTP code and it started loading all the available sensors 🙌 However, when updating the addon locally and restarting it, after filling in the OTP code again I do get an error response from the get_token(auth_session, data) method in volvo.py

gurtjun commented 2 months ago

@Dielee nevermind, reinstalled everything and now version 1.9.0b1 works like a charm. Restarted home assistant, everything keeps working. Only when I restart the add-on, I need to fill in the OTP code again.

Dielee commented 2 months ago

Please do not mix the new OTP authentication with your PR. I will check your PR later this week. For the OTP auth discussion, open up a new issue and don't hijack this PR.

Thanks!

gurtjun commented 2 months ago

Please do not mix the new OTP authentication with your PR. I will check your PR later this week. For the OTP auth discussion, open up a new issue and don't hijack this PR.

Thanks!

Good point! Regarding this PR: from the moment I add the scopes to the request things go wrong (also in OTP branch)

Dielee commented 2 months ago

So, the new scopes are not working at this time.

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

Because of this, I will not merge this PR. Sorry!

gurtjun commented 2 months ago

So, the new scopes are not working at this time.

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

Because of this, I will not merge this PR. Sorry!

Ok, could it be that the new scopes need to be requested first for the client application in Volvo’s developer portal?

If I want to publish my own application to get the client id and secret I need to select the scopes I want to use: IMG_0847

Dielee commented 2 months ago

Yes, maybe. I tried to publish an application for more than 3 months without any success. So, it could help.... nobody knows.