Skip to content

Commit

Permalink
Update Platform.js
Browse files Browse the repository at this point in the history
Start heartbeat also when `"Lib"` platform is not in `config.json`.
  • Loading branch information
ebaauw committed Aug 23, 2019
1 parent 9f4620d commit 51663a5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/Platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class Platform extends homebridgeLib.Delegate {
}
myContext.platform = this
if (global[globalKey].Platform == null) {
this.fatal('%s plugin not loaded', context.libName)
this.fatal('%s platform not registered', context.libName)
}
this._identify()

Expand All @@ -206,8 +206,13 @@ class Platform extends homebridgeLib.Delegate {
// Main platform function.
// Called by homebridge after restoring accessories from cache.
async _main () {
if (this._isHomebridgeLib || global[globalKey].Platform.platform == null) {
global[globalKey].Platform.platform = this
this.debug('starting heartbeat for %j', Object.keys(global[globalKey]))
this._heartbeatStart = new Date()
setTimeout(() => { this._beat(-1) }, 1000)
}
if (this._isHomebridgeLib) {
this.debug('plugins: %j', Object.keys(global[globalKey]))
const jobs = []
for (const plugin in global[globalKey]) {
const platform = global[globalKey][plugin].platform
Expand All @@ -218,9 +223,6 @@ class Platform extends homebridgeLib.Delegate {
jobs.push(events.once(platform, 'initialised'))
}
}
this.debug('starting heartbeat')
this._heartbeatStart = new Date()
setTimeout(() => { this._beat(-1) }, 1000)
for (const job of jobs) {
await job
}
Expand Down

0 comments on commit 51663a5

Please sign in to comment.