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


HC3: backup scenes / QAs


10der

Recommended Posts

1 minute ago, petergebruers said:

I like it. The funny thing though is this: the HC2 had "triggers" as comments at the top of the scene code, then HC3 moves away from this and has separate edit windows for condition and action.

The trouble with JSON is ... it needs special diff tool, it does not work well when using classic text diff/merge. Sorting the keys/values might help, I have never tried. Same issue with Lua tables and key/value stores in other languages, they do not define a fixed order (most people assume by that "insertion order" and some "alphabetical order") by design. After all it does not matter if you say "a=1; b=2;" or "b=2; a=1;" when that text represents k/v pairs.

So , my code goes to the trouble to sort the json keys in a stable order just because of this. issue,

Link to comment
Share on other sites

9 minutes ago, jgab said:

So , my code goes to the trouble to sort the json keys in a stable order just because of this. issue,

I noticed, I forgot to mention I looked at your code, I always do - LOL ;) - what I meant to say is "I am not sure if sorting it makes diff-ing more usable". But maybe you know the answer. Do you happen to store the resulting files in a (git) repository? Then you'll now if the text diffs are any good...

Link to comment
Share on other sites

Quote

 

Please login or register to see this link.

 On 5/11/2020 at 11:33 AM, 

Please login or register to see this link.

 said:

I will test on different platforms ;)

Awesome!

Please login or register to see this link.

 On 5/11/2020 at 11:34 AM, 

Please login or register to see this link.

 said:

no issues on win

Generally speaking "no issues" but that "?" issue is an O/S thing so no language can work around that...

 

Work as expected on Windows 7>10, OSX 10.13+, Linux and FreeBSD also...

 

Tested on Mac mini under Sierra (10.13.6):

 

Please login or register to see this attachment.

 

Scenes backup do the job

 

image.png.9f1a0689da1168a5a43994f5ec667396.png

 

image.png.c38c0503711730b7b429e94d4d2656b1.png


I plan to add an additional file ex: "4-FGKF 601 - Events- [Report] .txt" with basic but useful information: Name, Categories, start mode....

Edited by Krikroff
  • Thanks 2
Link to comment
Share on other sites

So, my goal is not backup per se, but to be able to download/edit/upload resources using ZBS.

Now I have backup/download integrated. The flat file format allows for easy upload.

Only supports QuickApps, Scenes, Global variables, CustomEvents, and Locations at the moment (that's what I work with)

 

I do have some minor issues with restoring QuickApps. Posting to /quickApp/ allows for creating a new QA (new id).

Putting to /devices/ with 

   {properties={
            quickAppVariables = <vars>,
            mainFunction = <code>,
            uiCallBacks = <callbacks>,
          }}

allows for modifying an existing QuickApp. But I can't put the whole devices struct, nor add viewLayout. So, if the viewLayout is modified I have to create a new QuickApp - not satisfactory...

 

Anybody know how to update (keeping the id) with more parts of the device struct?

 

The code leverage the ZBS plugin to run the commands but the code is included in the fibaroHC3.lua sdk and could be used from within code run in the editor too

(In fact I run the fibaroHC3.lua in a shell from the plugin to carry out the work)

Link to comment
Share on other sites

On 5/10/2020 at 7:38 PM, 10der said:

Peter,  with all due respect to you

Please login or register to see this link.

it's NOT JSON

Please login or register to see this link.

 

just proof

 

It's funny. If it's a block scene the conditions part is a json struct. If it's a lua scene it's a Lua table. That inconsistency bit me when I tried to convert scenes.... ;-)

  • Thanks 1
Link to comment
Share on other sites

11 minutes ago, jgab said:

If it's a block scene the conditions part is a json struct. If it's a lua scene it's a Lua table.

Ah, that explains my confusion. In January I filed a bug <HC3-345 Type of "Conditions" in api/scenes seems inconstent>. I couldn't quite see at that time why my json decoder sometimes failed, that happened when it is in fact a Lua table. That bug is still in review. I'll post a link to this explanation.

Link to comment
Share on other sites

  • 2 months later...
On 5/12/2020 at 6:37 PM, Krikroff said:
 

Work as expected on Windows 7>10, OSX 10.13+, Linux and FreeBSD also...

 

Tested on Mac mini under Sierra (10.13.6):

 

Please login or register to see this attachment.

 

Scenes backup do the job

 

Please login or register to see this link.

 

Please login or register to see this link.


I plan to add an additional file ex: "4-FGKF 601 - Events- [Report] .txt" with basic but useful information: Name, Categories, start mode....

When can we use it?

Link to comment
Share on other sites

  • 6 months later...

hc.ini 

 

Please login or register to see this code.


 

python. hc3_script_backup_new.py

Please login or register to see this attachment.

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
Reply to this topic...

×   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...