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


  • 1

HC3 LUA vs HC2


knuth

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 

Please login or register to see this link.

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

Please login or register to see this attachment.

Edited by knuth
Moved summary table to first post
  • Like 1
Link to comment
Share on other sites

Recommended Posts

  • 0
On 5/25/2020 at 10:50 PM, jgab said:

You do something similar like the /refreshStates loop in my first example. That way you get all events in the system. You can filter out the ones you are not interested in. 

 

it's works perfektly !!!!

 

but I must create some filters because there is to much informations !

And it can create some problems...

 

I continue to reflect with filters... ?

 

Thanks for the idea !!

Link to comment
Share on other sites

  • 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 comment
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

Please login or register to see this code.

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 comment
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 comment
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 comment
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 ?

 

Please login or register to see this attachment.

 

Any help would be much appreciated :)

Link to comment
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

Please login or register to see this code.

 

Link to comment
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 comment
Share on other sites

  • 0

With which command can I find out which profile is active

Edited by parip69
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...