mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-14 22:05:07 +01:00
New Motion Sensor service
This commit is contained in:
@@ -12,7 +12,8 @@ New 2015-09-18:
|
|||||||
- Services Switch and Outlet
|
- Services Switch and Outlet
|
||||||
- Code cleanup
|
- Code cleanup
|
||||||
New 2015-09-19:
|
New 2015-09-19:
|
||||||
- GarageDoorOpener Service
|
- GarageDoorOpener Service
|
||||||
|
- MotionSensor Service
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
var Service = require("HAP-NodeJS").Service;
|
var Service = require("HAP-NodeJS").Service;
|
||||||
@@ -666,6 +667,48 @@ KNXDevice.prototype = {
|
|||||||
//iterate(myService);
|
//iterate(myService);
|
||||||
return myService;
|
return myService;
|
||||||
},
|
},
|
||||||
|
getMotionSenserService: function(config) {
|
||||||
|
// Characteristic.ContactSensorState.CONTACT_DETECTED = 0;
|
||||||
|
// Characteristic.ContactSensorState.CONTACT_NOT_DETECTED = 1;
|
||||||
|
|
||||||
|
// some sanity checks
|
||||||
|
if (config.type !== "MotionSensor") {
|
||||||
|
this.log("[ERROR] MotionSensor Service for non 'MotionSensor' service called");
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (!config.name) {
|
||||||
|
this.log("[ERROR] MotionSensor Service without 'name' property called");
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
var myService = new Service.MotionSensor(config.name,config.name);
|
||||||
|
if (config.ContactSensorState) {
|
||||||
|
this.log("MotionSensor MotionDetected characteristic enabled");
|
||||||
|
this.bindCharacteristic(myService, Characteristic.MotionDetected, "Bool", config.MotionDetected);
|
||||||
|
}
|
||||||
|
//optionals
|
||||||
|
if (config.StatusActive) {
|
||||||
|
this.log("MotionSensor StatusActive characteristic enabled");
|
||||||
|
myService.addCharacteristic(Characteristic.StatusActive);
|
||||||
|
this.bindCharacteristic(myService, Characteristic.StatusActive, "Bool", config.StatusActive);
|
||||||
|
}
|
||||||
|
if (config.StatusFault) {
|
||||||
|
this.log("MotionSensor StatusFault characteristic enabled");
|
||||||
|
myService.addCharacteristic(Characteristic.StatusFault);
|
||||||
|
this.bindCharacteristic(myService, Characteristic.StatusFault, "Bool", config.StatusFault);
|
||||||
|
}
|
||||||
|
if (config.StatusTampered) {
|
||||||
|
this.log("MotionSensor StatusTampered characteristic enabled");
|
||||||
|
myService.addCharacteristic(Characteristic.StatusTampered);
|
||||||
|
this.bindCharacteristic(myService, Characteristic.StatusTampered, "Bool", config.StatusTampered);
|
||||||
|
}
|
||||||
|
if (config.StatusLowBattery) {
|
||||||
|
this.log("MotionSensor StatusLowBattery characteristic enabled");
|
||||||
|
myService.addCharacteristic(Characteristic.StatusLowBattery);
|
||||||
|
this.bindCharacteristic(myService, Characteristic.StatusLowBattery, "Bool", config.StatusLowBattery);
|
||||||
|
}
|
||||||
|
return myService;
|
||||||
|
},
|
||||||
getOutletService: function(config) {
|
getOutletService: function(config) {
|
||||||
/**
|
/**
|
||||||
* this.addCharacteristic(Characteristic.On);
|
* this.addCharacteristic(Characteristic.On);
|
||||||
@@ -903,6 +946,9 @@ KNXDevice.prototype = {
|
|||||||
case "LockMechanism":
|
case "LockMechanism":
|
||||||
accessoryServices.push(this.getLockMechanismService(configService));
|
accessoryServices.push(this.getLockMechanismService(configService));
|
||||||
break;
|
break;
|
||||||
|
case "MotionSensor":
|
||||||
|
accessoryServices.push(this.getMotionSensorService(configService));
|
||||||
|
break;
|
||||||
case "Switch":
|
case "Switch":
|
||||||
accessoryServices.push(this.getSwitchService(configService));
|
accessoryServices.push(this.getSwitchService(configService));
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -120,6 +120,13 @@ Two kinds of addresses are supported: `"Set":"1/2/3"` is a writable group addres
|
|||||||
|
|
||||||
*ToDo here: correction of mappings, HomeKit reqires lock states UNSECURED=0, SECURED=1, JAMMED = 2, UNKNOWN=3*
|
*ToDo here: correction of mappings, HomeKit reqires lock states UNSECURED=0, SECURED=1, JAMMED = 2, UNKNOWN=3*
|
||||||
|
|
||||||
|
## MotionSensor
|
||||||
|
- MotionDetected: DPT 1.002, 1 as motion detected
|
||||||
|
|
||||||
|
- StatusActive: DPT 1.011, 1 as true
|
||||||
|
- StatusFault: DPT 1.011, 1 as true
|
||||||
|
- StatusTampered: DPT 1.011, 1 as true
|
||||||
|
- StatusLowBattery: DPT 1.011, 1 as true
|
||||||
|
|
||||||
## Outlet
|
## Outlet
|
||||||
- On: DPT 1.001, 1 as on, 0 as off
|
- On: DPT 1.001, 1 as on, 0 as off
|
||||||
|
|||||||
Reference in New Issue
Block a user