]> git.pld-linux.org Git - packages/domoticz.git/blob - domoticz-openzwave-Dev.patch
- correct install
[packages/domoticz.git] / domoticz-openzwave-Dev.patch
1 diff --git a/hardware/OpenZWave.cpp b/hardware/OpenZWave.cpp
2 index 1f5c341c..51b2865b 100644
3 --- a/hardware/OpenZWave.cpp
4 +++ b/hardware/OpenZWave.cpp
5 @@ -1641,19 +1641,83 @@ void COpenZWave::AddValue(const OpenZWave::ValueID &vID, const NodeInfo *pNodeIn
6                 if (newInstance != 0)
7                 {
8                         _device.instanceID = newInstance;
9 -                       if (m_pManager->GetValueAsByte(vID, &byteValue) == true)
10 +            //Door lock device
11 +                       if (
12 +                               (vLabel == "Access Control") ||
13 +                               (vLabel == "UserCode")
14 +                               )
15                         {
16 -                               _device.devType = ZDTYPE_SWITCH_NORMAL;
17 -                               if (byteValue == 0)
18 -                                       _device.intvalue = 0;
19 -                               else
20 -                                       _device.intvalue = 255;
21 -                               InsertDevice(_device);
22 +                               if( ValueID::ValueType_List == vID.GetType() )
23 +                               {
24 +                                       try
25 +                                       {
26 +                                               std::string vListStr;
27 +                                               if (m_pManager->GetValueListSelection(vID, &vListStr))
28 +                                               {
29 +                                                       _device.devType = ZDTYPE_SWITCH_NORMAL;
30 +                                                       _device.Alarm_Type = 6;
31 +                                                       _device.intvalue = 0;
32 +                                                       if (vListStr == "Access Control - RF Lock")
33 +                                                               _device.intvalue = 24;
34 +                                                       else if (vListStr == "Access Control - RF Unlock")
35 +                                                               _device.intvalue = 25;
36 +                                                       else if (vListStr == "Access Control - Manual Lock")
37 +                                                               _device.intvalue = 21;
38 +                                                       else if (vListStr == "Access Control - Manual Unlock")
39 +                                                               _device.intvalue = 22;
40 +                                                       else if (vListStr == "Access Control - KeyPad Lock")
41 +                                                               _device.intvalue = 18;
42 +                                                       else if (vListStr == "Access Control - KeyPad Unlock")
43 +                                                               _device.intvalue = 19;
44 +                                                       else if (vListStr == "Not Active")
45 +                                                               _device.intvalue = 1;
46 +                                                       else
47 +                                                               _log.Log(LOG_STATUS, "OpenZWave: Value_Added: Unhandled List Selection: %s", vListStr.c_str());
48 +                                                       InsertDevice(_device);
49 +                                               }
50 +                                       }
51 +                                       catch (...)
52 +                                       {
53 +                                               _log.Log(LOG_STATUS, "OpenZWave: Value_Added: GetValueListSelection Exception");
54 +                                       }
55 +                               }
56 +                               else {
57 +                                       _log.Log(LOG_STATUS, "OpenZWave: Value_Added: Unhandled Value for Label: %s", vLabel.c_str());
58 +                               }
59 +                       }
60 +                       else if( ValueID::ValueType_Byte == vID.GetType() )
61 +                       {
62 +                               if (m_pManager->GetValueAsByte(vID, &byteValue) == true)
63 +                               {
64 +                                       _device.devType = ZDTYPE_SWITCH_NORMAL;
65 +                                       if (byteValue == 0)
66 +                                               _device.intvalue = 0;
67 +                                       else
68 +                                               _device.intvalue = 255;
69 +                                       InsertDevice(_device);
70 +                               }
71                         }
72 +            else
73 +            {
74 +                _log.Log(LOG_STATUS, "OpenZWave: Value_Added: Unhandled Value: X, Type: %i", vID.GetType());
75 +            }
76                 }
77                 else
78                 {
79 -                       if (vLabel != "SourceNodeId")
80 +                       if (vLabel == "UserCode") {
81 +                               if ((vType == OpenZWave::ValueID::ValueType_Raw) || (vType == OpenZWave::ValueID::ValueType_String))
82 +                               {
83 +                                       std::string strValue;
84 +                                       if (m_pManager->GetValueAsString(vID, &strValue) == true)
85 +                                               _log.Log(LOG_STATUS, "OpenZWave: Value_Added: UserCode: %s", strValue.c_str());
86 +                               }
87 +                               else
88 +                               {
89 +                                       if (m_pManager->GetValueAsByte(vID, &byteValue) == true)
90 +                                               _log.Log(LOG_STATUS, "OpenZWave: Value_Added: UserCode: %i", byteValue);
91 +                               }
92 +                       }
93 +                       else if (vLabel != "SourceNodeId")
94                         {
95                                 _log.Log(LOG_STATUS, "OpenZWave: Value_Added: Unhandled Label: %s, Unit: %s", vLabel.c_str(), vUnits.c_str());
96                         }
97 @@ -2395,7 +2459,7 @@ void COpenZWave::UpdateValue(const OpenZWave::ValueID &vID)
98         unsigned char byteValue = 0;
99         int32 intValue = 0;
100         std::string strValue = "";
101 -       int32 lValue = 0;
102 +       std::string lValue = "";
103  
104         if (vType == OpenZWave::ValueID::ValueType_Decimal)
105         {
106 @@ -2833,16 +2897,40 @@ void COpenZWave::UpdateValue(const OpenZWave::ValueID &vID)
107                                 }
108                                 else if (vLabel == "Access Control")
109                                 {
110 +                                       if (!lValue.empty()) {
111 +                                               if (lValue == "Access Control - RF Lock")
112 +                                                       byteValue = 24;
113 +                                               else if (lValue == "Access Control - RF Unlock")
114 +                                                       byteValue = 25;
115 +                                               else if (lValue == "Access Control - Manual Lock")
116 +                                                       byteValue = 21;
117 +                                               else if (lValue == "Access Control - Manual Unlock")
118 +                                                       byteValue = 22;
119 +                                               else if (lValue == "Access Control - KeyPad Lock")
120 +                                                       byteValue = 18;
121 +                                               else if (lValue == "Access Control - KeyPad Unlock")
122 +                                                       byteValue = 19;
123 +                                               else if (lValue == "Not Active")
124 +                                                       byteValue = 0;
125 +                                               else
126 +                                                       byteValue = 0;
127 +                                       }
128 +
129                                         switch (byteValue) {
130                                         case 0x00:      // Previous Events cleared
131                                         case 0x06:      //Keypad unlock/Arm Home
132 +                                       case 0x12:      // KeyPad lock
133 +                                       case 0x15:      // Manual Lock
134                                         case 0x17:      // Door closed
135 +                                       case 0x18:      // RF operated lock
136                                         case 0xfe:      // Unkown event; returned when retrieving the current state.
137                                                 intValue = 0;
138                                                 break;
139  
140                                         case 0x05:      //Keypad Lock/Arm Away
141 +                                       case 0x13:      // KeyPad unlock
142                                         case 0x16:      // Door open
143 +                                       case 0x19:      // RF operated unlock
144                                         default:        // all others, interpret as alarm
145                                                 intValue = 255;
146                                                 break;
This page took 0.074731 seconds and 3 git commands to generate.