Skip to content

Commit

Permalink
fixed crash in event handling (single event)
Browse files Browse the repository at this point in the history
  • Loading branch information
thkl committed Dec 23, 2016
1 parent 39f27e2 commit f239148
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
24 changes: 16 additions & 8 deletions ChannelServices/HomeKitGenericService.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ HomeKitGenericService.prototype = {

var that = this;

if ((channel!=undefined) && (dp!=undefined)) {

var tp = this.transformDatapoint(dp);

if (tp[1] == 'LEVEL') {
newValue = newValue * 100;
}
Expand Down Expand Up @@ -273,6 +276,7 @@ HomeKitGenericService.prototype = {
this.cache(dp,newValue);
}
this.eventupdate = false;
}
},

mappedValue:function(dp,value) {
Expand Down Expand Up @@ -378,15 +382,19 @@ HomeKitGenericService.prototype = {


transformDatapoint : function(dp) {
var pos = dp.indexOf(":");
if (pos==-1) {
return [this.adress,dp];
if (dp) {
var pos = dp.indexOf(":");
if (pos==-1) {
return [this.adress,dp];
}
var ndp = dp.substr(pos+1,dp.length);
var nadr = this.adress.substr(0,this.adress.indexOf(":"));
var chnl = dp.substr(0,pos);
nadr = nadr + ":" + chnl;
return [nadr,ndp];
} else {
return -1;
}
var ndp = dp.substr(pos+1,dp.length);
var nadr = this.adress.substr(0,this.adress.indexOf(":"));
var chnl = dp.substr(0,pos);
nadr = nadr + ":" + chnl;
return [nadr,ndp];
},

getServices: function() {
Expand Down
4 changes: 1 addition & 3 deletions HomeMaticRPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ HomeMaticRPC.prototype.init = function() {

that.platform.foundAccessories.map(function(accessory) {
if ((accessory.adress == channel) || ((accessory.cadress != undefined) && (accessory.cadress == channel))) {
accessory.event(datapoint, value);
accessory.event(channel, datapoint, value);
}
});
callback(null,[]);
Expand All @@ -129,9 +129,7 @@ HomeMaticRPC.prototype.init = function() {
if ((accessory.adress == channel) || 
((accessory.cadress != undefined) && (accessory.cadress == channel)) || 
((accessory.deviceAdress != undefined) && (accessory.deviceAdress == deviceAdress))) {

accessory.event(channel,datapoint, value);

}

});
Expand Down
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Changelog

**** BEGINNING OF VERSION 0.0.41 the selection of channels to use with HomeKit via a CCU Subsection is mandatory

Version 0.0.62
fixed Crash in Device Event Handling

Version 0.0.61
fixed Crash in RPC

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-homematic",
"version": "0.0.61",
"version": "0.0.62",
"description": "Homematic plugin for homebridge: https://github.com/nfarina/homebridge",
"license": "ISC",
"keywords": [
Expand Down

0 comments on commit f239148

Please sign in to comment.