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,76 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ThermostatMode.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_MODE
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 _ThermostatMode_H
29
+ #define _ThermostatMode_H
30
+
31
+ #include <vector>
32
+ #include <string>
33
+ #include "CommandClass.h"
34
+ #include "ValueList.h"
35
+
36
+ namespace OpenZWave
37
+ {
38
+ class ValueList;
39
+
40
+ /** \brief Implements COMMAND_CLASS_THERMOSTAT_MODE (0x40), a Z-Wave device command class.
41
+ */
42
+ class ThermostatMode: public CommandClass
43
+ {
44
+ public:
45
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ThermostatMode( _homeId, _nodeId ); }
46
+ virtual ~ThermostatMode(){}
47
+
48
+ static uint8 const StaticGetCommandClassId(){ return 0x40; }
49
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_THERMOSTAT_MODE"; }
50
+
51
+ // From CommandClass
52
+ virtual void ReadXML( TiXmlElement const* _ccElement );
53
+ virtual void WriteXML( TiXmlElement* _ccElement );
54
+ virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
55
+ virtual bool RequestValue( uint32 const _requestFlags, uint8 const _getTypeEnum, uint8 const _dummy, Driver::MsgQueue const _queue );
56
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
57
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
58
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
59
+ virtual bool SetValue( Value const& _value );
60
+
61
+ protected:
62
+ virtual void CreateVars( uint8 const _instance );
63
+
64
+ private:
65
+ ThermostatMode( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){ SetStaticRequest( StaticRequest_Values ); }
66
+
67
+ vector<ValueList::Item> m_supportedModes;
68
+ };
69
+
70
+ } // namespace OpenZWave
71
+
72
+ #endif
73
+
74
+
75
+
76
+
@@ -0,0 +1,147 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ThermostatOperatingState.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_OPERATING_STATE
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 "ThermostatOperatingState.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Node.h"
33
+ #include "Driver.h"
34
+ #include "Log.h"
35
+
36
+ #include "ValueString.h"
37
+
38
+ using namespace OpenZWave;
39
+
40
+ enum ThermostatOperatingStateCmd
41
+ {
42
+ ThermostatOperatingStateCmd_Get = 0x02,
43
+ ThermostatOperatingStateCmd_Report = 0x03
44
+ };
45
+
46
+ static char const* c_stateName[] =
47
+ {
48
+ "Idle",
49
+ "Heating",
50
+ "Cooling",
51
+ "Fan Only",
52
+ "Pending Heat",
53
+ "Pending Cool",
54
+ "Vent / Economizer",
55
+ "State 07", // Undefined states. May be used in the future.
56
+ "State 08",
57
+ "State 09",
58
+ "State 10",
59
+ "State 11",
60
+ "State 12",
61
+ "State 13",
62
+ "State 14",
63
+ "State 15"
64
+ };
65
+
66
+ //-----------------------------------------------------------------------------
67
+ // <ThermostatOperatingState::RequestState>
68
+ // Get the static thermostat mode details from the device
69
+ //-----------------------------------------------------------------------------
70
+ bool ThermostatOperatingState::RequestState
71
+ (
72
+ uint32 const _requestFlags,
73
+ uint8 const _instance,
74
+ Driver::MsgQueue const _queue
75
+ )
76
+ {
77
+ if( _requestFlags & RequestFlag_Dynamic )
78
+ {
79
+ return RequestValue( _requestFlags, 0, _instance, _queue );
80
+ }
81
+ return false;
82
+ }
83
+
84
+ //-----------------------------------------------------------------------------
85
+ // <ThermostatOperatingState::RequestValue>
86
+ // Get a thermostat mode value from the device
87
+ //-----------------------------------------------------------------------------
88
+ bool ThermostatOperatingState::RequestValue
89
+ (
90
+ uint32 const _requestFlags,
91
+ uint8 const _dummy1, // = 0 (not used)
92
+ uint8 const _instance,
93
+ Driver::MsgQueue const _queue
94
+ )
95
+ {
96
+ Msg* msg = new Msg( "Request Current Thermostat Operating State", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
97
+ msg->SetInstance( this, _instance );
98
+ msg->Append( GetNodeId() );
99
+ msg->Append( 2 );
100
+ msg->Append( GetCommandClassId() );
101
+ msg->Append( ThermostatOperatingStateCmd_Get );
102
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
103
+ GetDriver()->SendMsg( msg, _queue );
104
+ return true;
105
+ }
106
+
107
+ //-----------------------------------------------------------------------------
108
+ // <ThermostatOperatingState::HandleMsg>
109
+ // Handle a message from the Z-Wave network
110
+ //-----------------------------------------------------------------------------
111
+ bool ThermostatOperatingState::HandleMsg
112
+ (
113
+ uint8 const* _data,
114
+ uint32 const _length,
115
+ uint32 const _instance // = 1
116
+ )
117
+ {
118
+ if( ThermostatOperatingStateCmd_Report == (ThermostatOperatingStateCmd)_data[0] )
119
+ {
120
+ // We have received the thermostat operating state from the Z-Wave device
121
+ if( ValueString* valueString = static_cast<ValueString*>( GetValue( _instance, 0 ) ) )
122
+ {
123
+ valueString->OnValueRefreshed( c_stateName[_data[1]&0x0f] );
124
+ valueString->Release();
125
+ Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat operating state: %s", valueString->GetValue().c_str() );
126
+ }
127
+ return true;
128
+ }
129
+
130
+ return false;
131
+ }
132
+
133
+ //-----------------------------------------------------------------------------
134
+ // <ThermostatOperatingState::CreateVars>
135
+ // Create the values managed by this command class
136
+ //-----------------------------------------------------------------------------
137
+ void ThermostatOperatingState::CreateVars
138
+ (
139
+ uint8 const _instance
140
+ )
141
+ {
142
+ if( Node* node = GetNodeUnsafe() )
143
+ {
144
+ node->CreateValueString( ValueID::ValueGenre_User, GetCommandClassId(), _instance, 0, "Operating State", "", true, false, c_stateName[0], 0 );
145
+ }
146
+ }
147
+
@@ -0,0 +1,71 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ThermostatOperatingState.h
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_OPERATING_STATE
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 _ThermostatOperatingState_H
29
+ #define _ThermostatOperatingState_H
30
+
31
+ #include <vector>
32
+ #include <string>
33
+ #include "CommandClass.h"
34
+ #include "ValueList.h"
35
+
36
+ namespace OpenZWave
37
+ {
38
+ class ValueString;
39
+
40
+ /** \brief Implements COMMAND_CLASS_THERMOSTAT_OPERATING_STATE (0x42), a Z-Wave device command class.
41
+ */
42
+ class ThermostatOperatingState: public CommandClass
43
+ {
44
+ public:
45
+ static CommandClass* Create( uint32 const _homeId, uint8 const _nodeId ){ return new ThermostatOperatingState( _homeId, _nodeId ); }
46
+ virtual ~ThermostatOperatingState(){}
47
+
48
+ static uint8 const StaticGetCommandClassId(){ return 0x42; }
49
+ static string const StaticGetCommandClassName(){ return "COMMAND_CLASS_THERMOSTAT_OPERATING_STATE"; }
50
+
51
+ // From CommandClass
52
+ virtual bool RequestState( uint32 const _requestFlags, uint8 const _instance, Driver::MsgQueue const _queue );
53
+ virtual bool RequestValue( uint32 const _requestFlags, uint8 const _index, uint8 const _instance, Driver::MsgQueue const _queue );
54
+ virtual uint8 const GetCommandClassId()const{ return StaticGetCommandClassId(); }
55
+ virtual string const GetCommandClassName()const{ return StaticGetCommandClassName(); }
56
+ virtual bool HandleMsg( uint8 const* _data, uint32 const _length, uint32 const _instance = 1 );
57
+
58
+ protected:
59
+ virtual void CreateVars( uint8 const _instance );
60
+
61
+ private:
62
+ ThermostatOperatingState( uint32 const _homeId, uint8 const _nodeId ): CommandClass( _homeId, _nodeId ){}
63
+ };
64
+
65
+ } // namespace OpenZWave
66
+
67
+ #endif
68
+
69
+
70
+
71
+
@@ -0,0 +1,317 @@
1
+ //-----------------------------------------------------------------------------
2
+ //
3
+ // ThermostatSetpoint.cpp
4
+ //
5
+ // Implementation of the Z-Wave COMMAND_CLASS_THERMOSTAT_SETPOINT
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 "ThermostatSetpoint.h"
30
+ #include "Defs.h"
31
+ #include "Msg.h"
32
+ #include "Node.h"
33
+ #include "Driver.h"
34
+ #include "Log.h"
35
+
36
+ #include "ValueDecimal.h"
37
+
38
+ using namespace OpenZWave;
39
+
40
+ enum ThermostatSetpointCmd
41
+ {
42
+ ThermostatSetpointCmd_Set = 0x01,
43
+ ThermostatSetpointCmd_Get = 0x02,
44
+ ThermostatSetpointCmd_Report = 0x03,
45
+ ThermostatSetpointCmd_SupportedGet = 0x04,
46
+ ThermostatSetpointCmd_SupportedReport = 0x05
47
+ };
48
+
49
+ enum
50
+ {
51
+ ThermostatSetpoint_Unused0 = 0,
52
+ ThermostatSetpoint_Heating1,
53
+ ThermostatSetpoint_Cooling1,
54
+ ThermostatSetpoint_Unused3,
55
+ ThermostatSetpoint_Unused4,
56
+ ThermostatSetpoint_Unused5,
57
+ ThermostatSetpoint_Unused6,
58
+ ThermostatSetpoint_Furnace,
59
+ ThermostatSetpoint_DryAir,
60
+ ThermostatSetpoint_MoistAir,
61
+ ThermostatSetpoint_AutoChangeover,
62
+ ThermostatSetpoint_HeatingEcon,
63
+ ThermostatSetpoint_CoolingEcon,
64
+ ThermostatSetpoint_AwayHeating,
65
+ ThermostatSetpoint_Count
66
+ };
67
+
68
+ static char const* c_setpointName[] =
69
+ {
70
+ "Unused 0",
71
+ "Heating 1",
72
+ "Cooling 1",
73
+ "Unused 3",
74
+ "Unused 4",
75
+ "Unused 5",
76
+ "Unused 6",
77
+ "Furnace",
78
+ "Dry Air",
79
+ "Moist Air",
80
+ "Auto Changeover",
81
+ "Heating Econ",
82
+ "Cooling Econ",
83
+ "Away Heating"
84
+ };
85
+
86
+ //-----------------------------------------------------------------------------
87
+ // <ThermostatSetpoint::ThermostatSetpoint>
88
+ // Constructor
89
+ //-----------------------------------------------------------------------------
90
+ ThermostatSetpoint::ThermostatSetpoint
91
+ (
92
+ uint32 const _homeId,
93
+ uint8 const _nodeId
94
+ ):
95
+ CommandClass( _homeId, _nodeId ), m_setPointBase( 1 )
96
+ {
97
+ SetStaticRequest( StaticRequest_Values );
98
+ }
99
+
100
+ //-----------------------------------------------------------------------------
101
+ // <ThermostatSetpoint::ReadXML>
102
+ // Read the saved change-counter value
103
+ //-----------------------------------------------------------------------------
104
+ void ThermostatSetpoint::ReadXML
105
+ (
106
+ TiXmlElement const* _ccElement
107
+ )
108
+ {
109
+ CommandClass::ReadXML( _ccElement );
110
+
111
+ int intVal;
112
+ if( TIXML_SUCCESS == _ccElement->QueryIntAttribute( "base", &intVal ) )
113
+ {
114
+ m_setPointBase = (uint8)intVal;
115
+ }
116
+ }
117
+
118
+ //-----------------------------------------------------------------------------
119
+ // <ThermostatSetpoint::WriteXML>
120
+ // Write the change-counter value
121
+ //-----------------------------------------------------------------------------
122
+ void ThermostatSetpoint::WriteXML
123
+ (
124
+ TiXmlElement* _ccElement
125
+ )
126
+ {
127
+ CommandClass::WriteXML( _ccElement );
128
+
129
+ char str[8];
130
+ snprintf( str, 8, "%d", m_setPointBase );
131
+ _ccElement->SetAttribute( "base", str );
132
+ }
133
+
134
+ //-----------------------------------------------------------------------------
135
+ // <ThermostatSetpoint::RequestState>
136
+ // Get the static thermostat setpoint details from the device
137
+ //-----------------------------------------------------------------------------
138
+ bool ThermostatSetpoint::RequestState
139
+ (
140
+ uint32 const _requestFlags,
141
+ uint8 const _instance,
142
+ Driver::MsgQueue const _queue
143
+ )
144
+ {
145
+ bool requests = false;
146
+ if( ( _requestFlags & RequestFlag_Static ) && HasStaticRequest( StaticRequest_Values ) )
147
+ {
148
+ requests |= RequestValue( _requestFlags, 0xff, _instance, _queue );
149
+ }
150
+
151
+ if( _requestFlags & RequestFlag_Session )
152
+ {
153
+ for( uint8 i=0; i<ThermostatSetpoint_Count; ++i )
154
+ {
155
+ requests |= RequestValue( _requestFlags, i, _instance, _queue );
156
+ }
157
+ }
158
+
159
+ return requests;
160
+ }
161
+
162
+ //-----------------------------------------------------------------------------
163
+ // <ThermostatSetpoint::RequestValue>
164
+ // Request current state from the device
165
+ //-----------------------------------------------------------------------------
166
+ bool ThermostatSetpoint::RequestValue
167
+ (
168
+ uint32 const _requestFlags,
169
+ uint8 const _setPointIndex,
170
+ uint8 const _instance,
171
+ Driver::MsgQueue const _queue
172
+ )
173
+ {
174
+ if( _setPointIndex == 0xff ) // check for supportedget
175
+ {
176
+ // Request the supported setpoints
177
+ Msg* msg = new Msg( "Request Supported Thermostat Setpoints", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
178
+ msg->SetInstance( this, _instance );
179
+ msg->Append( GetNodeId() );
180
+ msg->Append( 2 );
181
+ msg->Append( GetCommandClassId() );
182
+ msg->Append( ThermostatSetpointCmd_SupportedGet );
183
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
184
+ GetDriver()->SendMsg( msg, _queue );
185
+ return true;
186
+ }
187
+
188
+ Value* value = GetValue( 1, _setPointIndex );
189
+ if( value != NULL )
190
+ {
191
+ value->Release();
192
+ // Request the setpoint value
193
+ Msg* msg = new Msg( "Request Current Thermostat Setpoint", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
194
+ msg->SetInstance( this, _instance );
195
+ msg->Append( GetNodeId() );
196
+ msg->Append( 3 );
197
+ msg->Append( GetCommandClassId() );
198
+ msg->Append( ThermostatSetpointCmd_Get );
199
+ msg->Append( _setPointIndex );
200
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
201
+ GetDriver()->SendMsg( msg, _queue );
202
+ return true;
203
+ }
204
+ return false;
205
+ }
206
+
207
+ //-----------------------------------------------------------------------------
208
+ // <ThermostatSetpoint::HandleMsg>
209
+ // Handle a message from the Z-Wave network
210
+ //-----------------------------------------------------------------------------
211
+ bool ThermostatSetpoint::HandleMsg
212
+ (
213
+ uint8 const* _data,
214
+ uint32 const _length,
215
+ uint32 const _instance // = 1
216
+ )
217
+ {
218
+ if( ThermostatSetpointCmd_Report == (ThermostatSetpointCmd)_data[0] )
219
+ {
220
+ // We have received a thermostat setpoint value from the Z-Wave device
221
+ if( ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, _data[1] ) ) )
222
+ {
223
+ uint8 scale;
224
+ uint8 precision = 0;
225
+ string temperature = ExtractValue( &_data[2], &scale, &precision );
226
+
227
+ value->SetUnits( scale ? "F" : "C" );
228
+ value->OnValueRefreshed( temperature );
229
+ if( value->GetPrecision() != precision )
230
+ {
231
+ value->SetPrecision( precision );
232
+ }
233
+ value->Release();
234
+
235
+ Log::Write( LogLevel_Info, GetNodeId(), "Received thermostat setpoint report: Setpoint %s = %s%s", value->GetLabel().c_str(), value->GetValue().c_str(), value->GetUnits().c_str() );
236
+ }
237
+ return true;
238
+ }
239
+
240
+ if( ThermostatSetpointCmd_SupportedReport == (ThermostatSetpointCmd)_data[0] )
241
+ {
242
+ if( Node* node = GetNodeUnsafe() )
243
+ {
244
+ // We have received the supported thermostat setpoints from the Z-Wave device
245
+ Log::Write( LogLevel_Info, GetNodeId(), "Received supported thermostat setpoints" );
246
+
247
+ // Parse the data for the supported setpoints
248
+ for( uint32 i=1; i<_length-1; ++i )
249
+ {
250
+ for( int32 bit=0; bit<8; ++bit )
251
+ {
252
+ if( ( _data[i] & (1<<bit) ) != 0 )
253
+ {
254
+ // Add supported setpoint
255
+ int32 index = (int32)((i-1)<<3) + bit + m_setPointBase;
256
+ if( index < ThermostatSetpoint_Count )
257
+ {
258
+ node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, index, c_setpointName[index], "C", false, false, "0.0", 0 );
259
+ Log::Write( LogLevel_Info, GetNodeId(), " Added setpoint: %s", c_setpointName[index] );
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }
265
+
266
+ ClearStaticRequest( StaticRequest_Values );
267
+ return true;
268
+ }
269
+
270
+ return false;
271
+ }
272
+
273
+ //-----------------------------------------------------------------------------
274
+ // <ThermostatSetpoint::SetValue>
275
+ // Set a thermostat setpoint temperature
276
+ //-----------------------------------------------------------------------------
277
+ bool ThermostatSetpoint::SetValue
278
+ (
279
+ Value const& _value
280
+ )
281
+ {
282
+ if( ValueID::ValueType_Decimal == _value.GetID().GetType() )
283
+ {
284
+ ValueDecimal const* value = static_cast<ValueDecimal const*>(&_value);
285
+ uint8 scale = strcmp( "C", value->GetUnits().c_str() ) ? 1 : 0;
286
+
287
+ Msg* msg = new Msg( "Set Thermostat Setpoint", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true );
288
+ msg->SetInstance( this, _value.GetID().GetInstance() );
289
+ msg->Append( GetNodeId() );
290
+ msg->Append( 4 + GetAppendValueSize( value->GetValue() ) );
291
+ msg->Append( GetCommandClassId() );
292
+ msg->Append( ThermostatSetpointCmd_Set );
293
+ msg->Append( value->GetID().GetIndex() );
294
+ AppendValue( msg, value->GetValue(), scale );
295
+ msg->Append( TRANSMIT_OPTION_ACK | TRANSMIT_OPTION_AUTO_ROUTE );
296
+ GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
297
+ return true;
298
+ }
299
+
300
+ return false;
301
+ }
302
+
303
+ //-----------------------------------------------------------------------------
304
+ // <ThermostatSetpoint::CreateVars>
305
+ // Create the values managed by this command class
306
+ //-----------------------------------------------------------------------------
307
+ void ThermostatSetpoint::CreateVars
308
+ (
309
+ uint8 const _instance,
310
+ uint8 const _index
311
+ )
312
+ {
313
+ if( Node* node = GetNodeUnsafe() )
314
+ {
315
+ node->CreateValueDecimal( ValueID::ValueGenre_User, GetCommandClassId(), _instance, _index, "Setpoint", "C", false, false, "0.0", 0 );
316
+ }
317
+ }