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

Issue:291 add device metadata #336

Merged
merged 3 commits into from
Nov 5, 2019
Merged
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
18 changes: 18 additions & 0 deletions lib/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,21 @@ var LogLevel;
LogLevel[LogLevel["DebugMessagesAndHigher"] = 8] = "DebugMessagesAndHigher";
LogLevel[LogLevel["ProtocolInformationAndHigher"] = 9] = "ProtocolInformationAndHigher";
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
var MetaDataFields;
(function (MetaDataFields) {
MetaDataFields[MetaDataFields["OzwInfoPage_URL"] = 0] = "OzwInfoPage_URL";
MetaDataFields[MetaDataFields["ZWProductPage_URL"] = 1] = "ZWProductPage_URL";
MetaDataFields[MetaDataFields["ProductPic"] = 2] = "ProductPic";
MetaDataFields[MetaDataFields["Description"] = 3] = "Description";
MetaDataFields[MetaDataFields["ProductManual_URL"] = 4] = "ProductManual_URL";
MetaDataFields[MetaDataFields["ProductPage_URL"] = 5] = "ProductPage_URL";
MetaDataFields[MetaDataFields["InclusionHelp"] = 6] = "InclusionHelp";
MetaDataFields[MetaDataFields["ExclusionHelp"] = 7] = "ExclusionHelp";
MetaDataFields[MetaDataFields["ResetHelp"] = 8] = "ResetHelp";
MetaDataFields[MetaDataFields["WakeupHelp"] = 9] = "WakeupHelp";
MetaDataFields[MetaDataFields["ProductSupport_URL"] = 10] = "ProductSupport_URL";
MetaDataFields[MetaDataFields["Frequency"] = 11] = "Frequency";
MetaDataFields[MetaDataFields["Name"] = 12] = "Name";
MetaDataFields[MetaDataFields["Identifier"] = 13] = "Identifier";
MetaDataFields[MetaDataFields["Invalid"] = 255] = "Invalid";
})(MetaDataFields = exports.MetaDataFields || (exports.MetaDataFields = {}));
18 changes: 18 additions & 0 deletions lib/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@ export enum LogLevel {
DebugMessagesAndHigher = 8,
ProtocolInformationAndHigher = 9
}

export enum MetaDataFields {
OzwInfoPage_URL = 0,
ZWProductPage_URL = 1,
ProductPic = 2,
Description = 3,
ProductManual_URL = 4,
ProductPage_URL = 5,
InclusionHelp = 6,
ExclusionHelp = 7,
ResetHelp = 8,
WakeupHelp = 9,
ProductSupport_URL = 10,
Frequency = 11,
Name = 12,
Identifier = 13,
Invalid = 255
}
55 changes: 48 additions & 7 deletions src/openzwave-nodes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ namespace OZW {
OZWManagerAssign(result, IsNodeSecurityDevice, homeid, nodeid);
info.GetReturnValue().Set(Nan::New<Boolean>(result));
}

