ansible4ozw 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/lib/ansible.rb +12 -9
  2. data/lib/ansible/ansible_device.rb +1 -1
  3. data/lib/ansible/ansible_value.rb +1 -1
  4. data/lib/ansible/config.rb +8 -5
  5. data/lib/ansible/devices.rb +1 -0
  6. data/lib/ansible/knx.rb +0 -0
  7. data/lib/ansible/knx/dpt/tests/test_dpt10.rb~ +45 -0
  8. data/lib/ansible/knx/dpt/tests/test_dpt9.rb~ +55 -0
  9. data/lib/ansible/transceiver.rb +0 -3
  10. data/lib/ansible/version.rb +3 -0
  11. data/lib/ansible/zwave.rb +1 -0
  12. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_constants.rb +1 -2
  13. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_headers.rb +2 -6
  14. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_remote_manager.rb +0 -3
  15. data/lib/ansible/{openzwave → zwave/openzwave}/ozw_types.rb +0 -0
  16. data/lib/ansible/zwave/openzwave/src/Driver.h +695 -0
  17. data/lib/ansible/zwave/openzwave/src/Notification.h +165 -0
  18. data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.cpp +142 -0
  19. data/lib/ansible/zwave/openzwave/src/command_classes/Alarm.h +69 -0
  20. data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.cpp +93 -0
  21. data/lib/ansible/zwave/openzwave/src/command_classes/ApplicationStatus.h +57 -0
  22. data/lib/ansible/zwave/openzwave/src/command_classes/Association.cpp +385 -0
  23. data/lib/ansible/zwave/openzwave/src/command_classes/Association.h +73 -0
  24. data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.cpp +277 -0
  25. data/lib/ansible/zwave/openzwave/src/command_classes/AssociationCommandConfiguration.h +70 -0
  26. data/lib/ansible/zwave/openzwave/src/command_classes/Basic.cpp +212 -0
  27. data/lib/ansible/zwave/openzwave/src/command_classes/Basic.h +72 -0
  28. data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.cpp +118 -0
  29. data/lib/ansible/zwave/openzwave/src/command_classes/BasicWindowCovering.h +64 -0
  30. data/lib/ansible/zwave/openzwave/src/command_classes/Battery.cpp +141 -0
  31. data/lib/ansible/zwave/openzwave/src/command_classes/Battery.h +65 -0
  32. data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.cpp +415 -0
  33. data/lib/ansible/zwave/openzwave/src/command_classes/ClimateControlSchedule.h +71 -0
  34. data/lib/ansible/zwave/openzwave/src/command_classes/Clock.cpp +227 -0
  35. data/lib/ansible/zwave/openzwave/src/command_classes/Clock.h +67 -0
  36. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.cpp +546 -0
  37. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClass.h +145 -0
  38. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.cpp +291 -0
  39. data/lib/ansible/zwave/openzwave/src/command_classes/CommandClasses.h +79 -0
  40. data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.cpp +258 -0
  41. data/lib/ansible/zwave/openzwave/src/command_classes/Configuration.h +67 -0
  42. data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.cpp +142 -0
  43. data/lib/ansible/zwave/openzwave/src/command_classes/ControllerReplication.h +63 -0
  44. data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.cpp +163 -0
  45. data/lib/ansible/zwave/openzwave/src/command_classes/EnergyProduction.h +65 -0
  46. data/lib/ansible/zwave/openzwave/src/command_classes/Hail.cpp +68 -0
  47. data/lib/ansible/zwave/openzwave/src/command_classes/Hail.h +58 -0
  48. data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.cpp +159 -0
  49. data/lib/ansible/zwave/openzwave/src/command_classes/Indicator.h +66 -0
  50. data/lib/ansible/zwave/openzwave/src/command_classes/Language.cpp +159 -0
  51. data/lib/ansible/zwave/openzwave/src/command_classes/Language.h +65 -0
  52. data/lib/ansible/zwave/openzwave/src/command_classes/Lock.cpp +159 -0
  53. data/lib/ansible/zwave/openzwave/src/command_classes/Lock.h +66 -0
  54. data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.cpp +439 -0
  55. data/lib/ansible/zwave/openzwave/src/command_classes/ManufacturerSpecific.h +116 -0
  56. data/lib/ansible/zwave/openzwave/src/command_classes/Meter.cpp +541 -0
  57. data/lib/ansible/zwave/openzwave/src/command_classes/Meter.h +73 -0
  58. data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.cpp +137 -0
  59. data/lib/ansible/zwave/openzwave/src/command_classes/MeterPulse.h +65 -0
  60. data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.cpp +77 -0
  61. data/lib/ansible/zwave/openzwave/src/command_classes/MultiCmd.h +63 -0
  62. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.cpp +568 -0
  63. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstance.h +96 -0
  64. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.cpp +61 -0
  65. data/lib/ansible/zwave/openzwave/src/command_classes/MultiInstanceAssociation.h +59 -0
  66. data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.cpp +525 -0
  67. data/lib/ansible/zwave/openzwave/src/command_classes/NodeNaming.h +66 -0
  68. data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.cpp +157 -0
  69. data/lib/ansible/zwave/openzwave/src/command_classes/Powerlevel.h +82 -0
  70. data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.cpp +62 -0
  71. data/lib/ansible/zwave/openzwave/src/command_classes/Proprietary.h +58 -0
  72. data/lib/ansible/zwave/openzwave/src/command_classes/Protection.cpp +177 -0
  73. data/lib/ansible/zwave/openzwave/src/command_classes/Protection.h +73 -0
  74. data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.cpp +208 -0
  75. data/lib/ansible/zwave/openzwave/src/command_classes/SensorAlarm.h +77 -0
  76. data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.cpp +134 -0
  77. data/lib/ansible/zwave/openzwave/src/command_classes/SensorBinary.h +65 -0
  78. data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.cpp +237 -0
  79. data/lib/ansible/zwave/openzwave/src/command_classes/SensorMultilevel.h +71 -0
  80. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.cpp +219 -0
  81. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchAll.h +69 -0
  82. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.cpp +157 -0
  83. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchBinary.h +66 -0
  84. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.cpp +559 -0
  85. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchMultilevel.h +83 -0
  86. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.cpp +151 -0
  87. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleBinary.h +66 -0
  88. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.cpp +195 -0
  89. data/lib/ansible/zwave/openzwave/src/command_classes/SwitchToggleMultilevel.h +75 -0
  90. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.cpp +332 -0
  91. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanMode.h +77 -0
  92. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.cpp +149 -0
  93. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatFanState.h +71 -0
  94. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.cpp +373 -0
  95. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatMode.h +76 -0
  96. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.cpp +147 -0
  97. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatOperatingState.h +71 -0
  98. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.cpp +317 -0
  99. data/lib/ansible/zwave/openzwave/src/command_classes/ThermostatSetpoint.h +73 -0
  100. data/lib/ansible/zwave/openzwave/src/command_classes/Version.cpp +255 -0
  101. data/lib/ansible/zwave/openzwave/src/command_classes/Version.h +71 -0
  102. data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.cpp +391 -0
  103. data/lib/ansible/zwave/openzwave/src/command_classes/WakeUp.h +85 -0
  104. data/lib/ansible/zwave/openzwave/src/platform/Controller.cpp +68 -0
  105. data/lib/ansible/zwave/openzwave/src/platform/Controller.h +106 -0
  106. data/lib/ansible/zwave/openzwave/src/platform/Event.cpp +102 -0
  107. data/lib/ansible/zwave/openzwave/src/platform/Event.h +91 -0
  108. data/lib/ansible/zwave/openzwave/src/platform/HidController.cpp +539 -0
  109. data/lib/ansible/zwave/openzwave/src/platform/HidController.h +147 -0
  110. data/lib/ansible/zwave/openzwave/src/platform/Log.cpp +310 -0
  111. data/lib/ansible/zwave/openzwave/src/platform/Log.h +184 -0
  112. data/lib/ansible/zwave/openzwave/src/platform/Mutex.cpp +96 -0
  113. data/lib/ansible/zwave/openzwave/src/platform/Mutex.h +88 -0
  114. data/lib/ansible/zwave/openzwave/src/platform/Ref.h +91 -0
  115. data/lib/ansible/zwave/openzwave/src/platform/SerialController.cpp +180 -0
  116. data/lib/ansible/zwave/openzwave/src/platform/SerialController.h +138 -0
  117. data/lib/ansible/zwave/openzwave/src/platform/Stream.cpp +229 -0
  118. data/lib/ansible/zwave/openzwave/src/platform/Stream.h +135 -0
  119. data/lib/ansible/zwave/openzwave/src/platform/Thread.cpp +118 -0
  120. data/lib/ansible/zwave/openzwave/src/platform/Thread.h +101 -0
  121. data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.cpp +92 -0
  122. data/lib/ansible/zwave/openzwave/src/platform/TimeStamp.h +85 -0
  123. data/lib/ansible/zwave/openzwave/src/platform/Wait.cpp +176 -0
  124. data/lib/ansible/zwave/openzwave/src/platform/Wait.h +113 -0
  125. data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.cpp +262 -0
  126. data/lib/ansible/zwave/openzwave/src/platform/unix/EventImpl.h +62 -0
  127. data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.cpp +304 -0
  128. data/lib/ansible/zwave/openzwave/src/platform/unix/LogImpl.h +70 -0
  129. data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.cpp +136 -0
  130. data/lib/ansible/zwave/openzwave/src/platform/unix/MutexImpl.h +56 -0
  131. data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.cpp +368 -0
  132. data/lib/ansible/zwave/openzwave/src/platform/unix/SerialControllerImpl.h +74 -0
  133. data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.cpp +181 -0
  134. data/lib/ansible/zwave/openzwave/src/platform/unix/ThreadImpl.h +67 -0
  135. data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.cpp +121 -0
  136. data/lib/ansible/zwave/openzwave/src/platform/unix/TimeStampImpl.h +84 -0
  137. data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.cpp +160 -0
  138. data/lib/ansible/zwave/openzwave/src/platform/unix/WaitImpl.h +74 -0
  139. data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.cpp +102 -0
  140. data/lib/ansible/zwave/openzwave/src/platform/windows/EventImpl.h +60 -0
  141. data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.cpp +302 -0
  142. data/lib/ansible/zwave/openzwave/src/platform/windows/LogImpl.h +71 -0
  143. data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.cpp +114 -0
  144. data/lib/ansible/zwave/openzwave/src/platform/windows/MutexImpl.h +58 -0
  145. data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.cpp +410 -0
  146. data/lib/ansible/zwave/openzwave/src/platform/windows/SerialControllerImpl.h +66 -0
  147. data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.cpp +158 -0
  148. data/lib/ansible/zwave/openzwave/src/platform/windows/ThreadImpl.h +71 -0
  149. data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.cpp +95 -0
  150. data/lib/ansible/zwave/openzwave/src/platform/windows/TimeStampImpl.h +83 -0
  151. data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.cpp +134 -0
  152. data/lib/ansible/zwave/openzwave/src/platform/windows/WaitImpl.h +73 -0
  153. data/lib/ansible/zwave/openzwave/src/value_classes/ValueID.h +283 -0
  154. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_bool.rb +0 -0
  155. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_button.rb +0 -0
  156. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_byte.rb +0 -0
  157. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_decimal.rb +0 -0
  158. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_int.rb +0 -0
  159. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_list.rb +0 -0
  160. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_short.rb +0 -0
  161. data/lib/ansible/zwave/{types → openzwave/types}/valuetype_string.rb +0 -0
  162. data/lib/ansible/zwave/zwave_transceiver.rb +2 -8
  163. data/lib/ansible/zwave/zwave_value.rb +6 -10
  164. metadata +159 -17
  165. data/lib/ansible/zwave/zwave_node.rb +0 -5
