diff --git a/CHANGELOG.md b/CHANGELOG.md index 47979f1a..07e70570 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,12 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/). +## v5.9.8 +* [Housekeeping] Check if device exists based on `deviceUUID` rather than `serial` for consistency with cache restore checks. `deviceUUID` used as basis for Homebridge `UUID`. +* [Logging] Add accType to logging messages added in v5.9.7 so that UUIDs can be more easily tracked. + ## v5.9.7 -* [Debugging] Add additional logging for homebridge accessory UUID during addition of new Awair device and recovery from cache for existing Awair devices. +* [Logging] Add additional logging for homebridge accessory UUID during addition of new Awair device and recovery from cache for existing Awair devices. ## v5.9.6 * [Housekeeping] Plug-in initialization code and logging improvements. diff --git a/package-lock.json b/package-lock.json index 4827a198..700479ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-awair2", - "version": "5.9.7", + "version": "5.9.8", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index f8a44cb5..7b2b8aa9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": false, "displayName": "Homebridge Awair2", "name": "homebridge-awair2", - "version": "5.9.7", + "version": "5.9.8", "description": "HomeKit integration of Awair air quality monitor as Dynamic Platform.", "main": "dist/index.js", "scripts": { diff --git a/src/index.ts b/src/index.ts index 5bedac22..1b2235dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -221,7 +221,8 @@ class AwairPlatform implements DynamicPlatformPlugin { */ configureAccessory(accessory: PlatformAccessory): void { if(this.config.logging){ - this.log(`Restoring cached accessory deviceUUID: ${accessory.context.deviceUUID}, UUID: ${accessory.UUID}`); + // eslint-disable-next-line max-len + this.log(`Restoring cached accessory deviceUUID: ${accessory.context.deviceUUID}, ${accessory.context.accType}, UUID: ${accessory.UUID}`); } switch(accessory.context.accType) { @@ -557,16 +558,16 @@ class AwairPlatform implements DynamicPlatformPlugin { this.log(`[${device.macAddress}] Initializing platform accessory ${device.name}...`); } - // check if IAQ accessory exists + // check if IAQ accessory exists in cache let accessory = this.accessories.find(cachedAccessory => { - return ((cachedAccessory.context.serial === device.macAddress) && (cachedAccessory.context.accType === 'IAQ')); + return ((cachedAccessory.context.deviceUUID === device.deviceUUID) && (cachedAccessory.context.accType === 'IAQ')); }); - // if IAQ accessory does _not_ exist, initialze as new + // if IAQ accessory does NOT exist in cache, initialze as new if (!accessory) { const uuid = hap.uuid.generate(device.deviceUUID); if(this.config.logging){ - this.log(`Adding deviceUUID: ${device.deviceUUID}, UUID: ${uuid}`); + this.log(`Adding deviceUUID: ${device.deviceUUID}, IAQ, UUID: ${uuid}`); } accessory = new Accessory(device.name, uuid); @@ -1200,7 +1201,7 @@ class AwairPlatform implements DynamicPlatformPlugin { // check if Awair device 'displayMode' accessory exists let accessory = this.accessories.find(cachedAccessory => { - return ((cachedAccessory.context.serial === data.macAddress) && (cachedAccessory.context.accType === 'Display')); + return ((cachedAccessory.context.deviceUUID === data.deviceUUID) && (cachedAccessory.context.accType === 'Display')); }); // if displayMode accessory does not exist in cache, initialze as new @@ -1381,7 +1382,7 @@ class AwairPlatform implements DynamicPlatformPlugin { // check if Awair device 'ledMode' accessory exists let accessory = this.accessories.find(cachedAccessory => { - return ((cachedAccessory.context.serial === data.macAddress) && (cachedAccessory.context.accType === 'LED')); + return ((cachedAccessory.context.deviceUUID === data.deviceUUID) && (cachedAccessory.context.accType === 'LED')); }); // if ledMode accessory does not exist in cache, initialze as new