From f12d40d8d2d8ee6fa63c960123a7e228d98a061b Mon Sep 17 00:00:00 2001 From: Nico0084 Date: Mon, 11 Apr 2016 22:15:07 +0200 Subject: [PATCH 1/2] Value read from xml device config recreate value type with deleteting default value type if different. AlarmClass Handling List type from xml. --- cpp/src/Node.cpp | 13 ++++++++++--- cpp/src/command_classes/Alarm.cpp | 24 +++++++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/cpp/src/Node.cpp b/cpp/src/Node.cpp index 926933d6..475b0e12 100644 --- a/cpp/src/Node.cpp +++ b/cpp/src/Node.cpp @@ -2495,7 +2495,6 @@ bool Node::CreateValueFromXML if( value ) { value->ReadXML( m_homeId, m_nodeId, _commandClassId, _valueElement ); - ValueStore* store = GetValueStore(); if( store->AddValue( value ) ) { @@ -2545,8 +2544,16 @@ void Node::ReadValueFromXML { if( Value* value = store->GetValue( id.GetValueStoreKey() ) ) { - value->ReadXML( m_homeId, m_nodeId, _commandClassId, _valueElement ); - value->Release(); + // Check if values type are the same + ValueID::ValueType v_type = value->GetID().GetType(); + if ( v_type == type ) { + value->ReadXML( m_homeId, m_nodeId, _commandClassId, _valueElement ); + value->Release(); + } else { + Log::Write( LogLevel_Info, m_nodeId, "xml value type (%s) is different to stored value type (%s). Value is recreate with xml params.", value->GetTypeNameFromEnum(type), value->GetTypeNameFromEnum(v_type) ); + store->RemoveValue( value->GetID().GetValueStoreKey() ); + CreateValueFromXML( _commandClassId, _valueElement ); + } } else { diff --git a/cpp/src/command_classes/Alarm.cpp b/cpp/src/command_classes/Alarm.cpp index 3dad19c0..c2934eb9 100644 --- a/cpp/src/command_classes/Alarm.cpp +++ b/cpp/src/command_classes/Alarm.cpp @@ -229,12 +229,30 @@ bool Alarm::HandleMsg value->OnValueRefreshed( _data[1] ); value->Release(); } - if( (value = static_cast( GetValue( _instance, AlarmIndex_Level ) )) ) + // For device on version 1 the level could have different value. This level value correspond to a list of alarm type. + if ( Value* value = GetValue( _instance, AlarmIndex_Level ) ) { - value->OnValueRefreshed( _data[2] ); + switch ( value->GetID().GetType() ) + { + case ValueID::ValueType_Byte: + { + ValueByte* valueByte = static_cast( value ); + valueByte->OnValueRefreshed( _data[2] ); + break; + } + case ValueID::ValueType_List: + { + ValueList* valueList = static_cast( value ); + valueList->OnValueRefreshed( _data[2] ); + break; + } + default: + { + Log::Write( LogLevel_Info, GetNodeId(), "Invalid type (%d) for Alarm Level %d", value->GetID().GetType(), _data[2] ); + } + } value->Release(); } - // With Version=2, the data has more detailed information about the alarm if(( GetVersion() > 1 ) && ( _length >= 7 )) { From c72890a12410dd5560e1bd327c2bdcfa9d52b654 Mon Sep 17 00:00:00 2001 From: Nico0084 Date: Mon, 11 Apr 2016 22:37:48 +0200 Subject: [PATCH 2/2] Modify CommandClass Alarm everspringct HSM02 to value type list --- config/everspringct/hsm02.xml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/config/everspringct/hsm02.xml b/config/everspringct/hsm02.xml index 4bdd887f..8017d5dc 100644 --- a/config/everspringct/hsm02.xml +++ b/config/everspringct/hsm02.xml @@ -32,27 +32,25 @@ - - - - - Once the power has been applied, Alarm Report Command will be sent to - Nodes in Grouping 1 to confirm the power applied status for HSM02. - + + Grouping 1, afterward, LED will light up for 1 sec to remind user when HSM02 is triggered due to open or close incidents. - + - When HSM02 automatically wakes up, it will check the battery usage. When + No alarm : There is no alarm to report. + Power applied : Once the power has been applied, Alarm Report Command will be sent to + Nodes in Grouping 1 to confirm the power applied status for HSM02. + Tamper event : Grouping 1, afterward, LED will light up for 1 sec to remind user when HSM02 is + triggered due to open or close incidents. + Low battery : When HSM02 automatically wakes up, it will check the battery usage. When low battery is detected, Alarm Report Command will be sent to Nodes in Grouping 1, afterward, LED will light up for 1 sec to remind user when HSM02 is triggered due to open or close incidents. - - - - Grouping 1, afterward, LED will light up for 1 sec to remind user when HSM02 is - triggered due to open or close incidents. - + + + +