Skip to content

Commit

Permalink
Fix HomeKit update delay issue for Nest Protect and (some) Nest Therm…
Browse files Browse the repository at this point in the history
…ostats
  • Loading branch information
adriancable committed Apr 30, 2022
1 parent 1f4633e commit 42ca369
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion lib/nest-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const API_AUTH_FAIL_RETRY_DELAY_SECONDS = 15;
// Delay after authentication fail (long) before retrying
const API_AUTH_FAIL_RETRY_LONG_DELAY_SECONDS = 60 * 60;

// Interval between Nest subscribe requests
const API_SUBSCRIBE_DELAY_SECONDS = 0.1;

// Nest property updates are combined together if less than this time apart, to reduce network traffic
const API_PUSH_DEBOUNCE_SECONDS = 2;

Expand Down Expand Up @@ -1224,7 +1227,7 @@ class Connection {
}

async dataTimerLoop(resolve, handler) {
var notify = resolve || handler;
var notify = resolve;

// eslint-disable-next-line
while (true) {
Expand Down Expand Up @@ -1256,6 +1259,9 @@ class Connection {
}
}
}

await Promise.delay(API_SUBSCRIBE_DELAY_SECONDS * 1000);
notify = handler;
}
}

Expand Down Expand Up @@ -1295,6 +1301,8 @@ class Connection {
this.error('Retrying in ' + API_RETRY_DELAY_SECONDS + ' seconds.');
return Promise.delay(API_RETRY_DELAY_SECONDS * 1000);
}

await Promise.delay(API_SUBSCRIBE_DELAY_SECONDS * 1000);
}
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
"prepublishOnly": "npm run lint",
"preversion": "npm run lint"
},
"version": "4.6.6",
"version": "4.6.7",
"warnings": [
{
"code": "ENOTSUP",
"required": {
"node": ">=7.0.0",
"homebridge": ">=0.2.5"
},
"pkgid": "[email protected].6"
"pkgid": "[email protected].7"
}
]
}

0 comments on commit 42ca369

Please sign in to comment.