Skip to content

Commit

Permalink
feat(dingz): reduce DEAD/ALIVE logging
Browse files Browse the repository at this point in the history
- don't log as often
- only indicate state changes after setup
  • Loading branch information
johannrichard committed Dec 3, 2020
1 parent d363121 commit 84b1ebb
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/lib/dingzDaBaseAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,21 @@ export class DingzDaBaseAccessory {
// .. and finally set-up the interval that triggers updates or
// changes the reachability state of the device
this.platform.eb.on(PlatformEvent.REQUEST_STATE_UPDATE, () => {
const heartbeat: string =
this.reachabilityState === null
? chalk.green('ALIVE')
: chalk.yellow('DEAD');
this.log.info(heartbeat, `(${this.device.address})`);
this.getDeviceStateUpdate()
.then(() => {
// The device update was successful
if (this.reachabilityState !== null) {
// Update reachability -- obviously, we're online again
this.reachabilityState = null;
this.log.warn(
this.log.info(
chalk.green('ALIVE'),
`Device --> recovered from unreachable state (${this.device.address})`,
);
}
})
.catch((e) => {
this.log.warn(
chalk.yellow('DEAD'),
`Device --> entered unreachable state (${this.device.address})`,
);
this.handleRequestErrors(e);
Expand Down

0 comments on commit 84b1ebb

Please sign in to comment.