Skip to content

Commit

Permalink
Merge pull request #480 from dd4rk/master
Browse files Browse the repository at this point in the history
Add Eve Room 2 support for Air Quality Sensor
  • Loading branch information
arachnetech authored Nov 27, 2021
2 parents 4ddc880 + 098d2c7 commit 3948d1f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
7 changes: 5 additions & 2 deletions docs/Accessories.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -157,7 +159,8 @@ For Air Quality History (in the Eve-App) you have to use `getAirQualityPPM`.
"getCurrentRelativeHumidity": "<topic used to provide 'current relative humidity' (optional)>"
},
"airQualityValues": [ "unknown-value", "excellent-value", "good-value", "fair-value", "inferior-value", "poor-value" ],
"history": "<true to enable History service for Eve App (optional)>"
"history": "<true to enable History service for Eve App (optional)>",
"room2": "<true to enable Room 2 support for Eve App (optional)>"
}
```

Expand Down
29 changes: 28 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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;
Expand Down Expand Up @@ -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 ) {
Expand Down
19 changes: 9 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3948d1f

Please sign in to comment.