Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene activation/deactivation notification #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,14 @@ zwave.on('scan complete', function() {
console.log('scan complete, hit ^C to finish.');
});

zwave.on('node event', function(nodeid, eventid) {
console.log('node%d: node event %d', nodeid, eventid);
});

zwave.on('scene event', function(nodeid, sceneid) {
console.log('node%d: scene %d activated', nodeid, sceneid);
});

zwave.connect();

process.on('SIGINT', function() {
Expand Down
18 changes: 18 additions & 0 deletions src/openzwave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,24 @@ void async_cb_handler(uv_async_t *handle, int status)
args[2] = Integer::New(notif->notification);
MakeCallback(context_obj, "emit", 3, args);
break;
/*
* A node event (including scene deactivation)
*/
case OpenZWave::Notification::Type_NodeEvent:
args[0] = String::New("node event");
args[1] = Integer::New(notif->nodeid);
args[2] = Integer::New(notif->event);
MakeCallback(context_obj, "emit", 3, args);
break;
/*
* A scene activation
*/
case OpenZWave::Notification::Type_SceneEvent:
args[0] = String::New("scene event");
args[1] = Integer::New(notif->nodeid);
args[2] = Integer::New(notif->sceneid);
MakeCallback(context_obj, "emit", 3, args);
break;
/*
* Send unhandled events to stderr so we can monitor them if
* necessary.
Expand Down