Skip to content

Commit

Permalink
Add Eve Room 2 support for Air Quality Sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
D4rkCrypto committed Oct 4, 2021
1 parent 81b983a commit d4e5a33
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 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 @@ -2089,6 +2089,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 @@ -2103,6 +2108,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 @@ -3037,7 +3056,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

0 comments on commit d4e5a33

Please sign in to comment.