diff --git a/docs/Accessories.md b/docs/Accessories.md index f23105d..22089fc 100644 --- a/docs/Accessories.md +++ b/docs/Accessories.md @@ -126,7 +126,9 @@ The filter life level is used to indicate remaining filter life level in percent Air quality state can be `UNKNOWN`, `EXCELLENT`, `GOOD`, `FAIR`, `INFERIOR` or `POOR`. To use different values, specify them in **airQualityValues** in that order. -For Air Quality History (in the Eve-App) you have to use `getAirQualityPPM`. +For Air Quality History (in the Eve-App) you have to use `getVOCDensity` (Eve Room 2) or `getAirQualityPPM` (Eve Room 1). + +History records need to be cleared when Migrating from Room 1 to Room 2 because they are not compatible. ```javascript { @@ -157,7 +159,8 @@ For Air Quality History (in the Eve-App) you have to use `getAirQualityPPM`. "getCurrentRelativeHumidity": "" }, "airQualityValues": [ "unknown-value", "excellent-value", "good-value", "fair-value", "inferior-value", "poor-value" ], - "history": "" + "history": "", + "room2": "" } ``` diff --git a/index.js b/index.js index 5f99ffe..f894f64 100644 --- a/index.js +++ b/index.js @@ -2128,6 +2128,11 @@ function makeThing( log, accessoryConfig, api ) { floatCharacteristic( service, 'airQualityPPM', Eve.Characteristics.AirParticulateDensity, null, config.topics.getAirQualityPPM ); } + // Eve.Characteristics.TemperatureDisplayUnits (Eve Room 2 only) + function characteristic_TemperatureDisplayUnits( service ) { + stringCharacteristic( service, 'temperatureDisplayUnits', Characteristic.TemperatureDisplayUnits, null, 'Celsius' ) + } + // History for Air Quality (Eve-only) function history_AirQualityPPM( historySvc ) { if( config.topics.getAirQualityPPM ) { @@ -2142,6 +2147,20 @@ function makeThing( log, accessoryConfig, api ) { } } + // History for Air Quality (Eve Room 2 only) + function history_VOCDensity( historySvc ) { + if( config.topics.getVOCDensity ) { + // additional MQTT subscription instead of set-callback due to correct averaging: + mqttSubscribe( config.topics.getVOCDensity, 'VOCDensity', function( topic, message ) { + var logEntry = { + time: Math.floor( Date.now() / 1000 ), // seconds (UTC) + voc: parseFloat( message ) // fakegato-history logProperty 'voc' for air quality sensor + }; + historySvc.addEntry( logEntry ); + } ); + } + } + // Characteristic.CarbonDioxideDetected function characteristic_CarbonDioxideDetected( service ) { let values = config.carbonDioxideDetectedValues; @@ -3087,7 +3106,15 @@ function makeThing( log, accessoryConfig, api ) { addSensorOptionalCharacteristics( humSvc ); services.push( humSvc ); } - if( config.history ) { + if( config.history && config.room2 ) { + let historyOptions = new HistoryOptions(); + let historySvc = new HistoryService( 'room2', { displayName: name, log: log }, historyOptions ); + characteristic_TemperatureDisplayUnits( tempSvc ); + history_VOCDensity( historySvc ); + history_CurrentTemperature( historySvc ); + history_CurrentRelativeHumidity( historySvc ); + services.push( historySvc ); + } else if( config.history ) { let historyOptions = new HistoryOptions(); let historySvc = new HistoryService( 'room', { displayName: name, log: log }, historyOptions ); if( config.topics.getAirQualityPPM ) { diff --git a/package-lock.json b/package-lock.json index 189ba30..ca715c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,14 @@ { "name": "homebridge-mqttthing", - "version": "1.1.30", + "version": "1.1.31", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "homebridge-mqttthing", - "version": "1.1.30", + "version": "1.1.31", "license": "Apache-2.0", "dependencies": { - "fakegato-history": "^0.6.1", + "fakegato-history": "^0.6.2", "homebridge-lib": "~5.1.4", "jsonpath": "^1.1.1", "mqtt": "^4.2.6" @@ -532,9 +531,9 @@ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" }, "node_modules/fakegato-history": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/fakegato-history/-/fakegato-history-0.6.1.tgz", - "integrity": "sha512-RcgxQj8LEnO/Bt1fxT3pbeLPmDlZ7hZKiW6CPvTGgOHfKYUktXAVKhzj7/Nq14MRWx6DYO+BoI4zZCQDgkob/A==", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/fakegato-history/-/fakegato-history-0.6.2.tgz", + "integrity": "sha512-G8531zKJR263yl3jN+i7eHGr9q6vEW+OkhRM7Q3INCDex5BU6pW2mKEEH/BU1/qAx1Jk/KYOEAfyti6r4VpcZQ==", "dependencies": { "debug": "^2.2.0", "googleapis": ">39.1.0" @@ -2262,9 +2261,9 @@ "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" }, "fakegato-history": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/fakegato-history/-/fakegato-history-0.6.1.tgz", - "integrity": "sha512-RcgxQj8LEnO/Bt1fxT3pbeLPmDlZ7hZKiW6CPvTGgOHfKYUktXAVKhzj7/Nq14MRWx6DYO+BoI4zZCQDgkob/A==", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/fakegato-history/-/fakegato-history-0.6.2.tgz", + "integrity": "sha512-G8531zKJR263yl3jN+i7eHGr9q6vEW+OkhRM7Q3INCDex5BU6pW2mKEEH/BU1/qAx1Jk/KYOEAfyti6r4VpcZQ==", "requires": { "debug": "^2.2.0", "googleapis": ">39.1.0" diff --git a/package.json b/package.json index b0db244..b9a5a4b 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ }, "homepage": "https://github.com/arachnetech/homebridge-mqttthing#readme", "dependencies": { - "fakegato-history": "^0.6.1", + "fakegato-history": "^0.6.2", "homebridge-lib": "~5.1.4", "jsonpath": "^1.1.1", "mqtt": "^4.2.6"