@@ -0,0 +1,415 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ClimateControlSchedule.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE
6
+ //
7
+ // Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
8
+ //
9
+ // SOFTWARE NOTICE AND LICENSE
10
+ //
11
+ // This file is part of OpenZWave.
12
+ //
13
+ // OpenZWave is free software: you can redistribute it and/or modify
14
+ // it under the terms of the GNU Lesser General Public License as published
15
+ // by the Free Software Foundation, either version 3 of the License,
16
+ // or (at your option) any later version.
17
+ //
18
+ // OpenZWave is distributed in the hope that it will be useful,
19
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ // GNU Lesser General Public License for more details.
22
+ //
23
+ // You should have received a copy of the GNU Lesser General Public License
24
+ // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25
+ //
26
+ //-----------------------------------------------------------------------------
27
+
28
+ #include "CommandClasses.h"
29
+ #include "ClimateControlSchedule.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Driver.h"
33
+ #include "Node.h"
34
+ #include "Log.h"
35
+ #include "ValueByte.h"
36
+ #include "ValueList.h"
37
+ #include "ValueSchedule.h"
38
+
39
+ using namespace OpenZWave;
40
+
41
+ enum ClimateControlScheduleCmd
42
+ {
43
+ ClimateControlScheduleCmd_Set = 0x01,
44
+ ClimateControlScheduleCmd_Get,
45
+ ClimateControlScheduleCmd_Report,
46
+ ClimateControlScheduleCmd_ChangedGet,
47
+ ClimateControlScheduleCmd_ChangedReport,
48
+ ClimateControlScheduleCmd_OverrideSet,
49
+ ClimateControlScheduleCmd_OverrideGet,
50
+ ClimateControlScheduleCmd_OverrideReport
51
+ };
52
+
53
+ enum
54
+ {
55
+ ClimateControlScheduleIndex_OverrideState = 8,
56
+ ClimateControlScheduleIndex_OverrideSetback = 9
57
+ };
58
+
59
+ static char const* c_dayNames[] =
60
+ {
61
+ "Invalid",
62
+ "Monday",
63
+ "Tuesday",
64
+ "Wednesday",
65
+ "Thursday",
66
+ "Friday",
67
+ "Saturday",
68
+ "Sunday"
69
+ };
70
+
71
+ static char const* c_overrideStateNames[] =
72
+ {
73
+ "None",
74
+ "Temporary",
75
+ "Permanent",
76
+ "Invalid"
77
+ };
78
+
79
+
80
+ //-----------------------------------------------------------------------------
81
+ // <ClimateControlSchedule::ReadXML>
82
+ // Read the saved change-counter value
83
+ //-----------------------------------------------------------------------------
84
+ void ClimateControlSchedule::ReadXML
85
+ (
86
+ TiXmlElement const* _ccElement
87
+ )
88
+ {
89
+ CommandClass::ReadXML( _ccElement );
90
+
91
+ int intVal;
92
+ if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "change_counter", &intVal ) )
93
+ {
94
+ m_changeCounter = (uint8)intVal;
95
+ }
96
+ }
97
+
98
+ //-----------------------------------------------------------------------------
99
+ // <ClimateControlSchedule::WriteXML>
100
+ // Write the change-counter value
101
+ //-----------------------------------------------------------------------------
102
+ void ClimateControlSchedule::WriteXML
103
+ (
104
+ TiXmlElement* _ccElement
105
+ )
106
+ {
107
+ CommandClass::WriteXML( _ccElement );
108
+
109
+ char str[8];
110
+ snprintf( str, 8, "%d", m_changeCounter );
111
+ _ccElement->SetAttribute( "change_counter", str );
112
+ }
113
+
114
+ //-----------------------------------------------------------------------------
115
+ // <ClimateControlSchedule::RequestState>
116
+ // Request current state from the device
117
+ //-----------------------------------------------------------------------------
118
+ bool ClimateControlSchedule::RequestState
119
+ (
120
+ uint32 const _requestFlags,
121
+ uint8 const _instance,
122
+ Driver::MsgQueue const _queue
123
+ )
124
+ {
125
+ if( _requestFlags & RequestFlag_Session )
126
+ {
127
+ // See if the schedule has changed since last time
128
+ return RequestValue( _requestFlags, 0, _instance, _queue );
129
+ }
130
+
131
+ return false;
132
+ }
133
+
134
+ //-----------------------------------------------------------------------------
135
+ // <ClimateControlSchedule::RequestValue>
136
+ // Request current value from the device
137
+ //-----------------------------------------------------------------------------
138
+ bool ClimateControlSchedule::RequestValue
139
+ (
140
+ uint32 const _requestFlags,
141
+ uint8 const _dummy1, // = 0 (not used)
142
+ uint8 const _instance,
143
+ Driver::MsgQueue const _queue
144
+ )
145
+ {
146
+ // See if the schedule has changed since last time
147
+ Msg* msg = new Msg( "ClimateControlScheduleCmd_ChangedGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
148
+ msg->SetInstance( this, _instance );
149
+ msg->Append( GetNodeId() );
150
+ msg->Append( 2 );
151
+ msg->Append( GetCommandClassId() );
152
+ msg->Append( ClimateControlScheduleCmd_ChangedGet );
153
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
154
+ GetDriver()->SendMsg( msg, _queue );
155
+ return true;
156
+ }
157
+
158
+ //-----------------------------------------------------------------------------
159
+ // <ClimateControlSchedule::HandleMsg>
160
+ // Handle a message from the Z-Wave network
161
+ //-----------------------------------------------------------------------------
162
+ bool ClimateControlSchedule::HandleMsg
163
+ (
164
+ uint8 const* _data,
165
+ uint32 const _length,
166
+ uint32 const _instance // = 1
167
+ )
168
+ {
169
+ if( ClimateControlScheduleCmd_Report == (ClimateControlScheduleCmd)_data[0] )
170
+ {
171
+ uint8 day = _data[1] & 0x07;
172
+
173
+ Log::Write( LogLevel_Info, GetNodeId(), "Received climate control schedule report for %s", c_dayNames[day] );
174
+
175
+ if( ValueSchedule* value = static_cast<ValueSchedule*>( GetValue( _instance, day ) ) )
176
+ {
177
+ // Remove any existing data
178
+ value->ClearSwitchPoints();
179
+
180
+ // Parse the switch point data
181
+ for( uint8 i=2; i<29; i+=3 )
182
+ {
183
+ uint8 setback = _data[i+2];
184
+ if( setback == 0x7f )
185
+ {
186
+ // Switch point is unused, so we stop parsing here
187
+ break;
188
+ }
189
+
190
+ uint8 hours = _data[i] & 0x1f;
191
+ uint8 minutes = _data[i+1] & 0x3f;
192
+
193
+ if( setback == 0x79 )
194
+ {
195
+ Log::Write( LogLevel_Info, GetNodeId(), " Switch point at %02d:%02d, Frost Protection Mode", hours, minutes, c_dayNames[day] );
196
+ }
197
+ else if( setback == 0x7a )
198
+ {
199
+ Log::Write( LogLevel_Info, GetNodeId(), " Switch point at %02d:%02d, Energy Saving Mode", hours, minutes, c_dayNames[day] );
200
+ }
201
+ else
202
+ {
203
+ Log::Write( LogLevel_Info, GetNodeId(), " Switch point at %02d:%02d, Setback %+.1fC", hours, minutes, ((float)setback)*0.1f );
204
+ }
205
+
206
+ value->SetSwitchPoint( hours, minutes, setback );
207
+ }
208
+
209
+ if( !value->GetNumSwitchPoints() )
210
+ {
211
+ Log::Write( LogLevel_Info, GetNodeId(), " No Switch points have been set" );
212
+ }
213
+
214
+ // Notify the user
215
+ value->OnValueRefreshed();
216
+ value->Release();
217
+ }
218
+
219
+ return true;
220
+ }
221
+
222
+ if( ClimateControlScheduleCmd_ChangedReport == (ClimateControlScheduleCmd)_data[0] )
223
+ {
224
+ Log::Write( LogLevel_Info, GetNodeId(), "Received climate control schedule changed report:" );
225
+
226
+ if( _data[1] )
227
+ {
228
+ if( _data[1] != m_changeCounter )
229
+ {
230
+ m_changeCounter = _data[1];
231
+
232
+ // The schedule has changed and is not in override mode, so request reports for each day
233
+ for( int i=1; i<=7; ++i )
234
+ {
235
+ char str[64];
236
+ snprintf( str, 64, "Get climate control schedule for %s", c_dayNames[i] );
237
+
238
+ Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
239
+ msg->Append( GetNodeId() );
240
+ msg->Append( 3 );
241
+ msg->Append( GetCommandClassId() );
242
+ msg->Append( ClimateControlScheduleCmd_Get );
243
+ msg->Append( i );
244
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
245
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
246
+ }
247
+ }
248
+ }
249
+ else
250
+ {
251
+ // Device is in override mode, so we request details of that instead
252
+ Msg* msg = new Msg( "Get climate control schedule override state", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
253
+ msg->Append( GetNodeId() );
254
+ msg->Append( 2 );
255
+ msg->Append( GetCommandClassId() );
256
+ msg->Append( ClimateControlScheduleCmd_OverrideGet );
257
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
258
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
259
+ }
260
+ return true;
261
+ }
262
+
263
+ if( ClimateControlScheduleCmd_OverrideReport == (ClimateControlScheduleCmd)_data[0] )
264
+ {
265
+ uint8 overrideState = _data[1] & 0x03;
266
+
267
+ Log::Write( LogLevel_Info, GetNodeId(), "Received climate control schedule override report:" );
268
+ Log::Write( LogLevel_Info, GetNodeId(), " Override State: %s:", c_overrideStateNames[overrideState] );
269
+
270
+ if( ValueList* valueList = static_cast<ValueList*>( GetValue( _instance, ClimateControlScheduleIndex_OverrideState ) ) )
271
+ {
272
+ valueList->OnValueRefreshed( (int)overrideState );
273
+ valueList->Release();
274
+ }
275
+
276
+ uint8 setback = _data[2];
277
+ if( overrideState )
278
+ {
279
+ if( setback == 0x79 )
280
+ {
281
+ Log::Write( LogLevel_Info, GetNodeId(), " Override Setback: Frost Protection Mode" );
282
+ }
283
+ else if( setback == 0x7a )
284
+ {
285
+ Log::Write( LogLevel_Info, GetNodeId(), " Override Setback: Energy Saving Mode" );
286
+ }
287
+ else
288
+ {
289
+ Log::Write( LogLevel_Info, GetNodeId(), " Override Setback: %+.1fC", ((float)setback)*0.1f );
290
+ }
291
+ }
292
+
293
+ if( ValueByte* valueByte = static_cast<ValueByte*>( GetValue( _instance, ClimateControlScheduleIndex_OverrideSetback ) ) )
294
+ {
295
+ valueByte->OnValueRefreshed( setback );
296
+ valueByte->Release();
297
+ }
298
+
299
+ return true;
300
+ }
301
+
302
+ return false;
303
+ }
304
+
305
+ //-----------------------------------------------------------------------------
306
+ // <ClimateControlSchedule::SetValue>
307
+ // Set a value in the device
308
+ //-----------------------------------------------------------------------------
309
+ bool ClimateControlSchedule::SetValue
310
+ (
311
+ Value const& _value
312
+ )
313
+ {
314
+ // bool res = false;
315
+ uint8 instance = _value.GetID().GetInstance();
316
+ uint8 idx = _value.GetID().GetIndex();
317
+
318
+ if( idx < 8 )
319
+ {
320
+ // Set a schedule
321
+ ValueSchedule const* value = static_cast<ValueSchedule const*>(&_value);
322
+
323
+ char str[64];
324
+ snprintf( str, 64, "Set the climate control schedule for %s on node %d", c_dayNames[idx], GetNodeId() );
325
+
326
+ Msg* msg = new Msg( str, GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
327
+ msg->SetInstance( this, instance );
328
+ msg->Append( GetNodeId() );
329
+ msg->Append( 30 );
330
+ msg->Append( GetCommandClassId() );
331
+ msg->Append( ClimateControlScheduleCmd_Set );
332
+ msg->Append( idx ); // Day of week
333
+
334
+ for( uint8 i=0; i<9; ++i )
335
+ {
336
+ uint8 hours;
337
+ uint8 minutes;
338
+ int8 setback;
339
+ if( value->GetSwitchPoint( i, &hours, &minutes, &setback ) )
340
+ {
341
+ msg->Append( hours );
342
+ msg->Append( minutes );
343
+ msg->Append( setback );
344
+ }
345
+ else
346
+ {
347
+ // Unused switch point
348
+ msg->Append( 0 );
349
+ msg->Append( 0 );
350
+ msg->Append( 0x7f );
351
+ }
352
+ }
353
+
354
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
355
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
356
+ }
357
+ else
358
+ {
359
+ // Set an override
360
+ ValueList* state = static_cast<ValueList*>( GetValue( instance, ClimateControlScheduleIndex_OverrideState ) );
361
+ ValueByte* setback = static_cast<ValueByte*>( GetValue( instance, ClimateControlScheduleIndex_OverrideSetback ) );
362
+
363
+ if( state && setback )
364
+ {
365
+ ValueList::Item const& item = state->GetItem();
366
+
367
+ Msg* msg = new Msg( "Set climate control schedule override state", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
368
+ msg->SetInstance( this, instance );
369
+ msg->Append( GetNodeId() );
370
+ msg->Append( 4 );
371
+ msg->Append( GetCommandClassId() );
372
+ msg->Append( ClimateControlScheduleCmd_OverrideSet );
373
+ msg->Append( (uint8)item.m_value );
374
+ msg->Append( setback->GetValue() );
375
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
376
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
377
+ }
378
+ }
379
+
380
+ return true;
381
+ }
382
+
383
+ //-----------------------------------------------------------------------------
384
+ // <ClimateControlSchedule::CreateVars>
385
+ // Create the values managed by this command class
386
+ //-----------------------------------------------------------------------------
387
+ void ClimateControlSchedule::CreateVars
388
+ (
389
+ uint8 const _instance
390
+ )
391
+ {
392
+ if( Node* node = GetNodeUnsafe() )
393
+ {
394
+ // Add a ValueSchedule for each day of the week.
395
+ for( uint8 i=0; i<7; ++i )
396
+ {
397
+ node->CreateValueSchedule( ValueID::ValueGenre_User, GetCommandClassId(), _instance, i+1, c_dayNames[i+1], "", false, false, 0 );
398
+ }
399
+
400
+ // Add values for the override state and setback
401
+ vector<ValueList::Item> items;
402
+
403
+ ValueList::Item item;
404
+ for( uint8 i=0; i<3; ++i )
405
+ {
406
+ item.m_label = c_overrideStateNames[i];
407
+ item.m_value = i;
408
+ items.push_back( item );
409
+ }
410
+
411
+ node->CreateValueList( ValueID::ValueGenre_User, GetCommandClassId(), _instance, ClimateControlScheduleIndex_OverrideState, "Override State", "", false, false, 1, items, 0, 0 );
412
+ node->CreateValueByte( ValueID::ValueGenre_User, GetCommandClassId(), _instance, ClimateControlScheduleIndex_OverrideSetback, "Override Setback", "", false, false, 0, 0 );
413
+ }
414
+ }
415
+
@@ -0,0 +1,71 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ClimateControlSchedule.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE
6
+ //
7
+ // Copyright (c) 2010 Mal Lansell <openzwave@lansell.org>
8
+ //
9
+ // SOFTWARE NOTICE AND LICENSE
10
+ //
11
+ // This file is part of OpenZWave.
12
+ //
13
+ // OpenZWave is free software: you can redistribute it and/or modify
14
+ // it under the terms of the GNU Lesser General Public License as published
15
+ // by the Free Software Foundation, either version 3 of the License,
16
+ // or (at your option) any later version.
17
+ //
18
+ // OpenZWave is distributed in the hope that it will be useful,
19
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ // GNU Lesser General Public License for more details.
22
+ //
23
+ // You should have received a copy of the GNU Lesser General Public License
24
+ // along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25
+ //
26
+ //-----------------------------------------------------------------------------
27
+
28
+ #ifndef _ClimateControlSchedule_H
29
+ #define _ClimateControlSchedule_H
30
+
31
+ #include "CommandClass.h"
32
+
33
+ namespace OpenZWave
34
+ {
35
+ class ValueSchedule;
36
+ class ValueList;
37
+ class ValueByte;
38
+
39
+ /** \brief Implements COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE (0x46), a Z-Wave device command class.
40
+ */
41
+ class ClimateControlSchedule: public CommandClass
42
+ {
43
+ public:
44
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ClimateControlSchedule( _homeId, _nodeId ); }
45
+ virtual ~ClimateControlSchedule(){}
46
+
47
+ static uint8 const StaticGetCommandClassId(){ return 0x46; }
48
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_CLIMATE_CONTROL_SCHEDULE"; }
49
+
50
+ // From CommandClass
51
+ virtual void ReadXML( TiXmlElement const* _ccElement );
52
+ virtual void WriteXML( TiXmlElement* _ccElement );
53
+ virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
54
+ virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
55
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
56
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
57
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
58
+ virtual bool SetValue( Value const& _value );
59
+
60
+ protected:
61
+ virtual void CreateVars( uint8 const _instance );
62
+
63
+ private:
64
+ ClimateControlSchedule( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ), m_changeCounter( 0 ){}
65
+ uint8 m_changeCounter;
66
+ };
67
+
68
+ } // namespace OpenZWave
69
+
70
+ #endif
71
+