Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Auto backup


Neo Andersson

Question

@jgab Hello Jan

 

I was able to make a function that retrieves the backup possibility..

 

Please login or register to see this code.

 

Now i want to make the function that creates the backup, would you be so kind to assist a little bit, how to formulate the POST call, and what is what inside the BODY that should be set. Its not celar for me. This is the BODY in SWAGGER

 

 

Please login or register to see this code.

Please login or register to see this code.

 

 

 

I think we should set the action to  "create", the description is obviusly the description, the type can be i think local or remote (jsut my guess), but what to do with ID and the version?

How would the HTTP post look like?

 

Thanks a lot

 

 

 

 

 

 

 

 

 

 

 

 

Please login or register to see this code.

 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hi @Neo Andersson ,

 

You don't need to worry about version and ID, this is handled by HC3. All you need to provide is this payload:

Please login or register to see this code.

 

At least this is how it works on HC2. Comparing HC2 and HC3 backup records it looks the same therefore I expect that payload for adding backup is also the same.

Link to comment
Share on other sites

  • 0

In ER5 now there is a hc3api.get(), hc3api.put(), hc3api.post(), hc3api.delete() available now that is like api.* but it makes 

net.HTTPClient calls with credentials.

Allows us to do ex. the backups stuff simpler.

 

we need to set the magic variable _creds with the credentials

Please login or register to see this code.

and we can make the calls synchronous without waiting for a callback.

 

We can do it even better by defining special function for ex. retrieving backups

Please login or register to see this code.

We have a backups(typ) function that return either the remotes or the locals backups.

The rule calls it and creates a log message with all remote backups with id, description, and time stamp

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • 4 hours ago, Sankotronic said:

    Hi @Neo Andersson ,

     

    You don't need to worry about version and ID, this is handled by HC3. All you need to provide is this payload:

    Please login or register to see this code.

     

    At least this is how it works on HC2. Comparing HC2 and HC3 backup records it looks the same therefore I expect that payload for adding backup is also the same.

    thanks

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 24 minutes ago, jgab said:

    In ER5 now there is a hc3api.get(), hc3api.put(), hc3api.post(), hc3api.delete() available now that is like api.* but it makes 

    net.HTTPClient calls with credentials.

    Allows us to do ex. the backups stuff simpler.

     

    we need to set the magic variable _creds with the credentials

    Please login or register to see this code.

    and we can make the calls synchronous without waiting for a callback.

     

    We can do it even better by defining special function for ex. retrieving backups

    Please login or register to see this code.

    We have a backups(typ) function that return either the remotes or the locals backups.

    The rule calls it and creates a log message with all remote backups with id, description, and time stamp

     

    Ohh man, this is not my level at this point to understand..:-) Okay i will try...

    So i need to create a rule with that _cred magic variable that holds my actual credentials. I suppose _cred is kinda inbuilt variable in ER5 right? So that is used behind the scenes in rule rule("b = hc3api.get('/service/backups'); log('%s',b)"), and variable b will hold a table with all backups.  So i can use a similar approach to get back backupStatuses like 

    Please login or register to see this code.

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I have managed to create a backup with a Http call, but it made a backup that is way larger than it should be. It is probably due to the option "Save the content of history". However, there is no parameter, that is related to this option.

     

     

    Please login or register to see this image.

    /monthly_2023_12/image.png.e23bf35d7daf3b6840e32daa21113c25.png" />

     

    Anyone has any knowledge, where to set this parameter in a HTTP call? 

    The swagger shows only these parameters that can be sent

     

    Please login or register to see this code.

     

    There is nothing related to historical data

     

    Edited by Neo Andersson
    Link to comment
    Share on other sites

    • 0

    Hi @Neo Andersson ,

     

    just to complete this thread, as you already get info from @m.roszak, call to make backup skipping history data is something like this:

    Please login or register to see this code.

     

    Is that correct?

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 1 hour ago, Sankotronic said:

    Hi @Neo Andersson ,

     

    just to complete this thread, as you already get info from @m.roszak, call to make backup skipping history data is something like this:

    Please login or register to see this code.

     

    Is that correct?

     

    Yes, correct

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I am sharing here a little QA that manages backups. Some can use it in block scenes, and link it to some exact time, and make it automatic. I will wrap it into my ER5 system later, but so far maybe some will find this usefull.

    I would appreciate any feedback about it, as testing is quite cumbersome, as every time it succedes, my system restarts :-) due to the succesfull backup downloading. I have tested it with both local and cloud types, and worked fine.

    Just fill up the QA variables with you crednetials and IP address.

     

     

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    • Thanks 1
    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...