Merge pull request #353 from thkl/master

HomeMatic Platform - new Devices and Bugfixing
This commit is contained in:
Nick Farina
2015-11-02 11:46:01 -08:00
2 changed files with 549 additions and 473 deletions

View File

@@ -2,9 +2,25 @@
// //
// Homematic Platform Shim for HomeBridge // Homematic Platform Shim for HomeBridge
// //
// to add the homematic platform add this to config.json. Example:
// "platforms": [
// {
// "platform": "HomeMatic",
// "name": "HomeMatic",
// "filter_device":[],
// "filter_channel":["BidCos-RF.KEQXXXXXXX:4", "BidCos-RF.LEQXXXXXXX:2"],
// "outlets":[ "BidCos-RF.KEQXXXXXXX:4","BidCos-RF.IEQXXXXXXX:1"]
//
// }
//
// V0.1 - 2015/10/29 // V0.1 - 2015/10/29
// - initial version // - initial version
// - reintegrated Homematic Platform fork from https://github.com/thkl/homebridge/tree/xmlrpc // - reintegrated Homematic Platform fork from https://github.com/thkl/homebridge/tree/xmlrpc
// 2015/10/30 thkl
// - added Rotary Sensors ; fixed thermostat
// ],
var types = require("hap-nodejs/accessories/types.js"); var types = require("hap-nodejs/accessories/types.js");
@@ -292,15 +308,16 @@ HomeMaticPlatform.prototype = {
// that.log('name', ch.name, ' -> address:', ch.address); // that.log('name', ch.name, ' -> address:', ch.address);
if ((ch.address !== undefined) && (!isChannelFiltered)) { if ((ch.address !== undefined) && (!isChannelFiltered)) {
if ((ch.type == "SWITCH") || (ch.type == "BLIND") || (ch.type == "SHUTTER_CONTACT") || (ch.type == "DIMMER") || (ch.type == "CLIMATECONTROL_RT_TRANSCEIVER") ||  (ch.type == "MOTION_DETECTOR") ||  (ch.type == "KEYMATIC")) {
// Switch found // Switch found
// Check if marked as Outlet // Check if marked as Outlet
var special = (that.outlets.indexOf(ch.address) > -1) ? "OUTLET" : undefined; var special = (that.outlets.indexOf(ch.address) > -1) ? "OUTLET" : undefined;
var accessory = new HomeMaticGenericChannel(that.log, that, ch.id, ch.name, ch.type, ch.address, special); var accessory = new HomeMaticGenericChannel(that.log, that, ch.id, ch.name, ch.type, ch.address, special);
if (accessory.sType()!=undefined) {
// support exists for this channel
that.foundAccessories.push(accessory); that.foundAccessories.push(accessory);
} }
} else { } else {
that.log(device.name + " has no address"); that.log(device.name + " has no address");
} }
@@ -313,7 +330,7 @@ HomeMaticPlatform.prototype = {
}); });
/* /*
accessory = new HomeMaticGenericChannel(that.log, that, "1234" , "DummyKM" , "KEYMATIC" , "1234"); var accessory = new HomeMaticGenericChannel(that.log, that, "1234" , "DummyKM" , "SMOKE_DETECTOR" , "1234");
that.foundAccessories.push(accessory); that.foundAccessories.push(accessory);
accessory = new HomeMaticGenericChannel(that.log, that, "5678" , "DummyBLIND" , "BLIND" , "5678"); accessory = new HomeMaticGenericChannel(that.log, that, "5678" , "DummyBLIND" , "BLIND" , "5678");
@@ -343,6 +360,12 @@ HomeMaticPlatform.prototype = {
}, },
setRegaValue: function(channel, datapoint, value) {
var rega = new RegaRequest(this.log, this.ccuIP);
rega.setValue(channel, datapoint, value);
return;
},
getValue: function(channel, datapoint, callback) { getValue: function(channel, datapoint, callback) {
if (channel.indexOf("BidCos-RF.") > -1)  { if (channel.indexOf("BidCos-RF.") > -1)  {

View File

@@ -1,8 +1,7 @@
"use strict";
var types = require("hap-nodejs/accessories/types.js"); var types = require("hap-nodejs/accessories/types.js");
function HomeMaticGenericChannel(log, platform, id, name, type, adress, special) { function HomeMaticGenericChannel(log,platform, id ,name, type ,adress,special) {
this.name = name; this.name = name;
this.type = type; this.type = type;
this.adress = adress; this.adress = adress;
@@ -12,114 +11,123 @@ function HomeMaticGenericChannel(log, platform, id, name, type, adress, special)
this.eventupdate = false; this.eventupdate = false;
this.special = special; this.special = special;
this.currentStateCharacteristic = []; this.currentStateCharacteristic = [];
this.reverseDP = []; this.datapointMappings = [];
} }
HomeMaticGenericChannel.prototype = { HomeMaticGenericChannel.prototype = {
addValueMapping: function(dp,value,mappedvalue) {
if (this.datapointMappings[dp]==undefined) {
this.datapointMappings[dp] = [];
}
this.datapointMappings[dp][value] = mappedvalue;
} ,
// Return current States // Return current States
query: function(dp, callback) { query: function(dp,callback) {
if (this.state[dp] !== undefined) { var that = this;
callback(this.state[dp]);
if (this.state[dp] != undefined) {
if (callback!=undefined){callback(this.state[dp]);}
} else { } else {
// that.log("No cached Value found start fetching and send temp 0 back"); // that.log("No cached Value found start fetching and send temp 0 back");
this.remoteGetValue(dp); this.remoteGetValue(dp);
callback(0); if (callback!=undefined){callback(0);}
} }
}, },
dpvalue: function(dp, fallback) { dpvalue:function(dp,fallback) {
if (this.state[dp] !== undefined) { if (this.state[dp] != undefined) {
return (this.state[dp]); return(this.state[dp]);
} else { } else {
return fallback; return fallback;
} }
}, },
remoteGetValue: function(dp) { remoteGetValue:function(dp) {
var that = this; var that = this;
that.platform.getValue(that.adress, dp, function(newValue) { that.platform.getValue(that.adress,dp,function(newValue) {
that.log("Remote Value Response for " + that.adress + "." + dp + "->" + newValue); that.log("Remote Value Response for " + that.adress + "." + dp + "->" + newValue);
that.eventupdate = true; that.eventupdate = true;
that.cache(dp, newValue); that.cache(dp,newValue);
that.eventupdate = false; that.eventupdate = false;
}); });
}, },
event: function(dp, newValue) { event:function(dp,newValue) {
if (dp == "LEVEL") { if (dp=="LEVEL") {
newValue = newValue * 100; newValue = newValue*100;
} }
this.eventupdate = true; this.eventupdate = true;
this.cache(dp, newValue); this.cache(dp,newValue);
this.eventupdate = false; this.eventupdate = false;
}, },
reverse: function(value) { cache:function(dp,value) {
if (value == "true") return "false";
if (value == "false") return "true";
if (value === 0) return 1;
if (value === 1) return 0;
if (value == "0") return "1";
if (value == "1") return "0";
return value;
},
cache: function(dp, value) {
var that = this; var that = this;
if ((that.reverseDP[dp] !== undefined) && (that.reverseDP[dp] === true)) {
value = that.reverse(value); // Check custom Mapping from HM to HomeKit
var map = this.datapointMappings[dp];
if (map != undefined) {
if (map[value]!=undefined) {
value = map[value];
}
} }
if (that.currentStateCharacteristic[dp] !== undefined) { if (that.currentStateCharacteristic[dp]!=undefined) {
that.currentStateCharacteristic[dp].updateValue(value, null); that.currentStateCharacteristic[dp].updateValue(value, null);
} }
this.state[dp] = value; this.state[dp] = value;
}, },
delayed: function(mode, dp, value, delay) { delayed: function(mode, dp,value,delay) {
if (this.eventupdate === true) { if (this.eventupdate==true) {
return; return;
} }
var timer = this.delayed[delay]; var timer = this.delayed[delay];
if (timer) { if( timer ) {
clearTimeout(timer); clearTimeout( timer );
} }
this.log(this.name + " delaying command " + mode + " " + dp + " with value " + value); this.log(this.name + " delaying command "+mode + " " + dp +" with value " + value);
var that = this; var that = this;
this.delayed[delay] = setTimeout(function() { this.delayed[delay] = setTimeout( function(){clearTimeout(that.delayed[delay]);that.command(mode,dp,value)}, delay?delay:100 );
clearTimeout(that.delayed[delay]);
that.command(mode, dp, value);
}, delay ? delay : 100);
}, },
command: function(mode, dp, value, callback) { command: function(mode,dp,value,callback) {
if (this.eventupdate === true) { if (this.eventupdate==true) {
return; return;
} }
var that = this; var that = this;
if (mode == "set") { if (mode == "set") {
//this.log("Send " + value + " to Datapoint " + dp + " at " + that.adress); this.log("Send " + value + " to Datapoint " + dp + " at " + that.adress);
that.platform.setValue(that.adress, dp, value); that.platform.setValue(that.adress,dp,value);
} }
if (mode == "setrega") {
this.log("Send " + value + " to Datapoint " + dp + " at " + that.adress);
that.platform.setRegaValue(that.adress,dp,value);
}
}, },
informationCharacteristics: function() { informationCharacteristics: function() {
return [{ return [
{
cType: types.NAME_CTYPE, cType: types.NAME_CTYPE,
onUpdate: null, onUpdate: null,
perms: ["pr"], perms: ["pr"],
@@ -129,7 +137,7 @@ HomeMaticGenericChannel.prototype = {
supportBonjour: false, supportBonjour: false,
manfDescription: "Name of the accessory", manfDescription: "Name of the accessory",
designedMaxLength: 255 designedMaxLength: 255
}, { },{
cType: types.MANUFACTURER_CTYPE, cType: types.MANUFACTURER_CTYPE,
onUpdate: null, onUpdate: null,
perms: ["pr"], perms: ["pr"],
@@ -139,7 +147,7 @@ HomeMaticGenericChannel.prototype = {
supportBonjour: false, supportBonjour: false,
manfDescription: "Manufacturer", manfDescription: "Manufacturer",
designedMaxLength: 255 designedMaxLength: 255
}, { },{
cType: types.MODEL_CTYPE, cType: types.MODEL_CTYPE,
onUpdate: null, onUpdate: null,
perms: ["pr"], perms: ["pr"],
@@ -149,17 +157,17 @@ HomeMaticGenericChannel.prototype = {
supportBonjour: false, supportBonjour: false,
manfDescription: "Model", manfDescription: "Model",
designedMaxLength: 255 designedMaxLength: 255
}, { },{
cType: types.SERIAL_NUMBER_CTYPE, cType: types.SERIAL_NUMBER_CTYPE,
onUpdate: null, onUpdate: null,
perms: ["pr"], perms: ["pr"],
format: "string", format: "string",
initialValue: this.adress, initialValue: this.adress ,
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "SN", manfDescription: "SN",
designedMaxLength: 255 designedMaxLength: 255
}, { },{
cType: types.IDENTIFY_CTYPE, cType: types.IDENTIFY_CTYPE,
onUpdate: null, onUpdate: null,
perms: ["pw"], perms: ["pw"],
@@ -169,12 +177,13 @@ HomeMaticGenericChannel.prototype = {
supportBonjour: false, supportBonjour: false,
manfDescription: "Identify Accessory", manfDescription: "Identify Accessory",
designedMaxLength: 1 designedMaxLength: 1
}]; }
]
}, },
controlCharacteristics: function(that) { controlCharacteristics: function(that) {
var cTypes = [{ cTypes = [{
cType: types.NAME_CTYPE, cType: types.NAME_CTYPE,
onUpdate: null, onUpdate: null,
perms: ["pr"], perms: ["pr"],
@@ -184,18 +193,18 @@ HomeMaticGenericChannel.prototype = {
supportBonjour: false, supportBonjour: false,
manfDescription: "Name of service", manfDescription: "Name of service",
designedMaxLength: 255 designedMaxLength: 255
}]; }]
if (this.type == "SWITCH") { if (this.type=="SWITCH") {
cTypes.push({ cTypes.push({
cType: types.POWER_STATE_CTYPE, cType: types.POWER_STATE_CTYPE,
onUpdate: function(value) { onUpdate: function(value) {
that.command("set", "STATE", (value == 1) ? true : false); that.command("set","STATE" , (value==1)?true:false)
}, },
onRead: function(callback) { onRead: function(callback) {
that.query("STATE", callback); that.query("STATE",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -204,40 +213,41 @@ HomeMaticGenericChannel.prototype = {
that.remoteGetValue("STATE"); that.remoteGetValue("STATE");
}, },
perms: ["pw", "pr", "ev"], perms: ["pw","pr","ev"],
format: "bool", format: "bool",
initialValue: that.dpvalue("STATE", 0), initialValue: that.dpvalue("STATE",0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Change the power state", manfDescription: "Change the power state",
designedMaxLength: 1 designedMaxLength: 1
}); });
if (this.special == "OUTLET") { if (this.special=="OUTLET") {
cTypes.push({ cTypes.push({
cType: types.OUTLET_IN_USE_CTYPE, cType: types.OUTLET_IN_USE_CTYPE,
onRead: function(callback) { onRead: function(callback) {
callback(true); callback(true);
}, },
perms: ["pr", "ev"], perms: ["pr","ev"],
format: "bool", format: "bool",
initialValue: true, initialValue: true,
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Is Outlet in Use", manfDescription: "Is Outlet in Use",
designedMaxLength: 1 designedMaxLength: 1
}); })
} }
} }
if (this.type == "KEYMATIC") { if (this.type=="KEYMATIC") {
cTypes.push({ cTypes.push(
{
cType: types.CURRENT_LOCK_MECHANISM_STATE_CTYPE, cType: types.CURRENT_LOCK_MECHANISM_STATE_CTYPE,
onRead: function(callback) { onRead: function(callback) {
that.query("STATE", callback); that.query("STATE",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -246,46 +256,49 @@ HomeMaticGenericChannel.prototype = {
that.remoteGetValue("STATE"); that.remoteGetValue("STATE");
}, },
perms: ["pr", "ev"], perms: ["pr","ev"],
format: "bool", format: "bool",
initialValue: that.dpvalue("STATE", 0), initialValue: that.dpvalue("STATE",0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Current State of your Lock", manfDescription: "Current State of your Lock",
designedMaxLength: 1 designedMaxLength: 1
}, { },
{
cType: types.TARGET_LOCK_MECHANISM_STATE_CTYPE, cType: types.TARGET_LOCK_MECHANISM_STATE_CTYPE,
onUpdate: function(value) { onUpdate: function(value) {
that.command("set", "STATE", (value == 1) ? "true" : "false"); that.command("set","STATE",(value==1)?"true":"false")
}, },
onRead: function(callback) { onRead: function(callback) {
that.query("STATE", callback); that.query("STATE",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
that.reverseDP["STATE"] = true; that.addValueMapping("STATE","1",0);
that.addValueMapping("STATE","0",1);
that.currentStateCharacteristic["STATE"] = characteristic; that.currentStateCharacteristic["STATE"] = characteristic;
characteristic.eventEnabled = true; characteristic.eventEnabled = true;
that.remoteGetValue("STATE"); that.remoteGetValue("STATE");
}, },
perms: ["pw", "pr", "ev"], perms: ["pw","pr","ev"],
format: "bool", format: "bool",
initialValue: that.dpvalue("STATE", 0), initialValue: that.dpvalue("STATE",0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Target State of your Lock", manfDescription: "Target State of your Lock",
designedMaxLength: 1 designedMaxLength: 1
}, }
,
{ {
cType: types.TARGET_DOORSTATE_CTYPE, cType: types.TARGET_DOORSTATE_CTYPE,
onUpdate: function(value) { onUpdate: function(value) {
that.command("set", "OPEN", "true"); that.command("set","OPEN" , "true")
}, },
onRead: function(callback) { onRead: function(callback) {
@@ -297,7 +310,7 @@ HomeMaticGenericChannel.prototype = {
characteristic.eventEnabled = true; characteristic.eventEnabled = true;
}, },
perms: ["pw", "pr", "ev"], perms: ["pw","pr","ev"],
format: "bool", format: "bool",
initialValue: 1, initialValue: 1,
supportEvents: false, supportEvents: false,
@@ -306,17 +319,21 @@ HomeMaticGenericChannel.prototype = {
designedMaxLength: 1 designedMaxLength: 1
} }
); );
} }
if (this.type == "DIMMER") {
if (this.type=="DIMMER") {
cTypes.push({ cTypes.push({
cType: types.POWER_STATE_CTYPE, cType: types.POWER_STATE_CTYPE,
onUpdate: function(value) { onUpdate: function(value) {
that.command("set", "LEVEL", (value == true) ? "1" : "0"); that.command("set","LEVEL" , (value==true) ? "1" : "0")
}, },
onRead: function(callback) { onRead: function(callback) {
that.query("LEVEL", callback); that.query("LEVEL",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -325,21 +342,22 @@ HomeMaticGenericChannel.prototype = {
that.remoteGetValue("LEVEL"); that.remoteGetValue("LEVEL");
}, },
perms: ["pw", "pr", "ev"], perms: ["pw","pr","ev"],
format: "bool", format: "bool",
initialValue: (that.dpvalue("LEVEL") > 0, 0), initialValue: (that.dpvalue("LEVEL")>0,0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Change the power state", manfDescription: "Change the power state",
designedMaxLength: 1 designedMaxLength: 1
}, { },
{
cType: types.BRIGHTNESS_CTYPE, cType: types.BRIGHTNESS_CTYPE,
onUpdate: function(value) { onUpdate: function(value) {
that.delayed("set", "LEVEL", String(value / 100), 100); that.delayed("set","LEVEL" , String(value/100),100);
}, },
onRead: function(callback) { onRead: function(callback) {
that.query("LEVEL", callback); that.query("LEVEL",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -349,9 +367,9 @@ HomeMaticGenericChannel.prototype = {
}, },
perms: ["pw", "pr", "ev"], perms: ["pw","pr","ev"],
format: "int", format: "int",
initialValue: that.dpvalue("LEVEL", 0), initialValue: that.dpvalue("LEVEL",0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Adjust Brightness of Light", manfDescription: "Adjust Brightness of Light",
@@ -362,12 +380,15 @@ HomeMaticGenericChannel.prototype = {
}); });
} }
if (this.type == "BLIND") {
cTypes.push({
if (this.type=="BLIND") {
cTypes.push(
{
cType: types.WINDOW_COVERING_CURRENT_POSITION_CTYPE, cType: types.WINDOW_COVERING_CURRENT_POSITION_CTYPE,
onRead: function(callback) { onRead: function(callback) {
that.query("LEVEL", callback); that.query("LEVEL",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -376,9 +397,9 @@ HomeMaticGenericChannel.prototype = {
that.remoteGetValue("LEVEL"); that.remoteGetValue("LEVEL");
}, },
perms: ["pr", "ev"], perms: ["pr","ev"],
format: "int", format: "int",
initialValue: that.dpvalue("LEVEL", 0), initialValue: that.dpvalue("LEVEL",0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Current Blind Position", manfDescription: "Current Blind Position",
@@ -392,12 +413,12 @@ HomeMaticGenericChannel.prototype = {
cType: types.WINDOW_COVERING_TARGET_POSITION_CTYPE, cType: types.WINDOW_COVERING_TARGET_POSITION_CTYPE,
onUpdate: function(value) { onUpdate: function(value) {
that.delayed("set", "LEVEL", String(value / 100), 100); that.delayed("set","LEVEL" , String(value/100),100);
}, },
onRead: function(callback) { onRead: function(callback) {
that.query("LEVEL", callback); that.query("LEVEL",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -406,9 +427,9 @@ HomeMaticGenericChannel.prototype = {
that.remoteGetValue("LEVEL"); that.remoteGetValue("LEVEL");
}, },
perms: ["pw", "pr", "ev"], perms: ["pw","pr","ev"],
format: "int", format: "int",
initialValue: that.dpvalue("LEVEL", 0), initialValue: that.dpvalue("LEVEL",0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Target Blind Position", manfDescription: "Target Blind Position",
@@ -416,11 +437,12 @@ HomeMaticGenericChannel.prototype = {
designedMaxValue: 100, designedMaxValue: 100,
designedMinStep: 1, designedMinStep: 1,
unit: "%" unit: "%"
}, { },
{
cType: types.WINDOW_COVERING_OPERATION_STATE_CTYPE, cType: types.WINDOW_COVERING_OPERATION_STATE_CTYPE,
onRead: function(callback) { onRead: function(callback) {
that.query("DIRECTION", callback); that.query("DIRECTION",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -429,9 +451,9 @@ HomeMaticGenericChannel.prototype = {
that.remoteGetValue("DIRECTION"); that.remoteGetValue("DIRECTION");
}, },
perms: ["pr", "ev"], perms: ["pr","ev"],
format: "int", format: "int",
initialValue: that.dpvalue("DIRECTION", 0), initialValue: that.dpvalue("DIRECTION",0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Operating State ", manfDescription: "Operating State ",
@@ -443,12 +465,15 @@ HomeMaticGenericChannel.prototype = {
); );
} }
if (this.type == "SHUTTER_CONTACT") { // Simple Contact (Magnet)
cTypes.push({
if (this.type=="SHUTTER_CONTACT") {
cTypes.push(
{
cType: types.CONTACT_SENSOR_STATE_CTYPE, cType: types.CONTACT_SENSOR_STATE_CTYPE,
onRead: function(callback) { onRead: function(callback) {
that.query("STATE", callback); that.query("STATE",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -457,21 +482,51 @@ HomeMaticGenericChannel.prototype = {
that.remoteGetValue("STATE"); that.remoteGetValue("STATE");
}, },
perms: ["pr", "ev"], perms: ["pr","ev"],
format: "bool", format: "bool",
initialValue: that.dpvalue("STATE", 0), initialValue: that.dpvalue("STATE",0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Current State" manfDescription: "Current State"
}); });
} }
if (this.type == "MOTION_DETECTOR") { // Rotary Handle
cTypes.push({ if (this.type=="ROTARY_HANDLE_SENSOR") {
cTypes.push(
{
cType: types.CONTACT_SENSOR_STATE_CTYPE,
onRead: function(callback) {
that.query("STATE",callback);
},
onRegister: function(characteristic) {
that.addValueMapping("STATE","2",1);
that.currentStateCharacteristic["STATE"] = characteristic;
characteristic.eventEnabled = true;
that.remoteGetValue("STATE");
},
perms: ["pr","ev"],
format: "bool",
initialValue: that.dpvalue("STATE",0),
supportEvents: false,
supportBonjour: false,
manfDescription: "Current State"
});
}
// Motion Detector
if (this.type=="MOTION_DETECTOR") {
cTypes.push(
{
cType: types.MOTION_DETECTED_CTYPE, cType: types.MOTION_DETECTED_CTYPE,
onRead: function(callback) { onRead: function(callback) {
that.query("MOTION", callback); that.query("MOTION",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -480,56 +535,59 @@ HomeMaticGenericChannel.prototype = {
that.remoteGetValue("MOTION"); that.remoteGetValue("MOTION");
}, },
perms: ["pr", "ev"], perms: ["pr","ev"],
format: "bool", format: "bool",
initialValue: that.dpvalue("MOTION", 0), initialValue: that.dpvalue("MOTION",0),
supportEvents: false, supportEvents: false,
supportBonjour: false, supportBonjour: false,
manfDescription: "Current Motion State" manfDescription: "Current Motion State"
}); });
} }
if (this.type == "CLIMATECONTROL_RT_TRANSCEIVER") { // Smoke Detector
if (this.type=="SMOKE_DETECTOR") {
cTypes.push(
{
cType: "00000076-0000-1000-8000-0026BB765291",
onRead: function(callback) {
that.query("STATE",callback);
},
onRegister: function(characteristic) {
that.currentStateCharacteristic["STATE"] = characteristic;
characteristic.eventEnabled = true;
that.remoteGetValue("STATE");
},
perms: ["pr","ev"],
format: "bool",
initialValue: that.dpvalue("STATE",0),
supportEvents: false,
supportBonjour: false,
manfDescription: "Smoke detected"
});
}
// Heating Device
if ((this.type=="CLIMATECONTROL_RT_TRANSCEIVER") || (this.type=="THERMALCONTROL_TRANSMIT")) {
cTypes.push({ cTypes.push({
cType: types.NAME_CTYPE, cType: types.NAME_CTYPE,onUpdate: null,perms: ["pr"],format: "string",
onUpdate: null, initialValue: this.name,supportEvents: true,supportBonjour: false,manfDescription: "Name of service",designedMaxLength: 255
perms: ["pr"],
format: "string",
initialValue: this.name,
supportEvents: true,
supportBonjour: false,
manfDescription: "Name of service",
designedMaxLength: 255
}, },
{ {
cType: types.CURRENTHEATINGCOOLING_CTYPE, cType: types.CURRENTHEATINGCOOLING_CTYPE,onUpdate: null,
onUpdate: null, perms: ["pr"],format: "int",initialValue: 1,supportEvents: false,
perms: ["pr"], supportBonjour: false,manfDescription: "Current Mode",designedMaxLength: 1,designedMinValue: 1,designedMaxValue: 1,designedMinStep: 1
format: "int",
initialValue: 1,
supportEvents: false,
supportBonjour: false,
manfDescription: "Current Mode",
designedMaxLength: 1,
designedMinValue: 1,
designedMaxValue: 1,
designedMinStep: 1
}, },
{ {
cType: types.TARGETHEATINGCOOLING_CTYPE, cType: types.TARGETHEATINGCOOLING_CTYPE,onUpdate: null,perms: ["pw","pr"],
onUpdate: null, format: "int",initialValue: 1,supportEvents: false,supportBonjour: false,manfDescription: "Target Mode",
perms: ["pw", "pr"], designedMinValue: 1,designedMaxValue: 1,designedMinStep: 1
format: "int",
initialValue: 1,
supportEvents: false,
supportBonjour: false,
manfDescription: "Target Mode",
designedMinValue: 1,
designedMaxValue: 1,
designedMinStep: 1
}, },
{ {
@@ -537,7 +595,7 @@ HomeMaticGenericChannel.prototype = {
onUpdate: null, onUpdate: null,
onRead: function(callback) { onRead: function(callback) {
that.query("ACTUAL_TEMPERATURE", callback); that.query("ACTUAL_TEMPERATURE",callback);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
@@ -545,96 +603,90 @@ HomeMaticGenericChannel.prototype = {
characteristic.eventEnabled = true; characteristic.eventEnabled = true;
that.remoteGetValue("ACTUAL_TEMPERATURE"); that.remoteGetValue("ACTUAL_TEMPERATURE");
}, },
perms: ["pr", "ev"], perms: ["pw","pr","ev"], perms: ["pr"],format: "double",
format: "double", initialValue: that.dpvalue("ACTUAL_TEMPERATURE",20),
initialValue: that.dpvalue("ACTUAL_TEMPERATURE", 20), supportEvents: false,supportBonjour: false,manfDescription: "Current Temperature",unit: "celsius"
supportEvents: false,
supportBonjour: false,
manfDescription: "Current Temperature",
unit: "celsius"
}, },
{ {
cType: types.TARGET_TEMPERATURE_CTYPE, cType: types.TARGET_TEMPERATURE_CTYPE,
onUpdate: function(value) { onUpdate: function(value) {
that.delayed("set", "SET_TEMPERATURE", value, 500); if (that.state["CONTROL_MODE"]!=1) {
that.delayed("setrega", "MANU_MODE",value,500);
that.state["CONTROL_MODE"]=1; // set to Manual Mode
} else {
that.delayed("setrega", "SET_TEMPERATURE", value,500);
}
}, },
onRead: function(callback) { onRead: function(callback) {
that.query("SET_TEMPERATURE", callback); that.query("SET_TEMPERATURE",callback);
that.query("CONTROL_MODE",undefined);
}, },
onRegister: function(characteristic) { onRegister: function(characteristic) {
that.currentStateCharacteristic["SET_TEMPERATURE"] = characteristic; that.currentStateCharacteristic["SET_TEMPERATURE"] = characteristic;
characteristic.eventEnabled = true; characteristic.eventEnabled = true;
that.remoteGetValue("SET_TEMPERATURE"); that.remoteGetValue("SET_TEMPERATURE");
that.remoteGetValue("CONTROL_MODE");
}, },
perms: ["pw", "pr", "ev"], perms: ["pw","pr","ev"],format: "double",
format: "double", initialValue: that.dpvalue("SET_TEMPERATURE",16),
initialValue: that.dpvalue("SET_TEMPERATURE", 16), supportEvents: false,supportBonjour: false, manfDescription: "Target Temperature",
supportEvents: false, designedMinValue: 16,designedMaxValue: 38,designedMinStep: 1,unit: "celsius"
supportBonjour: false,
manfDescription: "Target Temperature",
designedMinValue: 16,
designedMaxValue: 38,
designedMinStep: 1,
unit: "celsius"
}, },
{ {
cType: types.TEMPERATURE_UNITS_CTYPE, cType: types.TEMPERATURE_UNITS_CTYPE,onRead: null,
onRead: null, perms: ["pr"],format: "int",initialValue: 0,supportEvents: false,
perms: ["pr"], supportBonjour: false,manfDescription: "Current Temperature Unit",unit: "celsius"
format: "int",
initialValue: 0,
supportEvents: false,
supportBonjour: false,
manfDescription: "Current Temperature Unit",
unit: "celsius"
} }
); );
} }
return cTypes; return cTypes
}, },
sType: function() { sType: function() {
if (this.type == "SWITCH") { if (this.type=="SWITCH") {
if (this.special == "OUTLET") { if (this.special=="OUTLET") {
return types.OUTLET_STYPE; return types.OUTLET_STYPE;
} else { } else {
return types.LIGHTBULB_STYPE; return types.LIGHTBULB_STYPE;
} }
} }
if (this.type == "DIMMER") { if (this.type=="DIMMER") {
return types.LIGHTBULB_STYPE; return types.LIGHTBULB_STYPE;
} }
if (this.type == "BLIND") { if (this.type=="BLIND") {
return types.WINDOW_COVERING_STYPE; return types.WINDOW_COVERING_STYPE;
} }
if (this.type == "CLIMATECONTROL_RT_TRANSCEIVER") { if ((this.type=="CLIMATECONTROL_RT_TRANSCEIVER") || (this.type=="THERMALCONTROL_TRANSMIT")) {
return types.THERMOSTAT_STYPE; return types.THERMOSTAT_STYPE;
} }
if (this.type == "SHUTTER_CONTACT") { if ((this.type=="SHUTTER_CONTACT") || (this.type=="ROTARY_HANDLE_SENSOR")) {
return types.CONTACT_SENSOR_STYPE; return types.CONTACT_SENSOR_STYPE;
} }
if (this.type == "MOTION_DETECTOR") { if (this.type=="MOTION_DETECTOR") {
return types.MOTION_SENSOR_STYPE; return types.MOTION_SENSOR_STYPE
} }
if (this.type == "KEYMATIC") { if (this.type=="KEYMATIC") {
return types.LOCK_MECHANISM_STYPE; return types.LOCK_MECHANISM_STYPE
} }
if (this.type=="SMOKE_DETECTOR") {
return "00000087-0000-1000-8000-0026BB765291";
}
}, },
@@ -643,12 +695,13 @@ HomeMaticGenericChannel.prototype = {
var that = this; var that = this;
var services = [{ var services = [{
sType: types.ACCESSORY_INFORMATION_STYPE, sType: types.ACCESSORY_INFORMATION_STYPE,
characteristics: this.informationCharacteristics() characteristics: this.informationCharacteristics(),
}, { },
{
sType: this.sType(), sType: this.sType(),
characteristics: this.controlCharacteristics(that) characteristics: this.controlCharacteristics(that)
}]; }];
this.log("Loaded services for " + this.name); this.log("Loaded services for " + this.name)
return services; return services;
} }
}; };