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

Door Condition per 1.6 specs, adds DoorSense support #2196

Open
wants to merge 5 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
6 changes: 5 additions & 1 deletion config/Localization.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Localization xmlns="https://github.com/OpenZWave/open-zwave" Revision="8">
<Localization xmlns="https://github.com/OpenZWave/open-zwave" Revision="9">
<CommandClass id="113">
<!-- Please keep Localization.xml in sync with NotificationCCTypes.xml -->
<!-- If you are adding new Types or Params, Please also consider updating ValueIDIndexesDefines.def -->
Expand Down Expand Up @@ -587,6 +587,10 @@
<Help>State of the Interior Handle Control</Help>
<Label>Inside Handle Control</Label>
</Value>
<Value index="7">
<Help>State of Latch, Bolt, and Door</Help>
<Label>Door Condition</Label>
</Value>
</CommandClass>
<CommandClass id="76">
<Label>COMMAND_CLASS_DOOR_LOCK_LOGGING</Label>
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/ValueIDIndexesDefines.def
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,8 @@ ENUM(ValueID_Index_DoorLock,
System_Config_Minutes = 3,
System_Config_Seconds = 4,
System_Config_OutsideHandles = 5,
System_Config_InsideHandles = 6
System_Config_InsideHandles = 6,
System_Config_DoorCondition = 7
);
ENUM(ValueID_Index_DoorLockLogging,
System_Config_MaxRecords = 0,
Expand Down
110 changes: 1 addition & 109 deletions cpp/src/ValueIDIndexesDefines.h

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion cpp/src/command_classes/DoorLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ namespace OpenZWave
static char const* c_LockStateNames[] =
{ "Unsecure", "Unsecured with Timeout", "Inside Handle Unsecured", "Inside Handle Unsecured with Timeout", "Outside Handle Unsecured", "Outside Handle Unsecured with Timeout", "Secured", "Invalid" };

static char const* c_DoorConditionNames[] =
{ "Latched/Locked/Open", "Latched/Locked/Closed", "Latched/Unlocked/Open", "Latched/Unlocked/Closed", "Unlatched/Locked/Open", "Unlatched/Locked/Closed", "Unlatched/Unlocked/Open", "Unlatched/Unlocked/Closed"};

//-----------------------------------------------------------------------------
// <DoorLock::DoorLock>
// Constructor
Expand Down Expand Up @@ -194,6 +197,18 @@ namespace OpenZWave
value->OnValueRefreshed(lockState);
value->Release();
}

uint8 doorCondition = _data[3];
if (doorCondition < 8) { /* size of c_DoorConditionNames */
if (Internal::VC::ValueList* value = static_cast<Internal::VC::ValueList*>(GetValue(_instance, ValueID_Index_DoorLock::System_Config_DoorCondition)))
{
value->OnValueRefreshed(doorCondition);
value->Release();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few issues here:

  1. this ValueID is not created by the Class. You need to determine if the device in question supports this ValueID (probably based upon the CommandClass Version) and then create the ValueID, and subsequently, in this specific block, only do this update if the CommandClass Version is equal/above the minimum version and you should also check if index 3 is valid in the data recieved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking through the ZW docs and it appears DoorCondition is defined as far back as version 1 of the protocol and hasn't changed sense. I'm assuming this negates the need for any version checking? I added a simple validation of index 3.


Log::Write(LogLevel_Info, GetNodeId(), "Received DoorCondition report: DoorCondition is %s", c_DoorConditionNames[lockState]);

return true;
}
else if (DoorLockCmd_Configuration_Report == (DoorLockCmd) _data[0])
Expand Down Expand Up @@ -482,9 +497,21 @@ namespace OpenZWave
}
node->CreateValueList(ValueID::ValueGenre_System, GetCommandClassId(), _instance, ValueID_Index_DoorLock::System_Config_Mode, "Timeout Mode", "", false, false, 1, items, 0, 0);
}

/* Door Condition for Locks */
{
vector<Internal::VC::ValueList::Item> items;
Internal::VC::ValueList::Item item;
for (uint8 i = 0; i < 8; i++) {
item.m_label = c_DoorConditionNames[i];
item.m_value = i;
items.push_back(item);
}
node->CreateValueList(ValueID::ValueGenre_System, GetCommandClassId(), _instance, ValueID_Index_DoorLock::System_Config_DoorCondition, "Door Condition", "", false, false, 1, items, 0, 0);
}

node->CreateValueByte(ValueID::ValueGenre_System, GetCommandClassId(), _instance, ValueID_Index_DoorLock::System_Config_OutsideHandles, "Outside Handle Control", "", false, false, 0x0F, 0);
node->CreateValueByte(ValueID::ValueGenre_System, GetCommandClassId(), _instance, ValueID_Index_DoorLock::System_Config_InsideHandles, "Inside Handle Control", "", false, false, 0x0F, 0);

}
}
} // namespace CC
Expand Down