-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Tado: Made expire time of refresh token dynamic #6419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
|
Is one second not to risky? Maybe make it 30 seconds? if (acttime-token_get_time >= token_refresh_time) ... |
|
It is not one second, the 599/600 is something Tado delivers. The actual time is at least the poll intervall. Could be an issue if the poll intervall is set to 1 or so, but in that case the request limit is reached way too soon. In case the poll intervall is greater compared to expire time, there also is a problem, but in that case the loops is set to one. I know, not fool proof. |
|
Sorry that is not what I meant. You receive 600 from Tado. Instead of checking the time and see if 600 seconds have elapsed, be a bit more safe, like 590 seconds (minus 10 seconds) |
|
I made use of the loopcheck already present in the code. The time should be at least the pollinterval. Or do you mean substract 10secs from the expire time Tado sends and compute the nr of loops based on that and the pollinterval? Jan |
|
Yes, and I suggest to not use the loop for time checking, time_t atime=time(nullptr) bool RefreshToken()
tado.h |
|
@Jan-nl , is it possible to implement the above feature request? |
|
Yes, sure. But it will take some time. Due to my c++ knowledge and the actual time I have. If you can cancel the pr for now that is fine. |
|
No that's fine, take your time! |
a0a55cd to
e57a1b6
Compare
|
Is the "expries_in" in Seconds? Could you make the m_iTokenExpiresIn a time_t type in the header and when it is in seconds you could do m_iTokenExpiresIn = time(nullptr) + std::stoi(root["expires_in"].asString()); Is it a string or a number? Maybe you could directly to integer? m_iTokenExpiresIn = time(nullptr) + root["expires_in"].asInt(); Delete the 'Set_TokenRefresh' function, this is not needed m_iTADO_TOKEN_MAXLOOPS can also be deleted In Do_Work above this line do something like if (time(nullptr)>=m_iTokenExpiresIn ) { Maybe clean up some code, and move code from Do_Work in it's own function (Own poll function) If no token, no need to poll Hope that makes a bit sense? |
Made the expire time of the refresh token of the Tado API dynamic, based on the expire time returned when a token is refreshed. Max loops is abs(expire time / poll interval) - 1, to be safe.
Remark: the first expire time is 599 seconds, the first refresh token returns 600 secs