// ===================================================================
NAN_METHOD(OZW::GetNodePlusTypeString)
// ===================================================================
{
Nan::HandleScope scope;
CheckMinArgs(1, "nodeid");
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
::std::string result = OpenZWave::Manager::Get()->GetNodePlusTypeString(homeid, nodeid);
info.GetReturnValue().Set(Nan::New<String>(result.c_str()).ToLocalChecked());
}
Expand All @@ -324,7 +324,7 @@ namespace OZW {
{
Nan::HandleScope scope;
CheckMinArgs(1, "nodeid");
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
::std::string result = OpenZWave::Manager::Get()->GetNodeRoleString(homeid, nodeid);
info.GetReturnValue().Set(Nan::New<String>(result.c_str()).ToLocalChecked());
}
Expand All @@ -336,7 +336,7 @@ namespace OZW {
{
Nan::HandleScope scope;
CheckMinArgs(1, "nodeid");
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint8 result = OpenZWave::Manager::Get()->GetNodePlusType(homeid, nodeid);
info.GetReturnValue().Set(Nan::New<Integer>(result));
}
Expand All @@ -348,7 +348,7 @@ namespace OZW {
{
Nan::HandleScope scope;
CheckMinArgs(1, "nodeid");
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint8 result = OpenZWave::Manager::Get()->GetNodeRole(homeid, nodeid);
info.GetReturnValue().Set(Nan::New<Integer>(result));
}
Expand All @@ -360,7 +360,7 @@ namespace OZW {
{
Nan::HandleScope scope;
CheckMinArgs(1, "nodeid");
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
::std::string result = OpenZWave::Manager::Get()->GetNodeDeviceTypeString(homeid, nodeid);
info.GetReturnValue().Set(Nan::New<String>(result.c_str()).ToLocalChecked());
}
Expand All @@ -372,7 +372,7 @@ namespace OZW {
{
Nan::HandleScope scope;
CheckMinArgs(1, "nodeid");
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint16 result = OpenZWave::Manager::Get()->GetNodeDeviceType(homeid, nodeid);
info.GetReturnValue().Set(Nan::New<Integer>(result));
}
Expand Down Expand Up @@ -648,4 +648,45 @@ namespace OZW {
OZWManager( SetNodeProductName, homeid, nodeid, name);
}

#if OPENZWAVE_16
/*
*
*/
// ===================================================================
NAN_METHOD(OZW::GetMetaData)
// ===================================================================
{
Nan::HandleScope scope;
CheckMinArgs(2, "nodeid, metadata");
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
OpenZWave::Node::MetaDataFields metadata = static_cast<OpenZWave::Node::MetaDataFields>(Nan::To<int>(info[1]).ToChecked());
::std::string result("");
OZWManagerAssign(result, GetMetaData, homeid, nodeid, metadata);
info.GetReturnValue().Set(Nan::New<String>(result.c_str()).ToLocalChecked());
}

/*
*
*/
// ===================================================================
NAN_METHOD(OZW::GetChangeLog)
// ===================================================================
{
Nan::HandleScope scope;
CheckMinArgs(2, "nodeid, revision");
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
uint32_t revision = Nan::To<Number>(info[1]).ToLocalChecked()->Value();

OpenZWave::Node::ChangeLogEntry result;
OZWManagerAssign(result, GetChangeLog, homeid, nodeid, revision);

Local <Object> changeLog = Nan::New<Object>();
AddStringProp(changeLog, author, result.author);
AddStringProp(changeLog, date, result.date);
AddIntegerProp(changeLog, revision, result.revision);
AddStringProp(changeLog, description, result.description);
info.GetReturnValue().Set(changeLog);
}
#endif

}
4 changes: 4 additions & 0 deletions src/openzwave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ namespace OZW {
Nan::SetPrototypeMethod(t, "isNodeBeamingDevice", OZW::IsNodeBeamingDevice); // ** new
Nan::SetPrototypeMethod(t, "isNodeRoutingDevice", OZW::IsNodeRoutingDevice); // ** new
Nan::SetPrototypeMethod(t, "isNodeSecurityDevice", OZW::IsNodeSecurityDevice); // ** new
#if OPENZWAVE_16
Nan::SetPrototypeMethod(t, "getMetaData", OZW::GetMetaData);
Nan::SetPrototypeMethod(t, "getChangeLog", OZW::GetChangeLog);
#endif
// openzwave-values.cc
Nan::SetPrototypeMethod(t, "setValue", OZW::SetValue);
Nan::SetPrototypeMethod(t, "setValueLabel", OZW::SetValueLabel);
Expand Down
5 changes: 5 additions & 0 deletions src/openzwave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ namespace OZW {
static NAN_METHOD(IsNodeBeamingDevice);
static NAN_METHOD(IsNodeRoutingDevice);
static NAN_METHOD(IsNodeSecurityDevice);

// getter+setter pairs
static NAN_METHOD(GetNodeLocation);
static NAN_METHOD(SetNodeLocation);
Expand Down Expand Up @@ -165,6 +166,10 @@ namespace OZW {
static NAN_METHOD(GetNodeProductType);
static NAN_METHOD(GetNodeProductId);
static NAN_METHOD(GetNodeNeighbors);
#if OPENZWAVE_16
static NAN_METHOD(GetMetaData);
static NAN_METHOD(GetChangeLog);
#endif
// openzwave-values.cc
static NAN_METHOD(SetValue);
static NAN_METHOD(SetValueLabel);
Expand Down
74 changes: 70 additions & 4 deletions types/openzwave-shared.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ declare module "openzwave-shared" {
loc: string;
}

export interface ChangeLogEntry
{
author: string;
date: string;
revision: number;
description: string;
}

export enum Notification {
MessageComplete = 0,
Timeout = 1,
Expand Down Expand Up @@ -63,6 +71,24 @@ declare module "openzwave-shared" {
ProtocolInformationAndHigher = 9
}

export enum MetaDataFields {
OzwInfoPage_URL = 0,
ZWProductPage_URL = 1,
ProductPic = 2,
Description = 3,
ProductManual_URL = 4,
ProductPage_URL = 5,
InclusionHelp = 6,
ExclusionHelp = 7,
ResetHelp = 8,
WakeupHelp = 9,
ProductSupport_URL = 10,
Frequency = 11,
Name = 12,
Identifier = 13,
Invalid = 255
}

export interface DriverStats {
SOFCnt: number;
ACKWaiting: number;
Expand Down Expand Up @@ -160,15 +186,15 @@ declare module "openzwave-shared" {
*/
AppendLogFile: boolean;
/**
*
* Save (to file) log messages equal to or above LogLevel_Detail
*/
SaveLogLevel: LogLevel;
/**
*
* Save (in RAM) log messages equal to or above LogLevel_Debug
*/
QueueLogLevel: ZWave.LogLevel;
/**
*
* Default is to never dump RAM-stored log messages
*/
DumpTriggerLevel: ZWave.LogLevel;
/**
Expand Down Expand Up @@ -230,7 +256,43 @@ declare module "openzwave-shared" {
/**
* Should we refresh all UserCodes in the UserCode CC when we start up
*/
RefreshAllUserCodes: boolean;
RefreshAllUserCodes: boolean;
/**
* Should we send the Node/Value Notifications on Driver Unloading - Read comments in Driver::~Driver() method about possible race conditions
*/
NotifyOnDriverUnload: boolean;
/**
* Alters how OZW determines when to Encrypt Messages to certain CommandClasses.
* Options are:
* "ESSENTIAL" - Those CommandClasses that MUST be encrypted.
* "SUPPORTED" (default) is any CommandClass advertisied in the SecureNIF frame
* "CUSTOM" - A list of CommandClasses specified in the "CustomSecureCC" option
*/
SecurityStrategy: 'ESSENTIAL' | 'SUPPORTED' | 'CUSTOM'
/**
* What List of Custom CC should we always encrypt if SecurityStrategy is CUSTOM
*/
CustomSecuredCC: string;
/**
* if we recieve a clear text message for a CC that is Secured, should we drop the message
*/
EnforceSecureReception: boolean;
/**
* if we should automatically update config files for devices if they are out of date
*/
AutoUpdateConfigFile: boolean;
/**
* Should we automatically Reload Nodes after a update
*/
ReloadAfterUpdate: 'AWAKE' | 'NEVER' | 'IMMEDIATE';
/**
* Language we should use
*/
Language: string;
/**
* Should we include the Instance Label in Value Labels on MultiInstance Devices
*/
IncludeInstanceLabel: boolean;
}
}

Expand Down Expand Up @@ -652,6 +714,10 @@ declare module "openzwave-shared" {

getNodeProductId(nodeId: number): string;

getMetaData(nodeId: number, metadata: ZWave.MetaDataFields): string;

getChangeLog(nodeId: number, revision: number): ZWave.ChangeLogEntry;

// Exposed by "openzwave-values.cc"

/**
Expand Down