From 64b74d3a5692be6fbbeb6cf78453ccdd69cdfaa6 Mon Sep 17 00:00:00 2001 From: kyleboyer Date: Sun, 4 Aug 2024 08:39:18 -0500 Subject: [PATCH] Also reset sync state in the hub --- package-lock.json | 16 ++-------------- package.json | 3 +-- src/accessory/base.ts | 24 +----------------------- 3 files changed, 4 insertions(+), 39 deletions(-) diff --git a/package-lock.json b/package-lock.json index 774ca72..f295248 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebridge-blaq", - "version": "0.2.29", + "version": "0.2.31", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebridge-blaq", - "version": "0.2.29", + "version": "0.2.31", "funding": [ { "type": "github", @@ -20,7 +20,6 @@ "license": "Apache-2.0", "dependencies": { "bonjour-service": "^1.2.1", - "debounce": "^2.1.0", "eventsource": "^2.0.2", "node-fetch": "^3.3.2", "strip-ansi": "^7.1.0" @@ -926,17 +925,6 @@ "node": ">= 12" } }, - "node_modules/debounce": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/debounce/-/debounce-2.1.0.tgz", - "integrity": "sha512-OkL3+0pPWCqoBc/nhO9u6TIQNTK44fnBnzuVtJAbp13Naxw9R6u21x+8tVTka87AhDZ3htqZ2pSSsZl9fqL2Wg==", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/debug": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", diff --git a/package.json b/package.json index 25cae48..ed7ee65 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": false, "displayName": "Konnected BlaQ", "name": "homebridge-blaq", - "version": "0.2.29", + "version": "0.2.31", "description": "Control and view your garage door(s) remotely with real-time updates using Konnected's BlaQ hardware", "license": "Apache-2.0", "type": "module", @@ -36,7 +36,6 @@ ], "dependencies": { "bonjour-service": "^1.2.1", - "debounce": "^2.1.0", "eventsource": "^2.0.2", "node-fetch": "^3.3.2", "strip-ansi": "^7.1.0" diff --git a/src/accessory/base.ts b/src/accessory/base.ts index 6ea2305..d63ff0b 100644 --- a/src/accessory/base.ts +++ b/src/accessory/base.ts @@ -1,5 +1,4 @@ import { CharacteristicValue, Logger, PlatformAccessory, Service, WithUUID } from 'homebridge'; -import debounce, { DebouncedFunction } from 'debounce'; import { LogMessageEvent, PingMessageEvent, StateUpdateMessageEvent, StateUpdateRecord } from '../utils/eventsource'; import { BlaQHomebridgePluginPlatform } from '../platform'; import { BlaQTextSensorEvent } from '../types'; @@ -31,11 +30,6 @@ export const correctAPIBaseURL = (inputURL: string) => { return correctedAPIBaseURL; }; -type DebouncedService = (typeof Service | Service) & { - setCharacteristic: DebouncedFunction<(name: string, value: CharacteristicValue) => Service>; - updateCharacteristic: DebouncedFunction<(name: string, value: CharacteristicValue) => Service>; -}; - export class BaseBlaQAccessory implements BaseBlaQAccessoryInterface { protected apiBaseURL: string; protected firmwareVersion?: string; @@ -85,9 +79,8 @@ export class BaseBlaQAccessory implements BaseBlaQAccessoryInterface { } protected getOrAddService(service: WithUUID | Service): Service { - const retService = this.accessory.getService(service as WithUUID) || + return this.accessory.getService(service as WithUUID) || this.accessory.addService(service as Service); - return this.debounceService(retService); } protected removeService(service: WithUUID | Service): void{ @@ -97,21 +90,6 @@ export class BaseBlaQAccessory implements BaseBlaQAccessoryInterface { } } - protected debounceService(service: Service): Service { - const originalSet = service.setCharacteristic.bind(service); - const originalUpdate = service.updateCharacteristic.bind(service); - const retService: DebouncedService = service as DebouncedService; - retService.setCharacteristic = debounce( - (name: string, value: CharacteristicValue) => originalSet(name, value), - 100, - ); - retService.updateCharacteristic = debounce( - (name: string, value: CharacteristicValue) => originalUpdate(name, value), - 100, - ); - return retService as Service; - } - processQueuedEvents() { while(this.queuedEvents.length){ const event = this.queuedEvents.shift()!;