Troubles Writing My First Automation Module
Posted: 15 Jul 2014 06:31
Yet another newbie here, so I apologize if this is simple. I received my RaspberryPi and Razberry, and have a door contact sensor. Just to get my feet wet I want to write an Automation module that logs something when the door is opened and closed. I tried writing a module to do just that, but it doesn't log anything.
The logs show my module being instantiated:
From a hardware standpoint everything seems to be working. When I open and close my door the log on the server shows:
But nothing from my calls to debugPrint ever show up in the log. I've tried a number of ways of binding a function to the device, but they all either fail with errors about not being able to access a property or call a function on an undefined value, or nothing ever gets logged.
Any suggestions? Thanks!
Code: Select all
function FrontDoor( id, controller ) {
FrontDoor.super_.call(this, id, controller);
}
inherits(FrontDoor, AutomationModule);
_module = FrontDoor;
FrontDoor.prototype.init = function __init__( config ) {
FrontDoor.super_.prototype.init.call(this, config);
var self = this;
zway.devices[2].data.bind(function(d) {
// TODO: Do something when the binary sensor changes.
debugPrint(d);
});
};
FrontDoor.prototype.stop = function __stop__() {
FrontDoor.super_.prototype.stop.call( this );
};
Code: Select all
[2014-07-15 03:12:55.278] Instantiating module 6 from class FrontDoor
[2014-07-15 03:12:55.283] --- Starting module Front door automation
Code: Select all
[2014-07-15 03:13:23.225] RECEIVED: ( 01 09 00 04 00 02 03 30 03 FF 3F )
[2014-07-15 03:13:23.226] SENT ACK
[2014-07-15 03:13:23.228] SETDATA devices.2.data.lastReceived = 0 (0x00000000)
[2014-07-15 03:13:23.230] SETDATA devices.2.instances.0.commandClasses.48.data.1.level = True
[2014-07-15 03:13:23.231] SETDATA devices.2.instances.0.commandClasses.48.data.1 = Empty
[2014-07-15 03:13:23.244] RECEIVED: ( 01 09 00 04 00 02 03 20 01 FF 2D )
[2014-07-15 03:13:23.245] SENT ACK
[2014-07-15 03:13:23.246] SETDATA devices.2.data.lastReceived = 0 (0x00000000)
[2014-07-15 03:13:23.248] SETDATA devices.1.instances.0.commandClasses.32.data.srcNodeId = 2 (0x00000002)
[2014-07-15 03:13:23.249] SETDATA devices.1.instances.0.commandClasses.32.data.srcInstanceId = 0 (0x00000000)
[2014-07-15 03:13:23.261] SETDATA devices.1.instances.0.commandClasses.32.data.level = 255 (0x000000ff)
[2014-07-15 03:13:23.262] SETDATA devices.2.instances.0.commandClasses.48.data.1.level = True
[2014-07-15 03:13:23.264] SETDATA devices.2.instances.0.commandClasses.48.data.1 = Empty
[2014-07-15 03:13:24.485] RECEIVED: ( 01 09 00 04 00 02 03 30 03 00 C0 )
[2014-07-15 03:13:24.486] SENT ACK
[2014-07-15 03:13:24.487] SETDATA devices.2.data.lastReceived = 0 (0x00000000)
[2014-07-15 03:13:24.489] SETDATA devices.2.instances.0.commandClasses.48.data.1.level = False
[2014-07-15 03:13:24.491] SETDATA devices.2.instances.0.commandClasses.48.data.1 = Empty
Any suggestions? Thanks!