Python Plugin: Volvo EV

Python and python framework

Moderator: leecollings

akamming
Posts: 386
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Volvo EV

Post by akamming »

FireWizard wrote: Monday 07 July 2025 15:06 Hi @akamming,
The refresh token under 2 is (or was, since it’s no langer there) langer valid dan 1800s. I’ve Done tests with a refresh token of more than 2 days old and could still obtain a new token
I think, you are correct, but if you rotate the refresh_token, the old one will become invalid and will be "replaced" by the new one.
I don't think you can re-use an old "refresh_token" later on

I'm reading currently the Volvo Developer API and I see something, I did not see before.
You are also able to retrieve a complete list of any commands that you have sent.
Have you seen that before?
Nope
This API is Rate Limited to prevent malicious activity or accidents that cause service disruptions. The limit is set to 100 request per minute for a combination of the user's Volvo ID and the Client ID sending the request. A given user will have 100 requests per minute per application it uses. Should this limit be exceeded, the API will respond with HTTP code 429.

The invocation methods are more strictly limited to 10 requests per minute. This limit is also set using a combination of Volvo ID and Client ID. This stricter limitation is due to the underlying system's capacity.
Would that "id_token" be related to control the limitation instead of the current 10.000 calls/day?
no clue
The 7 days is not only the vision of Thomasddn, it is also stated on the Volvo developer page:
The access_token has a short lifespan. To create a seamless end-user experience, you will need to refresh the access token before it expires.

By default, refresh token rotation is enabled. Each time you call the Refresh endpoint, a new refresh token is created, and the old token is invalidated. If not rotated, the refresh_token is valid for 7 days. After that, the user has to re-authenticate.
That is what I know and I used that for my flow specification.

Regards
Check, i understand, tx for the clear explanation
rron
Posts: 249
Joined: Sunday 30 March 2014 15:24
Target OS: Linux
Domoticz version: Beta
Location: Waterland
Contact:

Re: Python Plugin: Volvo EV

Post by rron »

akamming wrote: Friday 04 July 2025 17:34
mvveelen wrote: Friday 04 July 2025 16:46 Hi, actually what's in the custom text device so that I have an overview in just 1 place.
Not sure how I can accomplish this.
several ways to go:
You could create a dzVents script to populate a text device or use something like dashticz to create your overview.

To be honest domoticz is a outdated for the UI (in my humble opinion, will not be a popular opinion in this forum), so you need more advanced ways to create simple overviews.

Tha'ts why i am now using a combi of domoticz (which is still far better than HA in flexibility in scripting, so I use it for the more complex scripting cases) and home assistant (for simple automations and dashboarding).

Sorry this is complete off topic but how do you use the HA user interface in combination with domoticz?



Alternatively: If you're an iphone user, you could also use https://github.com/PatchworkBoy/homebridge-edomoticz, to make apple home your dashboard. That was my setup before i moved to HA for that part.
Sorry my question is complete off topic but how do you use the HA user interface in combination with domoticz?
Rpi, RFXcom, klikaan klikuit switch,thermosmart, z-wave, espeasy, smartevse
akamming
Posts: 386
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Volvo EV

Post by akamming »

rron wrote: Monday 07 July 2025 17:44
akamming wrote: Friday 04 July 2025 17:34
mvveelen wrote: Friday 04 July 2025 16:46 Hi, actually what's in the custom text device so that I have an overview in just 1 place.
Not sure how I can accomplish this.
several ways to go:
You could create a dzVents script to populate a text device or use something like dashticz to create your overview.

To be honest domoticz is a outdated for the UI (in my humble opinion, will not be a popular opinion in this forum), so you need more advanced ways to create simple overviews.

Tha'ts why i am now using a combi of domoticz (which is still far better than HA in flexibility in scripting, so I use it for the more complex scripting cases) and home assistant (for simple automations and dashboarding).

Sorry this is complete off topic but how do you use the HA user interface in combination with domoticz?



Alternatively: If you're an iphone user, you could also use https://github.com/PatchworkBoy/homebridge-edomoticz, to make apple home your dashboard. That was my setup before i moved to HA for that part.
Sorry my question is complete off topic but how do you use the HA user interface in combination with domoticz?
Very offtopic indeed and if you would have searched the forum, you would have found the answer: viewtopic.php?t=42803
rron
Posts: 249
Joined: Sunday 30 March 2014 15:24
Target OS: Linux
Domoticz version: Beta
Location: Waterland
Contact:

Re: Python Plugin: Volvo EV

Post by rron »

You are right. I searched but not good enough :geek:
Rpi, RFXcom, klikaan klikuit switch,thermosmart, z-wave, espeasy, smartevse
User avatar
FireWizard
Posts: 1905
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Python Plugin: Volvo EV

Post by FireWizard »

Hi, @akammingm

Interesting article, I found, and probably for "something" new to come, as announced in that email.

https://auth0.com/blog/id-token-access- ... ifference/

Just to prepare yourself.

Regards
akamming
Posts: 386
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Volvo EV

Post by akamming »

FireWizard wrote: Monday 07 July 2025 22:28 Hi, @akammingm

Interesting article, I found, and probably for "something" new to come, as announced in that email.

https://auth0.com/blog/id-token-access- ... ifference/

Just to prepare yourself.

Regards
Yeah I already found more artikels/docs like that.Unfortunately it all depends on how Volvo is gonna implement it and hopefully how they document it

It is a bad sign they already started changing the Production environment without notifying the developers community and/or updating the docs on what they did

Hopefully they don’t do this too often, cause then it becomes frustrating to maintain a plugin like this. It’s just a hobby so I don’t have the time to reverse engineer changes like this…
User avatar
FireWizard
Posts: 1905
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Python Plugin: Volvo EV

Post by FireWizard »

Hello @akamming,

You said:
It is a bad sign they already started changing the Production environment without notifying the developers community and/or updating the docs on what they did

Hopefully they don’t do this too often, cause then it becomes frustrating to maintain a plugin like this. It’s just a hobby so I don’t have the time to reverse engineer changes like this…
I have to disappoint you, as they already started with modifications, that will have impact on the maintenance of our projects.

They silently introduced Energy API Version 2, that will replace Version 1 completely.
Your (and mine) application Version 1 supported 5 of 7 Endpoints with the scopes for h4Yf0b.
In Version 2, this has been reduced to 2 Endpoints,

1 Endpoint gives you the capabilities of your car as a boolean value.
The other gives you the data of 10 "sensors". So the information has been extended, but so far only 2 supports my car (XC 40 PHEV Hybrid 2023).

These 2 endpoints has also new scopes, so I was afrai0d, that I had to register a new project, as you cannot extend an existing project with new scopes. But I noticed that the current user does support these 2 new scopes.

The new document does also mention a new API (Subscription API) But the API itself has not been published yet.

Some changes in the base URL and Header, but that is easy to accomplish.

You have 6 months to migrate.

So some challenges

I also noted that ThomasDDN already has implemented version 2 in his library and also the id_token.

Regards
akamming
Posts: 386
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Volvo EV

Post by akamming »

FireWizard wrote: Thursday 10 July 2025 15:01 Hello @akamming,

You said:
It is a bad sign they already started changing the Production environment without notifying the developers community and/or updating the docs on what they did

Hopefully they don’t do this too often, cause then it becomes frustrating to maintain a plugin like this. It’s just a hobby so I don’t have the time to reverse engineer changes like this…
I have to disappoint you, as they already started with modifications, that will have impact on the maintenance of our projects.

They silently introduced Energy API Version 2, that will replace Version 1 completely.
Your (and mine) application Version 1 supported 5 of 7 Endpoints with the scopes for h4Yf0b.
In Version 2, this has been reduced to 2 Endpoints,

1 Endpoint gives you the capabilities of your car as a boolean value.
The other gives you the data of 10 "sensors". So the information has been extended, but so far only 2 supports my car (XC 40 PHEV Hybrid 2023).

These 2 endpoints has also new scopes, so I was afrai0d, that I had to register a new project, as you cannot extend an existing project with new scopes. But I noticed that the current user does support these 2 new scopes.

The new document does also mention a new API (Subscription API) But the API itself has not been published yet.

Some changes in the base URL and Header, but that is easy to accomplish.

You have 6 months to migrate.

So some challenges

I also noted that ThomasDDN already has implemented version 2 in his library and also the id_token.

Regards
i have no issues with improvements for which i have 6 months (was not aware of this one btw..., so tx for the hint) and are documented. My issue is that have breaking changes with no time to migrate and which are also undocumented... like the refresh token which is now changed..

Edit: This was an easy change, updates the plug-in with the v2 energy api. Nice to see more data available now. Tx for the tip!
akamming
Posts: 386
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Volvo EV

Post by akamming »

FireWizard wrote: Monday 07 July 2025 22:28 Hi, @akammingm

