Skip to content

Commit

Permalink
fix naming style
Browse files Browse the repository at this point in the history
  • Loading branch information
CFenner committed Jun 22, 2024
1 parent cd2cc4d commit 5c463e8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ module.exports = {
// write in token file and provides for token refresh
this.writeToken(result)
if (result.expires_in) {
const expire_at = moment(Date.now() + (result.expires_in * 1000)).format('LLLL')
console.log(`Netatmo: New Token Expire ${expire_at}`)
const expireAt = moment(Date.now() + (result.expires_in * 1000)).format('LLLL')
console.log(`Netatmo: New Token Expire ${expireAt}`)
setTimeout(() => this.authenticateRefresh(result.refresh_token), (result.expires_in - 60) * 1000)
};

Expand Down Expand Up @@ -177,13 +177,13 @@ module.exports = {
if (fs.existsSync(file)) {
console.log('Netatmo: using token.json file')
const tokenFile = JSON.parse(fs.readFileSync(file))
const refresh_token = tokenFile.refresh_token
if (!refresh_token) {
const refreshToken = tokenFile.refresh_token
if (!refreshToken) {
console.error('Netatmo: Token not found in token.json file')
console.log('Netatmo: using refresh_token from config')
return null
}
return refresh_token
return refreshToken
}
// Token file not used
console.log('Netatmo: using refresh_token from config')
Expand All @@ -204,11 +204,11 @@ module.exports = {
},

// Refresh Token
async authenticateRefresh (refresh_token) {
async authenticateRefresh (refreshToken) {
console.log('Netatmo: Refresh Token')
const params = new URLSearchParams()
params.append('grant_type', 'refresh_token')
params.append('refresh_token', refresh_token)
params.append('refresh_token', refreshToken)
params.append('client_id', this.clientId)
params.append('client_secret', this.clientSecret)

Expand All @@ -228,8 +228,8 @@ module.exports = {
console.log('Netatmo: TOKEN Updated')

if (result.expires_in) {
const expire_at = moment(Date.now() + (result.expires_in * 1000)).format('LLLL')
console.log(`Netatmo: New Token Expire ${expire_at}`)
const expireAt = moment(Date.now() + (result.expires_in * 1000)).format('LLLL')
console.log(`Netatmo: New Token Expire ${expireAt}`)
setTimeout(() => this.authenticateRefresh(result.refresh_token), (result.expires_in - 60) * 1000)
};

Expand Down

0 comments on commit 5c463e8

Please sign in to comment.