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

How are you updating your QuickApps


cincura.net
 Share

Question

How are y'all updating your QuickApps? If it's just a one instance, it's easy; that's the one I'm working on. But I have my app 7 times in HC3 and going manually over all and copy-pasting new code seems pretty dumb.

  • Thanks 1
Link to comment
Share on other sites

16 answers to this question

Recommended Posts

  • 0

ctrl-A / del / ctrl-V.

chuck norris approves

PS: not irony I have asked about this in the spring time @A.Socha he said what Fibaro always thinking about developers and end-users but no solution yet.

Link to comment
Share on other sites

  • 0
5 hours ago, cincura.net said:

How are y'all updating your QuickApps? If it's just a one instance, it's easy; that's the one I'm working on. But I have my app 7 times in HC3 and going manually over all and copy-pasting new code seems pretty dumb.

There are various approaches to make it easier...

You could design your QA so that it copies its 'main' file to the other QAs when it restart using the api. Something like in the below post 

 

I use ZeroBrane with an emulator that allows me to deploy the QA code on the

Please login or register to see this link.

 - and update the code of existing QAs.

 

The last alternative is to make these QAs QuickAppChildren. Then you will have one master QA with the code and it will create the children. This doesn't work if you need to create custom UIs for the moment but work quite well for standard devices.

 

 

 

 

 

Edited by jgab
  • Thanks 1
Link to comment
Share on other sites

  • 0

@jgab can your solution check what a new local var have added and do not change already exists values?

Link to comment
Share on other sites

  • 0
1 minute ago, 10der said:

@jgab can your solution check what a new local var have added and do not change already exists values?

Well, the QA always have to restart when you update the code.

Or do yo you mean quickAppVariables?

Link to comment
Share on other sites

  • 0

This is how a QA could look that would copy it's "main" file to all its "twin QAs"

Please login or register to see this code.

The TwinID is what all twins have in common. You can have many different "twin groups"

One of the QAs - the master - that you code in will also have its quickAppVariable "MasterTwin" set to "yes". That is to prevent the twins to also start to update each other when they restarts. (set MasterTwin to "no" on twins to avoid the debug complaint that MaterTwin does not exist)

Every time the master twin is restarted it will patch the other QAs with the same main code. If you have more files than "main" it's easy to extend.

It does not update the quickAppVariables - it can be extended to do that too, but then be careful not to copy the MasterTwin quickVar...

 

1 hour ago, 10der said:

yep.

Let me look into that. I think currently it will replace with vars from the "emulator code".

Hmm, to keep existing quickAppVars could be an option because it's not always what you want. Many times I want to start from fresh.

Edited by jgab
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 0
9 hours ago, jgab said:

This is how a QA could look that would copy it's "main" file to all its "twin QAs"

Please login or register to see this code.

 

Great jgab

Is it possible to use this piece of code (changed) to provide all my quickApps with the same second file.

With all my helper functions in it. great... love that..

 

thanks.

 

Link to comment
Share on other sites

  • 0
11 hours ago, NLWaard said:

Great jgab

Is it possible to use this piece of code (changed) to provide all my quickApps with the same second file.

With all my helper functions in it. great... love that..

 

thanks.

 

 

Yes. The below. would push the. file "myLibrary" to all other QAs that have that LibName quickVar. set  to the same. Master also has master set as in the previous example.

Please login or register to see this code.

 

If you start. to have many library files you may have to start to think about the order they load.

I have a toolbox that builds on this principle and loads the file in the order I specify

 

Edited by jgab
  • Thanks 1
Link to comment
Share on other sites

  • 0
1 hour ago, jgab said:

 

Yes. The below. would push the. file "myLibrary" to all other QAs that have that LibName quickVar. set  to the same. Master also has master set as in the previous example.

Please login or register to see this code.

 

Really great. You're the best. Thanks.

Lidle change, i changed:    local push = true    to :   local patch = true

 

And then I added the variable LibName = myLibrary to the quickApp, which I wanted the file to be added to.

t's working as expected. Insane.

 

  • Thanks 1
Link to comment
Share on other sites

  • 0
9 hours ago, NLWaard said:

Really great. You're the best. Thanks.

Lidle change, i changed:    local push = true    to :   local patch = true

 

Thanks, I have fixed (patched) the original post too.

 

Quote

And then I added the variable LibName = myLibrary to the quickApp, which I wanted the file to be added to.

t's working as expected. Insane.

 

 

The exercise left for the reader is to extend it to take a list of files that needs to be copied.

 

A thought, here it is the "master library" that pushes the file to other QAs. Another approach is that when QAs are restarted they look up the master library and patch themselves (or call the master library's function QuickApp:patchMe(myID,fileName) ... )

Now the code compares the file and only patch if they are different. One could introduce a version numbering schema instead.

Edited by jgab
  • Thanks 1
Link to comment
Share on other sites

  • 0
On 10/1/2020 at 8:38 AM, jgab said:

A thought, here it is the "master library" that pushes the file to other QAs. Another approach is that when QAs are restarted they look up the master library and patch themselves (or call the master library's function QuickApp:patchMe(myID,fileName) ... )

Now the code compares the file and only patch if they are different. One could introduce a version numbering schema instead.

Often I run into the limitations of this Fibaro-Lua programming environment, so I really appreciate your contribution to this forum. THANKS.


I also know that you have created your own environment, which makes my comment below seems te be pointless.

And I haven't thought carefully about the possible solutions that you come up with before. sorry.

 

Your second remark can of course be included in the library itself, which has considerable added value.

But I think it would even be better to be able to update the master from the QA in which you work at that time (included in your myLibrary, because you always have small changes or additions),

after which you change a variable in the master or execute a global  function in the master (for example with the id of the QA from which you are working at that moment) and then roll out that new master over the other QA's again.

Or am I going to far now ...

 

Maybe the guys from Fibaro should give the possibility to refer to one master file.

(If the user uses the same filename in a QA, then that file is the same over all QA's that uses that file).

Then I have my own library (Lua-Extension) again for all QA's and it is also more like OOP.

Maybe something @A.Socha  can support us in.

 

Once again, jgab, thank you very much for your reaction. 

 

Edited by NLWaard
Link to comment
Share on other sites

  • 0

Does this has to do with the update?

but the following code doesn't create the file "myLibrary" anymore...(post or put gives the same result).

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0
21 minutes ago, NLWaard said:

Does this has to do with the update?

but the following code doesn't create the file "myLibrary" anymore...(post or put gives the same result).

Please login or register to see this code.

 

post creates a new file (and will fail if it already exists)

put will update an existing file (and fail if it doesn't exist)

The code assumed that the file did exists. If you want to create a file from scratch do

Please login or register to see this code.

 

Edited by jgab
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 0

Ok, so the difference is removing of the filename at the end of the api call.

 

I searched in the swagger, but unfortunately I couldn't find it. How do you know this?

Thanks again..

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.

 Share

×
×
  • Create New...