Skip to content

Commit

Permalink
Changed Chime icon and smart detection trigger card names
Browse files Browse the repository at this point in the history
  • Loading branch information
steffjenl committed Nov 9, 2024
1 parent 77747f0 commit 48f5042
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions library/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit 48f5042

Please sign in to comment.