simont77 / fakegato-history

Module to emulate Elgato Eve history
MIT License
167 stars 15 forks source link

air quality history #65

Closed thncode closed 5 years ago

thncode commented 5 years ago

I am trying hard to add air quality (ppm) history with fakegato - but no luck yet. the accessory always reports "not data". is there anywhere a good example or where can I find the specific conditions for this? contactSensor and temp/humidity works for me, but not air quality. PLEASE HELP!

simont77 commented 5 years ago

Did you add the custom Eve characteristic for air quality? You should emulate Eve Room (have a look at the wiki)

simont77 commented 5 years ago

it's characteristic E863F10B-079E-48FF-8F27-9C2605A29F52

thncode commented 5 years ago

yes I did - this is within setUpServies:

this.fakeGatoHistoryService = new FakeGatoHistoryService("room", this, { storage: 'fs' });

var CustomCharacteristic = {};

CustomCharacteristic.AirQuality = function () {
    Characteristic.call(this, 'Air Quality PM25', 'E863F10B-079E-48FF-8F27-9C2605A29F52');
    this.setProps({
        format: Characteristic.Formats.UINT16,
        unit: "ppm",
        maxValue: 99999,
        minValue: 2,
        minStep: 1,
        perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
    });
    this.value = this.getDefaultValue();
};
CustomCharacteristic.AirQuality.uuid = 'E863F10B-079E-48FF-8F27-9C2605A29F52';
inherits(CustomCharacteristic.AirQuality, Characteristic);

CustomCharacteristic.EveAirQuality = function () {
    Characteristic.call(this, 'Eve Air Quality', 'E863F11B-079E-48FF-8F27-9C2605A29F52');
    this.setProps({
        format: Characteristic.Formats.FLOAT,
        unit: "ppm",
        maxValue: 5000,
        minValue: 0,
        minStep: 1,
        perms: [Characteristic.Perms.READ, Characteristic.Perms.NOTIFY]
    });
    this.value = this.getDefaultValue();
};
CustomCharacteristic.EveAirQuality.UUID = 'E863F11B-079E-48FF-8F27-9C2605A29F52';
inherits(CustomCharacteristic.EveAirQuality, Characteristic);

// AirQuality sensor
airQualitySensor = function (displayName, subtype) {
let uuid = UUIDGen.generate('airQualitySensor');
Service.call(this, displayName, uuid, subtype);

    this.addCharacteristic(Characteristic.AirQuality);
    this.addCharacteristic(CustomCharacteristic.EveAirQuality);
};
inherits(airQualitySensor, Service);
//airQualitySensor.UUID = uuid;

this.airQualityService = new Service.AirQualitySensor('Luftqualität');

this.airQualityService.getCharacteristic(Characteristic.StatusLowBattery)
.on('get', this.getStatusLowBattery.bind(this));
this.airQualityService.getCharacteristic(Characteristic.StatusActive)
.on('get', this.getStatusActive.bind(this));

this.airQualityService
.setCharacteristic(Characteristic.AirParticulateSize, '2.5um');

this.airQualityService.getCharacteristic(Characteristic.AirQuality)
.on('get', this.getAirQuality.bind(this));
this.airQualityService.getCharacteristic(CustomCharacteristic.EveAirQuality)
.on('get', this.getEveAirQuality.bind(this));
this.airQualityService.getCharacteristic(Characteristic.PM2_5Density)
.on('get', this.getPM2_5Density.bind(this));
this.airQualityService.getCharacteristic(Characteristic.PM10Density)
.on('get', this.getPM10Density.bind(this));
simont77 commented 5 years ago

did you try adding all 3 services to the accessory (temperature, humidity, airquality)? Also, add the E863F132-079E-48FF-8F27-9C2605A29F52 characteristic to the airquality service. The idea is to replicate as much as possible the Eve structure.

simont77 commented 5 years ago

Check your UUID: EveQualityPPM is E863F10B, but you are adding to your accessory E863F11B

simont77 commented 5 years ago

Try opening this with HomekitAccessorySimulator and copy the structure.

FakeRoom.hasaccessory.zip

thncode commented 5 years ago

I am one big step further: I am getting a history but no graphics. All history entries do say "UNKNOWN (xx ppm) - where is the quality assignment to measurement readings coming from???

simont77 commented 5 years ago

Try to remove the history from Eve deleting all the entries for temp, hum, and ppm. Can you post an image of what you see in the history?

thncode commented 5 years ago

img_0359 img_0358

simont77 commented 5 years ago

Have you tried with some higher value? A real Eve room upon reset starts from 450ppm, and it's already Excellent. Maybe 450 is the floor.

thncode commented 5 years ago

yes you are right. I mixed up ug/m3 (which my device is measuring) with PPM - my only problem now (and this is not fakegato related) is that I cannot find a conversion for those units...

simont77 commented 5 years ago

I don't know if there is direct conversion. Eve Room measures VOC (this is the sensor https://ams.com/documents/20143/36005/AS-MLV-P2_FS000137_2-00.pdf), and they are only expressed in ppm, while from what I see you are measuring particulate.

simont77 commented 5 years ago

Is it ok now? can I close the issue?

thncode commented 5 years ago

THX - works now!