//-----------------------------------------------------------------------------
// <ManufacturerProprietary::SetValue>
// Set the lock's state
//-----------------------------------------------------------------------------
bool ManufacturerProprietary::SetValue
(
    Value const& _value
)
{
    uint64 value_id = _value.GetID().GetIndex();
    Msg* msg = new Msg( "ManufacturerProprietary_SetValue", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );

    if (FibaroVenetianBlindsValueIds_Blinds == value_id || FibaroVenetianBlindsValueIds_Tilt == value_id){
        ValueByte const* value = static_cast<ValueByte const*>(&_value);

        msg->SetInstance( this, _value.GetID().GetInstance() );
        msg->Append( GetNodeId() );
        msg->Append( 2 + // length of data
                     sizeof(MANUFACTURER_ID_FIBARO) +
                     sizeof(FIBARO_VENETIAN_BLINDS_GET_POSITION_TILT) );
        msg->Append( GetCommandClassId() );
        msg->AppendArray( MANUFACTURER_ID_FIBARO, sizeof(MANUFACTURER_ID_FIBARO) );
        if (FibaroVenetianBlindsValueIds_Blinds == value_id) {
            msg->AppendArray( FIBARO_VENETIAN_BLINDS_SET_POSITION, sizeof(FIBARO_VENETIAN_BLINDS_SET_POSITION) );
            msg->Append( value->GetValue() );
            msg->Append( 0x00 );
        } else if (FibaroVenetianBlindsValueIds_Tilt == value_id) {
            msg->AppendArray( FIBARO_VENETIAN_BLINDS_SET_TILT, sizeof(FIBARO_VENETIAN_BLINDS_SET_TILT) );
            msg->Append( value->GetValue() );
        }
        msg->Append( GetDriver()->GetTransmitOptions() );
        GetDriver()->SendMsg( msg, Driver::MsgQueue_Send );
        return true;
    } else {
        Log::Write( LogLevel_Info, GetNodeId(), "ManufacturerProprietary_SetValue %d not supported on node %d", value_id, GetNodeId());
        return false;
    }
}
//-----------------------------------------------------------------------------
// <ManufacturerProprietary::RequestValue>
// Request current value from the device
//-----------------------------------------------------------------------------
bool ManufacturerProprietary::RequestValue
(
    uint32 const _requestFlags,
    uint16 const _index,
    uint8 const _instance,
    Driver::MsgQueue const _queue
)
{
    if ( IsGetSupported() )
    {
        Msg* msg = new Msg( "ManufacturerProprietary_RequestValue", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
        if (FibaroVenetianBlindsValueIds_Blinds == _index || FibaroVenetianBlindsValueIds_Tilt == _index){
            msg->SetInstance( this, _instance );
            msg->Append( GetNodeId() );
            msg->Append( 1+sizeof(MANUFACTURER_ID_FIBARO)+sizeof(FIBARO_VENETIAN_BLINDS_GET_POSITION_TILT) ); // length of data
            msg->Append( GetCommandClassId() );
            msg->AppendArray( MANUFACTURER_ID_FIBARO, sizeof(MANUFACTURER_ID_FIBARO) );
            msg->AppendArray( FIBARO_VENETIAN_BLINDS_GET_POSITION_TILT, sizeof(FIBARO_VENETIAN_BLINDS_GET_POSITION_TILT) );
            msg->Append( GetDriver()->GetTransmitOptions() );
            GetDriver()->SendMsg( msg, _queue );
            return true;
        } else {
            Log::Write( LogLevel_Info, GetNodeId(), "ManufacturerProprietary_RequestValue Not Supported for value index %d",
                    _index);
        }
    } else {
        Log::Write( LogLevel_Info, GetNodeId(), "ManufacturerProprietary_RequestValue Not Supported on this node");
    }
    return false;
}