Skip to content

Commit

Permalink
should fix #215
Browse files Browse the repository at this point in the history
  • Loading branch information
thkl committed Mar 16, 2018
1 parent fca9117 commit c49434a
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions ChannelServices/HomeMaticHomeKitSmokeDetectorServiceIP.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,50 @@ var util = require("util");


function HomeMaticHomeKitSmokeDetectorServiceIP(log,platform, id ,name, type ,adress,special, cfg, Service, Characteristic) {
HomeMaticHomeKitSmokeDetectorServiceIP.super_.apply(this, arguments);
HomeMaticHomeKitSmokeDetectorServiceIP.super_.apply(this, arguments);
}

util.inherits(HomeMaticHomeKitSmokeDetectorServiceIP, HomeKitGenericService);


HomeMaticHomeKitSmokeDetectorServiceIP.prototype.createDeviceService = function(Service, Characteristic) {

var that = this;
var sensor = new Service["SmokeSensor"](this.name);
var state = sensor.getCharacteristic(Characteristic.SmokeDetected)
.on('get', function(callback) {
that.query("SMOKE_DETECTOR_ALARM_STATUS",function(value){
if (callback) callback(null,value);
});
}.bind(this));
var that = this;
var sensor = new Service.SmokeSensor(this.name)
this.memyselfandi = this.getClazzConfigValue('single_alarm',false)

this.currentStateCharacteristic["SMOKE_DETECTOR_ALARM_STATUS"] = state;
state.eventEnabled = true;
this.services.push(sensor);
this.remoteGetValue("SMOKE_DETECTOR_ALARM_STATUS");
var state = sensor.getCharacteristic(Characteristic.SmokeDetected)
.on('get', function(callback) {
that.query("SMOKE_DETECTOR_ALARM_STATUS",function(value){

// https://github.com/thkl/homebridge-homematic/issues/215

if ((this.memyselfandi == true) && (value==1)) {
if (callback) callback(null,value);
} else {
if (callback) callback(null,value);
}

});
}.bind(this));

this.currentStateCharacteristic["SMOKE_DETECTOR_ALARM_STATUS"] = state;
state.eventEnabled = true;
this.services.push(sensor);
this.remoteGetValue("SMOKE_DETECTOR_ALARM_STATUS");

}

HomeMaticHomeKitSmokeDetectorServiceIP.prototype.datapointEvent=function(dp,newValue) {
if (dp=='SMOKE_DETECTOR_ALARM_STATUS') {

if ((this.memyselfandi == true) && (newValue==1)) {
if (callback) callback(null,newValue);
} else {
if (callback) callback(null,newValue);
}

}
}

module.exports = HomeMaticHomeKitSmokeDetectorServiceIP;
module.exports = HomeMaticHomeKitSmokeDetectorServiceIP;

0 comments on commit c49434a

Please sign in to comment.