Interesting article, I found, and probably for "something" new to come, as announced in that email.

https://auth0.com/blog/id-token-access- ... ifference/

Just to prepare yourself.

Regards
Hi @FireWizard: They fixed it. I checked the logs today, cause it would fail, since i implemented the workaround on July 7th. But the refresh token call now also sends back a new token. I did a scan on the logs and on July 10th as of about 2100 it was fixed.
User avatar
FireWizard
Posts: 1905
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Python Plugin: Volvo EV

Post by FireWizard »

Hello @akamming,

You wrote:
They fixed it. I checked the logs today, cause it would fail, since i implemented the workaround on July 7th. But the refresh token call now also sends back a new token. I did a scan on the logs and on July 10th as of about 2100 it was fixed.
I did not see that . Fur me it is still the same.

This morning I did a manual re-authentication. As in the past I received a refresh token, that you can use after 1799 seconds.
But in my case the response to the refresh token does not contain a new refresh token.

So in my case, it has not been fixed.

I discovered also something else:

Linus Dietz (dielee) made a small modification in his project. See: https://github.com/Dielee/volvo2mqtt/pull/295
I thought, that we stopped that project in favor of the new HA integration of ThomasDDN>

Have you done that as well?
In 3 places he replaced http for https. If that would be essential, then I would expect, that it would be corrected at the server (Volvo) side and that it is not something we should correct.

However, it is not a big job to correct.

Regards
akamming
Posts: 386
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Volvo EV

Post by akamming »

FireWizard wrote: Sunday 13 July 2025 11:09 Hello @akamming,

You wrote:
They fixed it. I checked the logs today, cause it would fail, since i implemented the workaround on July 7th. But the refresh token call now also sends back a new token. I did a scan on the logs and on July 10th as of about 2100 it was fixed.
I did not see that . Fur me it is still the same.

This morning I did a manual re-authentication. As in the past I received a refresh token, that you can use after 1799 seconds.
But in my case the response to the refresh token does not contain a new refresh token.

So in my case, it has not been fixed.

I discovered also something else:

Linus Dietz (dielee) made a small modification in his project. See: https://github.com/Dielee/volvo2mqtt/pull/295
I thought, that we stopped that project in favor of the new HA integration of ThomasDDN>

Have you done that as well?
In 3 places he replaced http for https. If that would be essential, then I would expect, that it would be corrected at the server (Volvo) side and that it is not something we should correct.

However, it is not a big job to correct.

Regards
Yeah, I did this Some time ago. At that moment in time refreshing tokens also failed, so i force https now in the url’s which are returned by the Volvo api when refreshing tokens or authenticating
akamming
Posts: 386
Joined: Friday 17 August 2018 14:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Volvo EV

Post by akamming »

FireWizard wrote: Sunday 13 July 2025 11:09 Hello @akamming,

You wrote:
They fixed it. I checked the logs today, cause it would fail, since i implemented the workaround on July 7th. But the refresh token call now also sends back a new token. I did a scan on the logs and on July 10th as of about 2100 it was fixed.
I did not see that . Fur me it is still the same.

This morning I did a manual re-authentication. As in the past I received a refresh token, that you can use after 1799 seconds.
But in my case the response to the refresh token does not contain a new refresh token.

So in my case, it has not been fixed.

I discovered also something else:

Linus Dietz (dielee) made a small modification in his project. See: https://github.com/Dielee/volvo2mqtt/pull/295
I thought, that we stopped that project in favor of the new HA integration of ThomasDDN>

Have you done that as well?
In 3 places he replaced http for https. If that would be essential, then I would expect, that it would be corrected at the server (Volvo) side and that it is not something we should correct.

However, it is not a big job to correct.

Regards
i just checked the logs again... it seems there are periods with a refresh token and without in the api responses from Volvo. The interesting thing is that at after exactly 7 days, it was in a period when there was no refresh_token present, but at exactly that moment it did have a refresh_token in the reply. My guess is that they changed the code so that the refresh token is only returned in the output at the moment it expires (that would be more safe, cause less change of intercepting that token). But the new code is not on all nodes. So depending which node answers your api call you will get an anwser with or without a refresh token.

What my code basically does: If a refresh code is returned, it stores it. If not, it just used the "old" one for future refresh_access_token calls. So it is can handle this inconsistent server behaviour (just lucky, i didn't have this scenario in mind when i made this "workaround", which now seems to be a "solution")
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest