From 952945c5f79902b453f1f5589a012f6df9c7d554 Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Fri, 1 Nov 2024 16:04:19 -0500 Subject: [PATCH] platform config --- src/devices/device.ts | 12 ++++++------ src/devices/leaksensors.ts | 2 +- src/devices/roomsensors.ts | 2 +- src/devices/roomsensorthermostats.ts | 2 +- src/devices/thermostats.ts | 2 +- src/platform.ts | 1 + 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/devices/device.ts b/src/devices/device.ts index fb75e66b..4245aa75 100644 --- a/src/devices/device.ts +++ b/src/devices/device.ts @@ -50,26 +50,26 @@ export abstract class deviceBase { } async getDeviceLogSettings(accessory: PlatformAccessory, device: resideoDevice & devicesConfig): Promise { - this.deviceLogging = this.platform.debugMode ? 'debugMode' : device.logging ?? this.config.logging ?? 'standard' - const logging = this.platform.debugMode ? 'Debug Mode' : device.logging ? 'Device Config' : this.config.logging ? 'Platform Config' : 'Default' + this.deviceLogging = this.platform.debugMode ? 'debugMode' : device.logging ?? this.platform.platformLogging ?? 'standard' + const logging = this.platform.debugMode ? 'Debug Mode' : device.logging ? 'Device Config' : this.platform.platformLogging ? 'Platform Config' : 'Default' accessory.context.deviceLogging = this.deviceLogging await this.debugLog(`Using ${logging} Logging: ${this.deviceLogging}`) } async getDeviceRateSettings(accessory: PlatformAccessory, device: resideoDevice & devicesConfig): Promise { // refreshRate - this.deviceRefreshRate = device.thermostat?.roomsensor?.refreshRate ?? device.thermostat?.roompriority?.refreshRate ?? device.refreshRate ?? this.config.options?.refreshRate ?? 120 + this.deviceRefreshRate = device.thermostat?.roomsensor?.refreshRate ?? device.thermostat?.roompriority?.refreshRate ?? device.refreshRate ?? this.platform.platformRefreshRate ?? 120 const refreshRate = device.thermostat?.roomsensor?.refreshRate ? 'Room Sensor Config' : device.thermostat?.roompriority?.refreshRate ? 'Room Priority Config' : device.refreshRate ? 'Device Config' - : this.config.options?.refreshRate ? 'Platform Config' : 'Default' + : this.platform.platformRefreshRate ? 'Platform Config' : 'Default' accessory.context.deviceRefreshRate = this.deviceRefreshRate // pushRate - this.devicePushRate = device.pushRate ?? this.config.options?.pushRate ?? 0.1 - const pushRate = device.pushRate ? 'Device Config' : this.config.options?.pushRate ? 'Platform Config' : 'Default' + this.devicePushRate = device.pushRate ?? this.platform.platformPushRate ?? 0.1 + const pushRate = device.pushRate ? 'Device Config' : this.platform.platformPushRate ? 'Platform Config' : 'Default' await this.debugLog(`Using ${refreshRate} refreshRate: ${this.deviceRefreshRate}, ${pushRate} pushRate: ${this.devicePushRate}`) accessory.context.devicePushRate = this.devicePushRate } diff --git a/src/devices/leaksensors.ts b/src/devices/leaksensors.ts index 4f2a7ca3..934f9df6 100644 --- a/src/devices/leaksensors.ts +++ b/src/devices/leaksensors.ts @@ -192,7 +192,7 @@ export class LeakSensor extends deviceBase { this.updateHomeKitCharacteristics() // Start an update interval - interval(this.config.options!.refreshRate! * 1000) + interval(this.deviceRefreshRate * 1000) .pipe(skipWhile(() => this.SensorUpdateInProgress)) .subscribe(async () => { await this.refreshStatus() diff --git a/src/devices/roomsensors.ts b/src/devices/roomsensors.ts index dcabf9c3..06a2fd4f 100644 --- a/src/devices/roomsensors.ts +++ b/src/devices/roomsensors.ts @@ -189,7 +189,7 @@ export class RoomSensors extends deviceBase { this.updateHomeKitCharacteristics() // Start an update interval - interval(this.config.options!.refreshRate! * 1000) + interval(this.deviceRefreshRate * 1000) .pipe(skipWhile(() => this.SensorUpdateInProgress)) .subscribe(async () => { await this.refreshStatus() diff --git a/src/devices/roomsensorthermostats.ts b/src/devices/roomsensorthermostats.ts index fd75eda9..90c220d6 100644 --- a/src/devices/roomsensorthermostats.ts +++ b/src/devices/roomsensorthermostats.ts @@ -227,7 +227,7 @@ export class RoomSensorThermostat extends deviceBase { this.updateHomeKitCharacteristics() // Start an update interval - interval(this.config.options!.refreshRate! * 1000) + interval(this.deviceRefreshRate * 1000) .pipe(skipWhile(() => this.thermostatUpdateInProgress)) .subscribe(async () => { await this.refreshStatus() diff --git a/src/devices/thermostats.ts b/src/devices/thermostats.ts index c4194f86..849533a2 100644 --- a/src/devices/thermostats.ts +++ b/src/devices/thermostats.ts @@ -312,7 +312,7 @@ export class Thermostats extends deviceBase { this.refreshStatus() // Start an update interval - interval(this.config.options!.refreshRate! * 1000) + interval(this.deviceRefreshRate * 1000) .pipe(skipWhile(() => this.thermostatUpdateInProgress)) .subscribe(async () => { await this.refreshStatus() diff --git a/src/platform.ts b/src/platform.ts index 57eb7485..c9d02b2c 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -71,6 +71,7 @@ export class ResideoPlatform implements DynamicPlatformPlugin { this.config = { platform: 'Resideo', + name: config.name, credentials: config.credentials, options: config.options, }