log key refresh better

This commit is contained in:
Alex Janka 2024-01-12 08:47:19 +11:00
parent 429a233974
commit 904513b71a

View file

@ -195,11 +195,15 @@ impl TeslaInterface {
async fn refresh_keys(&mut self) { async fn refresh_keys(&mut self) {
// refresh our Tesla (the company's web servers, not the car) access token // refresh our Tesla (the company's web servers, not the car) access token
if Instant::now().duration_since(self.last_refresh) >= KEY_REFRESH_INTERVAL { if Instant::now().duration_since(self.last_refresh) >= KEY_REFRESH_INTERVAL {
log::warn!("refreshing keys...");
match self.api.refresh().await { match self.api.refresh().await {
Ok(_) => { Ok(_) => {
let now = Instant::now(); let now = Instant::now();
match self.save_key() { match self.save_key() {
Ok(_) => self.last_refresh = now, Ok(_) => {
log::warn!("refreshed keys...");
self.last_refresh = now;
}
Err(e) => error!("error saving auth token: {e:?}"), Err(e) => error!("error saving auth token: {e:?}"),
} }
} }