diff --git a/binding.gyp b/binding.gyp index 626a88e..8a9b3c0 100644 --- a/binding.gyp +++ b/binding.gyp @@ -4,19 +4,6 @@ "target_name": "openzwave", "sources": [ "src/openzwave.cc" - ], - "include_dirs": [ - "deps/open-zwave/cpp/src" - "deps/open-zwave/cpp/hidapi/hidapi", - "deps/open-zwave/cpp/src", - "deps/open-zwave/cpp/src/command_classes", - "deps/open-zwave/cpp/src/platform", - "deps/open-zwave/cpp/src/platform/unix", - "deps/open-zwave/cpp/src/value_classes", - "deps/open-zwave/cpp/tinyxml" - ], - "dependencies": [ - "deps/open-zwave/libopenzwave.gyp:libopenzwave" ] } ] diff --git a/src/openzwave.cc b/src/openzwave.cc index 0939480..6355d46 100644 --- a/src/openzwave.cc +++ b/src/openzwave.cc @@ -22,11 +22,11 @@ #include #include -#include "Manager.h" -#include "Node.h" -#include "Notification.h" -#include "Options.h" -#include "Value.h" +#include +#include +#include +#include +#include using namespace v8; using namespace node; @@ -601,7 +601,7 @@ Handle OZW::SetName(const Arguments& args) /* * Switch a COMMAND_CLASS_SWITCH_BINARY on/off */ -void set_switch(uint8_t nodeid, bool state) +void set_switch(uint8_t nodeid, bool state, uint8_t instance) { NodeInfo *node; std::list::iterator vit; @@ -609,8 +609,10 @@ void set_switch(uint8_t nodeid, bool state) if ((node = get_node_info(nodeid))) { for (vit = node->values.begin(); vit != node->values.end(); ++vit) { if ((*vit).GetCommandClassId() == 0x25) { - OpenZWave::Manager::Get()->SetValue(*vit, state); - break; + if ( ! instance || (*vit).GetInstance() == instance ) { + OpenZWave::Manager::Get()->SetValue(*vit, state); + break; + } } } } @@ -620,7 +622,13 @@ Handle OZW::SwitchOn(const Arguments& args) HandleScope scope; uint8_t nodeid = args[0]->ToNumber()->Value(); - set_switch(nodeid, true); + uint8_t instance = 0; + + if ( args.Length() > 1 ) { + instance = args[1]->ToNumber()->Value(); + } + + set_switch(nodeid, true, instance); return scope.Close(Undefined()); } @@ -629,7 +637,13 @@ Handle OZW::SwitchOff(const Arguments& args) HandleScope scope; uint8_t nodeid = args[0]->ToNumber()->Value(); - set_switch(nodeid, false); + uint8_t instance = 0; + + if ( args.Length() > 1 ) { + instance = args[1]->ToNumber()->Value(); + } + + set_switch(nodeid, false, instance); return scope.Close(Undefined()); }