From 48f5042f314270241dd2c109be56a2cf0e53b90c Mon Sep 17 00:00:00 2001 From: steffjenl Date: Sat, 9 Nov 2024 19:35:13 +0100 Subject: [PATCH] Changed Chime icon and smart detection trigger card names --- library/websocket.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/library/websocket.js b/library/websocket.js index bd5f577..3428742 100644 --- a/library/websocket.js +++ b/library/websocket.js @@ -10,14 +10,13 @@ class ProtectWebSocket extends BaseClass { super(...props); this.loggedInStatus = 'Unknown'; this.lastWebsocketMessage = null; - this.isAlive = false; } heartbeat() { - this.homey.app.debug('Send heartbeat ping to websocket'); - this.homey.clearTimeout(this.pingTimeout); + this.homey.log('Send heartbeat ping to websocket'); + this.homey.clearInterval(this.pingTimeout); - this.pingTimeout = this.homey.setTimeout(() => { + this.pingTimeout = this.homey.setInterval(() => { this._eventListener.ping(); }, 30000); } @@ -76,15 +75,14 @@ class ProtectWebSocket extends BaseClass { // Connection opened this._eventListener.on('open', (event) => { - this.heartbeat(); this.homey.app.debug(this.homey.app.api.getNvrName() + ': Connected to the UniFi realtime update events API.'); this.homey.api.realtime(UfvConstants.EVENT_SETTINGS_WEBSOCKET_STATUS, 'Connected'); this.loggedInStatus = 'Connected'; - this._eventListener.ping(); + this.heartbeat(); }); this._eventListener.on('pong', (event) => { - this.heartbeat(); + this.homey.log('Received pong from websocket'); }); this._eventListener.on('close', () => {