diff --git a/CHANGELOG.md b/CHANGELOG.md index 12d65156..0728f636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/). +## v5.5.5 + * Omni occupancy detection improvments. Minimum sound level set to 47dBA based on dust sensor fan noise as guard for spurious low reading. Provide option to restart detection algorithm on Homebridge restart. + ## v5.5.4 * Omni occupancy detection improvments. Now based on minimum detected sound level + user defined offset. * Correct existing device recovery from cache on Homebridge restart. diff --git a/README.md b/README.md index 1aa50a45..bc7a870c 100755 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ See [config-sample.json](https://github.com/DMBlakeley/homebridge-awair2/blob/ma "vocMw": 72.66578273019740, "occupancyDetection": false, "occupancyOffset": 2, + "occupancyRestart": false, "logging": false, "verbose": false, "development": false, @@ -80,6 +81,7 @@ Parameter | Description `vocMw` | (OPTIONAL, default = `72.66578273019740`) The Molecular Weight (g/mol) of a reference gas or mixture that you use to convert from ppb to ug/m^3 `occupancyDetection` | (OPTIONAL - Omni only, default = `false`) Enables Omni occupancy detection based on minimum environmental sound level detected. `occupancyOffset` | (OPTIONAL - Omni only, default = `2`) Used when `occupancy detection` enabled. Offset value in dBA above background sound level to set `not occupied` level, `occupied` is 0.5dBA higher. +`occupancyRestart` | (OPTIONAL - Omni only, default = `false`, use historical data) `true` enables restart of occupancy detection algorithm on Homebridge reboot. `logging` | Whether to output logs to the Homebridge logs (OPTIONAL, default = `false`) `verbose` | Whether to log results from API data calls (OPTIONAL, default = `false`). Requires `logging` to be `true`. `development` | Enables Development mode to allow use of `test` Awair devices lacking `end user`/Awair OUI formatted Serial numbers. @@ -88,7 +90,8 @@ Parameter | Description # Resources -- Awair API: https://docs.developer.getawair.com/ +- Awair Cloud API: https://docs.developer.getawair.com/ +- Awair Local API: https://docs.google.com/document/d/1001C-ro_ig7aEyz0GiWUiiJn0M6DLj47BYWj31acesg/edit - Homebridge: https://github.com/nfarina/homebridge - Homebridge API: https://developers.homebridge.io/#/ - Homebridge examples: https://github.com/homebridge/homebridge-examples @@ -97,6 +100,6 @@ Parameter | Description - Using async-await and npm-promise with TypeScript: https://github.com/patdaburu/request-promise-typescript-example - Another Awair plugin: https://github.com/henrypoydar/homebridge-awair-glow - Reference AQ plugin: https://github.com/toto/homebridge-airrohr -- Refenerce temperature plugin: https://github.com/metbosch/homebridge-http-temperature +- Reference temperature plugin: https://github.com/metbosch/homebridge-http-temperature - AQI Calculation NPM package: https://www.npmjs.com/package/aqi-bot - Homebridge-philips-air plugin: https://github.com/Sunoo/homebridge-philips-air diff --git a/config-sample.json b/config-sample.json index 8d22507e..5f9f82cd 100644 --- a/config-sample.json +++ b/config-sample.json @@ -21,6 +21,7 @@ "vocMw": 72.66578273019740, "occupancyDetection": false, "occupancyOffset": 2, + "occupancyRestart": false, "logging": false, "verbose": false, "development": false, diff --git a/config.schema.json b/config.schema.json index aacee9cc..bbd49e70 100644 --- a/config.schema.json +++ b/config.schema.json @@ -59,7 +59,7 @@ "description": "The Molecular Weight (g/mol) of a reference gas or mixture that you use to convert from ppb to ug/m^3." }, "occupancyDetection": { - "title": "Omni - Whether to enable auto Occupancy detection based on minimum sound level.", + "title": "Omni - Whether to enable Occupancy detection based on minimum sound level.", "type": "boolean", "default": false, "description": "Omni only - enables occupancy detection based on minimum sound level + occupancyOffset value." @@ -70,6 +70,12 @@ "placeholder": 2, "description": "Omni only - Used when `occupancy detection` enabled. Offset value in dBA above background sound level to set `not occupied` level, `occupied` is 0.5dBA higher." }, + "occupancyRestart": { + "title": "Omni - restart Occupancy detection measurement on next Homebridge reboot.", + "type": "boolean", + "default": false, + "description": "Omni only - reinitialize Occupancy detection measurement on Homebridge reboot." + }, "logging": { "title": "Whether to output logs to the Homebridge logs.", "type": "boolean", @@ -121,6 +127,7 @@ "vocMw", "occupancyDetection", "occupancyOffset", + "occupancyRestart", "logging", "verbose", "development" diff --git a/package-lock.json b/package-lock.json index 8e80f205..2870d739 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "homebridge-awair2", - "version": "5.5.4", + "version": "5.5.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 776d13d6..8b39d710 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": false, "displayName": "Homebridge Awair2", "name": "homebridge-awair2", - "version": "5.5.4", + "version": "5.5.5", "description": "HomeKit integration of Awair air purifier as Dynamic Platform.", "main": "dist/index.js", "scripts": { diff --git a/src/configTypes.ts b/src/configTypes.ts index 7de59d23..d905bf4e 100644 --- a/src/configTypes.ts +++ b/src/configTypes.ts @@ -11,6 +11,7 @@ export type AwairPlatformConfig = { vocMw: number; occupancyDetection: boolean; occupancyOffset: number; + occupancyRestart: false; occupancyDetectedLevel: number; occupancyNotDetectedLevel: number; logging: boolean; diff --git a/src/index.ts b/src/index.ts index c52ecb2e..bd528517 100644 --- a/src/index.ts +++ b/src/index.ts @@ -415,10 +415,16 @@ class AwairPlatform implements DynamicPlatformPlugin { } else { // acessory exists, use data from cache if (this.config.logging) { this.log(accessory.context.name + ' exists, using data from cache'); - } + } if (accessory.context.deviceType === 'awair-omni') { this.omniPresent = true; // set flag for Occupancy detected loop } + // use Omni cache data unless 'occupancyRestart' enabled + if ((accessory.context.deviceType === 'awair-omni') && this.config.occupancyRestart) { + accessory.context.occDetectedLevel = this.occDetectedLevel; + accessory.context.occDetectedNotLevel = this.occDetectedNotLevel; + accessory.context.minSoundLevel = this.occDetectedNotLevel; + } } return; } @@ -796,8 +802,8 @@ class AwairPlatform implements DynamicPlatformPlugin { this.log('[' + accessory.context.serial + '] spl_a: ' + omniSpl_a); } - if(omniSpl_a < accessory.context.minSoundLevel) { // use context to track occupancy status for each Omni device - accessory.context.minSoundLevel = omniSpl_a; + if(omniSpl_a > 47.0 && omniSpl_a < accessory.context.minSoundLevel) { // 50dBA (±3) baseline set by dust sensor fan noise + accessory.context.minSoundLevel = omniSpl_a; // use 'context' to track occupancy status for each Omni device accessory.context.occDetectedLevel = accessory.context.minSoundLevel + this.occupancyOffset + 0.5; // dBA accessory.context.occDetectedNotLevel = accessory.context.minSoundLevel + this.occupancyOffset; // dBA if(this.config.logging) {