----------------------------------------------------------------------------- Set a value in the device -----------------------------------------------------------------------------
| 297 | // Set a value in the device |
| 298 | //----------------------------------------------------------------------------- |
| 299 | bool ClimateControlSchedule::SetValue |
| 300 | ( |
| 301 | Value const& _value |
| 302 | ) |
| 303 | { |
| 304 | // bool res = false; |
| 305 | uint8_t instance = _value.GetID().GetInstance(); |
| 306 | uint8_t idx = (uint8_t)(_value.GetID().GetIndex() & 0xFF); |
| 307 | |
| 308 | if( idx < 8 ) |
| 309 | { |
| 310 | // Set a schedule |
| 311 | ValueSchedule const* value = static_cast<ValueSchedule const*>(&_value); |
| 312 | |
| 313 | Log::Write( LogLevel_Info, GetNodeId(), "Set the climate control schedule for %s", c_dayNames[idx]); |
| 314 | |
| 315 | Msg* msg = new Msg( "ClimateControlScheduleCmd_Set", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() ); |
| 316 | msg->SetInstance( this, instance ); |
| 317 | msg->Append( GetNodeId() ); |
| 318 | msg->Append( 30 ); |
| 319 | msg->Append( GetCommandClassId() ); |
| 320 | msg->Append( ClimateControlScheduleCmd_Set ); |
| 321 | msg->Append( idx ); // Day of week |
| 322 | |
| 323 | for( uint8_t i=0; i<9; ++i ) |
| 324 | { |
| 325 | uint8_t hours; |
| 326 | uint8_t minutes; |
| 327 | int8 setback; |
| 328 | if( value->GetSwitchPoint( i, &hours, &minutes, &setback ) ) |
| 329 | { |
| 330 | msg->Append( hours ); |
| 331 | msg->Append( minutes ); |
| 332 | msg->Append( setback ); |
| 333 | } |
| 334 | else |
| 335 | { |
| 336 | // Unused switch point |
| 337 | msg->Append( 0 ); |
| 338 | msg->Append( 0 ); |
| 339 | msg->Append( 0x7f ); |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | msg->Append( GetDriver()->GetTransmitOptions() ); |
| 344 | GetDriver()->SendMsg( msg, Driver::MsgQueue_Send ); |
| 345 | } |
| 346 | else |
| 347 | { |
| 348 | // Set an override |
| 349 | ValueList* state = static_cast<ValueList*>( GetValue( instance, ClimateControlScheduleIndex_OverrideState ) ); |
| 350 | ValueByte* setback = static_cast<ValueByte*>( GetValue( instance, ClimateControlScheduleIndex_OverrideSetback ) ); |
| 351 | |
| 352 | if( state && setback ) |
| 353 | { |
| 354 | ValueList::Item const *item = state->GetItem(); |
| 355 | if (item == NULL) { |
| 356 | return false; |
nothing calls this directly
no test coverage detected