----------------------------------------------------------------------------- Handle a message from the Z-Wave network -----------------------------------------------------------------------------
| 192 | // Handle a message from the Z-Wave network |
| 193 | //----------------------------------------------------------------------------- |
| 194 | bool ThermostatSetpoint::HandleMsg |
| 195 | ( |
| 196 | uint8 const* _data, |
| 197 | uint32 const _length, |
| 198 | uint32 const _instance // = 1 |
| 199 | ) |
| 200 | { |
| 201 | if( ThermostatSetpointCmd_Report == (ThermostatSetpointCmd)_data[0] ) |
| 202 | { |
| 203 | // We have received a thermostat setpoint value from the Z-Wave device |
| 204 | if( ValueDecimal* value = static_cast<ValueDecimal*>( GetValue( _instance, _data[1] ) ) ) |
| 205 | { |
| 206 | uint8 scale; |
| 207 | uint8 precision = 0; |
| 208 | string temperature = ExtractValue( &_data[2], &scale, &precision ); |
| 209 | |
| 210 | value->SetUnits( scale ? "F" : "C" ); |
| 211 | value->OnValueRefreshed( temperature ); |
| 212 | if( value->GetPrecision() != precision ) |
| 213 | { |
| 214 | value->SetPrecision( precision ); |
| 215 | } |
| 216 | value->Release(); |
| 217 | |
| 218 | 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() ); |
| 219 | } |
| 220 | return true; |
| 221 | } |
| 222 | |
| 223 | else if( ThermostatSetpointCmd_SupportedReport == (ThermostatSetpointCmd)_data[0] ) |
| 224 | { |
| 225 | if( Node* node = GetNodeUnsafe() ) |
| 226 | { |
| 227 | // We have received the supported thermostat setpoints from the Z-Wave device |
| 228 | Log::Write( LogLevel_Info, GetNodeId(), "Received supported thermostat setpoints" ); |
| 229 | |
| 230 | // Parse the data for the supported setpoints |
| 231 | for( uint32 i=1; i<_length-1; ++i ) |
| 232 | { |
| 233 | for( int32 bit=0; bit<8; ++bit ) |
| 234 | { |
| 235 | if( ( _data[i] & (1<<bit) ) != 0 ) |
| 236 | { |
| 237 | if ( GetVersion() >= 3) |
| 238 | { |
| 239 | // Request the supported setpoints |
| 240 | Msg* msg = new Msg( "ThermostatSetpointCmd_CapabilitesGet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); |
| 241 | msg->SetInstance( this, _instance ); |
| 242 | msg->Append( GetNodeId() ); |
| 243 | msg->Append( 3 ); |
| 244 | msg->Append( GetCommandClassId() ); |
| 245 | msg->Append( ThermostatSetpointCmd_CapabilitiesGet ); |
| 246 | uint8 type = ((i-1)<<3) + bit; |
| 247 | if ( m_com.GetFlagBool(COMPAT_FLAG_TSSP_ALTTYPEINTERPRETATION) == false ) |
| 248 | { |
| 249 | // for interpretation A the setpoint identifier makes a jump of 4 after the 2nd bit ... wtf @ zensys |
| 250 | if ( type > 2 ) |
| 251 | { |
nothing calls this directly
no test coverage detected