mirror of
https://github.com/mtan93/homebridge.git
synced 2026-05-26 14:21:44 +01:00
added CurrentAmbientLightLevel characteristic
This commit is contained in:
+27
-1
@@ -643,6 +643,9 @@ FHEMAccessory(log, connection, s) {
|
|||||||
if( s.Readings.humidity )
|
if( s.Readings.humidity )
|
||||||
this.mappings.humidity = { reading: 'humidity' };
|
this.mappings.humidity = { reading: 'humidity' };
|
||||||
|
|
||||||
|
if( s.Readings.luminosity )
|
||||||
|
this.mappings.light = { reading: 'luminosity' };
|
||||||
|
|
||||||
if( s.Readings.voc )
|
if( s.Readings.voc )
|
||||||
this.mappings.airquality = { reading: 'voc' };
|
this.mappings.airquality = { reading: 'voc' };
|
||||||
|
|
||||||
@@ -815,6 +818,8 @@ FHEMAccessory(log, connection, s) {
|
|||||||
log( s.Internals.NAME + ' has temperature ['+ this.mappings.temperature.reading +']' );
|
log( s.Internals.NAME + ' has temperature ['+ this.mappings.temperature.reading +']' );
|
||||||
if( this.mappings.humidity )
|
if( this.mappings.humidity )
|
||||||
log( s.Internals.NAME + ' has humidity ['+ this.mappings.humidity.reading +']' );
|
log( s.Internals.NAME + ' has humidity ['+ this.mappings.humidity.reading +']' );
|
||||||
|
if( this.mappings.light )
|
||||||
|
log( s.Internals.NAME + ' has light ['+ this.mappings.light.reading +']' );
|
||||||
if( this.mappings.airquality )
|
if( this.mappings.airquality )
|
||||||
log( s.Internals.NAME + ' has voc ['+ this.mappings.airquality.reading +']' );
|
log( s.Internals.NAME + ' has voc ['+ this.mappings.airquality.reading +']' );
|
||||||
if( this.mappings.motor )
|
if( this.mappings.motor )
|
||||||
@@ -985,6 +990,9 @@ FHEMAccessory.prototype = {
|
|||||||
} else if( reading == 'humidity' ) {
|
} else if( reading == 'humidity' ) {
|
||||||
value = parseInt( value );
|
value = parseInt( value );
|
||||||
|
|
||||||
|
} else if( reading == 'luminosity' ) {
|
||||||
|
value = parseFloat( value ) / 0.265;
|
||||||
|
|
||||||
} else if( reading == 'voc' ) {
|
} else if( reading == 'voc' ) {
|
||||||
value = parseInt( value );
|
value = parseInt( value );
|
||||||
if( value > 1500 )
|
if( value > 1500 )
|
||||||
@@ -1329,8 +1337,11 @@ FHEMAccessory.prototype = {
|
|||||||
} else if( this.mappings.humidity ) {
|
} else if( this.mappings.humidity ) {
|
||||||
this.log(" humidity sensor service for " + this.name)
|
this.log(" humidity sensor service for " + this.name)
|
||||||
return new Service.HumiditySensor(name);
|
return new Service.HumiditySensor(name);
|
||||||
|
} else if( this.mappings.light ) {
|
||||||
|
this.log(" light sensor service for " + this.name)
|
||||||
|
return new Service.LightSensor(name);
|
||||||
} else if( this.mappings.airquality ) {
|
} else if( this.mappings.airquality ) {
|
||||||
this.log(" humidity sensor service for " + this.name)
|
this.log(" air quality sensor service for " + this.name)
|
||||||
return new Service.AirQualitySensor(name);
|
return new Service.AirQualitySensor(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1809,6 +1820,21 @@ FHEMAccessory.prototype = {
|
|||||||
}.bind(this) );
|
}.bind(this) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( this.mappings.light ) {
|
||||||
|
this.log(" light characteristic for " + this.name)
|
||||||
|
|
||||||
|
var characteristic = controlService.getCharacteristic(Characteristic.CurrentAmbientLightLevel)
|
||||||
|
|| controlService.addCharacteristic(Characteristic.CurrentAmbientLightLevel);
|
||||||
|
|
||||||
|
FHEM_subscribe(characteristic, this.mappings.light.informId, this);
|
||||||
|
characteristic.value = FHEM_cached[this.mappings.light.informId];
|
||||||
|
|
||||||
|
characteristic
|
||||||
|
.on('get', function(callback) {
|
||||||
|
this.query(this.mappings.light.reading, callback);
|
||||||
|
}.bind(this) );
|
||||||
|
}
|
||||||
|
|
||||||
if( this.mappings.airquality ) {
|
if( this.mappings.airquality ) {
|
||||||
this.log(" air quality characteristic for " + this.name)
|
this.log(" air quality characteristic for " + this.name)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user