Jump to content
  • 1

HC3 LUA vs HC2


Question

In making the transfer from HC2 to HC3 based on a cloud backup (update 4.581 Beta) it is stated that "scenes will not be moved and need to be created again". That's OK, but it would be helpful when planning the transfer to know what the differences are (in syntax and available functions) between the two LUA versions. I know that the new LUA editor is documented in https://manuals.fibaro.com/home-center-3-lua-scenes/ . What I would hope to see in addition, is a side by side comparison of all the crucial differences, to enable a pre-edit of the old LUA scenes before entering them into the new editor. Something like this:

 

If you used this in HC2 LUA:                You need to do this in HC3 LUA:

fibaro.debug("txt")                                   fibaro.debug("tag", "txt")

os.time()                                                   ??? 

etc.

 

If we all contribute to such a table as we identify all the differences, we may be able to help each other prepare for HC3. Not all differences can easily be summarized in the simple two-column format above, however. For the new definition of conditions and triggers, it seems it would be more appropriate to give a few examples of old codes (with triggers) converted to new codes. 

 

PS: I haven't even decided to buy the HC3 yet! But getting a feel for the amount of re-programming needed to convert my scene is an important factor in making that decision. 

 

The suggested table is now shown in a pdf file attached to this post, see below. It is regularly updated as new contributions are posted.

LUA HC2 vs HC3.pdf

Edited by knuth
Moved summary table to first post
  • Like 1
  • Thanks 1
Link to post
Share on other sites
  • Answers 68
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Popular Posts

First version of summary table, including some that are not mentioned above. I am sure there is more, please post your contribution once you find other differences. The trigger section is still e

Yeah, I'd like to add that on HC3 Fibaro works on an "alpha" version internally, then publishes that "alpha" to a group of end-users for feedback.   At the moment, I am not 100% sure if the

On the HC3 there is only one instance running. They skipped the multiple instance model that was used in the HC2. A HC3 running instance either block a new scene or the new scene kills the runnin

Posted Images

Recommended Posts

  • 0
55 minutes ago, jjacques68 said:

I continue to reflect with filters... 🤔

 

So I created a simple list of device to filter events.

 

It works fine.

I check RefreshStates every 200 ms :) 

 

So now, I have a QA to do this, ok.

 

Can I create another QA to check also RefreshStates, but for something else, like my problems with PIR trigger ?

It's not too much ? 2 questioning ?

 

 

 

 

Link to post
Share on other sites
  • 0
24 minutes ago, jjacques68 said:

 

So I created a simple list of device to filter events.

 

It works fine.

I check RefreshStates every 200 ms :) 

 

So now, I have a QA to do this, ok.

 

Can I create another QA to check also RefreshStates, but for something else, like my problems with PIR trigger ?

It's not too much ? 2 questioning ?

If you used code similar to my example it will poll every 200ms, but if there are no events it will hang in the request which kind of pauses the loop so t's pretty ok.

Yes, you can have more than one QA that polls /refreshStates.

Another approach is that you have one QA that polls /refreshStates and then call the other QAs with something like

fibaro.call(<otherQA>,"newEvent",event)

 

and the other QAs have declared a function to receive the event

function QuickApp:newEvent(event)
     self:debug("New event received ",json.encode(event))
end

The only trick is to decide which types of events should be sent to which QA.

I made a QA some time ago that does something like this

 

 

Edited by jgab
Link to post
Share on other sites
  • 0
8 hours ago, jgab said:

Another approach is that you have one QA that polls /refreshStates and then call the other QAs

 

Yes I understand.

 

One QA to poll and many QA to do the actions...

 

And Why not with Parent/Child QA ;) 

Link to post
Share on other sites
  • 0
On 5/30/2020 at 10:27 AM, jgab said:

Another approach is that you have one QA that polls /refreshStates and then call the other QAs

 

I did it.

 

One QA to check changes in RefreshStates, and many QA to do actions.

 

For Ligths with PIR, it's works fine.

I don't miss event any more :) 

But I note a small latency (~= 1 seconde) when PIR value is TRUE and lights is ON.

I didn't have this with PIR as trigger of scene...

It's acceptable but... too bad...

Link to post
Share on other sites
  • 0
On 3/23/2020 at 8:54 AM, jgab said:

HC2:

fibaro:isSceneEnabled(sceneID)

fibaro:setSceneEnabled(sceneID , enabled)

fibaro:getSceneRunConfig(sceneID)

fibaro:setSceneRunConfig(sceneID ,runConfig)

 

HC3:

function fibaro.isSceneEnabled(sceneID) return api.get("scenes/"..sceneID).enabled end

function fibaro.setSceneEnabled(sceneID,enabled) return api.put("scenes/"..sceneID,{enabled=enabled}) end

function getSceneRunConfig(sceneID) return api.get("scenes/"..sceneID).mode end

function setSceneRunConfig(sceneID,runConfig) return api.put("scenes/"..sceneID,{mode=runConfig}) end -- mode is 'automatic' or 'manual'

 

Hi everyone. I am looking to get a scene status with this function, but it always returns a "nil" value ? What am I doing wrong ?

 

1594139431_Screenshot2020-07-05at12_21_29.thumb.png.70f7faa582fde4fdba2a9be5dd38b965.png

 

Any help would be much appreciated :)

Link to post
Share on other sites
  • 0
20 minutes ago, jguellec said:

Hi everyone. I am looking to get a scene status with this function, but it always returns a "nil" value ? What am I doing wrong ?

Any help would be much appreciated :)

 Sorry, the path in the api.get should start with a "/". 

Like

function fibaro.isSceneEnabled(sceneID) return api.get("/scenes/"..sceneID).enabled end
function fibaro.setSceneEnabled(sceneID,enabled) return api.put("/scenes/"..sceneID,{enabled=enabled}) end
function getSceneRunConfig(sceneID) return api.get("/scenes/"..sceneID).mode end
function setSceneRunConfig(sceneID,runConfig) return api.put("/scenes/"..sceneID,{mode=runConfig}) end -- mode is 'automatic' or 'manual'

 

Link to post
Share on other sites
  • 0
On 3/11/2020 at 2:56 AM, cag014 said:

Please add

HC2

fibaro:startScene(id,{args}) 

HC3

fibaro.scene("execute",{id,id})

no arguments anymore

This did not work form me.  I had to convert a block scene to lua to find that the syntax is

fibaro.scene ('execute',{[1] = id})
Which makes sense as it kept giving the error "Table expected".
Link to post
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...