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


Question

Posted (edited)

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
  • Thanks 1

Recommended Posts

  • 0
Posted
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 !!

  • 0
Posted
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 ?

 

 

 

 

  • 0
Posted (edited)
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
  • 0
Posted
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 ;) 

  • 0
Posted
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...

  • 0
Posted
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 :)

  • 0
Posted
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.

 

  • 0
Posted

EXCELLENT )) Thanks a lot for your (very) quick help :)

  • 0
Posted
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".
  • 0
Posted (edited)

With which command can I find out which profile is active

Edited by parip69
  • 0
Posted

hello, perhaps a very basic question 

how do we get the ID of the current scene running 

 

i tried: 

Quote
local __sceneId = fibaro.getDevicesID
fibaro.debug("test", __sceneId)

but the result is not the sceneID 

[11.10.2024] [15:01:37] [DEBUG] [TEST]: function: 0xffff1c0acaf0

 

 

to follow this topic

  • 0
Posted

You could do something like this:

 

local debug_TAG = "Garage light ID:" ..sceneId -- Tag for the debug messages
fibaro.debug(debug_TAG"some text overhere")
  • 0
Posted
18 minutes ago, SmartHomeEddy said:

You could do something like this:

 

local debug_TAG = "Garage light ID:" ..sceneId -- Tag for the debug messages
fibaro.debug(debug_TAG"some text overhere")

thanks it's working 

 

but just to report 

Quote

 

fibaro.debug(sceneId, "some text overhere")

 

 

return an error 

[SCENE318]: (load):2: Assertion failed: Expected string

 

and 

Quote
local debug_TAG = "" ..sceneId -- Tag for the debug messages
fibaro.debug(debug_TAG"some text overhere")

 

return no error

  • 0
Posted

i have something that don't understand 

i try to modify LUA HC2 to in LUA scene HC3 and i get some trouble 

 

i 'm using in a  function the order fibaro.set/getGlobalVariable but i don't find the contents in the general/variable 

even more i don't find the contents with LUA  

 

sequence

 

the log show the contents 

      fibaro.debug("zwave_monitor", "isGlobal: setDefault : gName: " .. gName .. " gData: " .. gData)

[11.10.2024] [18:03:20] [DEBUG] [ZWAVE_MONITOR]: isGlobal: setDefault : gName: zwave_318 gData: {"nackDev":0,"nackNum":0,"inUse":false,"sTotal":0,"deadBuffer":"","sampleEndTime":1728662600,"total":0,"devNum":0,"rptDev":0,"rptNum":0,"sampleStartTime":1728662600,"topDev":{"zAvg":0,"zMax":0,"sTotal":0,"zMin":1728662600,"inTotal":0,"sId":0,"total":0,"id":0,"inId":0},"sample":[{"sum":0,"total":0,"cpu2":0,"cpu1":0,"lRate":1,"lTime":1728662580,"sTotal":0,"dead":""}]}

i set the contents 

       fibaro.setGlobalVariable(gName, gData)

 

 

 

one line after 

in the same function 

 

i  get the value of the same GlobalVariable 

       fibaro.debug("zwave_monitor", "isGlobal: fibaro.getGlobalVariable(gName) " .. fibaro.getGlobalVariable(gName))

 

[ZWAVE_MONITOR]: isGlobal: fibaro.getGlobalVariable(gName)

 

but the contents is blank ?? 

do i miss something ? 

  • 0
Posted
6 minutes ago, jluc2808 said:

i have something that don't understand 

i try to modify LUA HC2 to in LUA scene HC3 and i get some trouble 

 

i 'm using in a  function the order fibaro.set/getGlobalVariable but i don't find the contents in the general/variable 

even more i don't find the contents with LUA  

 

sequence

 

the log show the contents 

      fibaro.debug("zwave_monitor", "isGlobal: setDefault : gName: " .. gName .. " gData: " .. gData)

[11.10.2024] [18:03:20] [DEBUG] [ZWAVE_MONITOR]: isGlobal: setDefault : gName: zwave_318 gData: {"nackDev":0,"nackNum":0,"inUse":false,"sTotal":0,"deadBuffer":"","sampleEndTime":1728662600,"total":0,"devNum":0,"rptDev":0,"rptNum":0,"sampleStartTime":1728662600,"topDev":{"zAvg":0,"zMax":0,"sTotal":0,"zMin":1728662600,"inTotal":0,"sId":0,"total":0,"id":0,"inId":0},"sample":[{"sum":0,"total":0,"cpu2":0,"cpu1":0,"lRate":1,"lTime":1728662580,"sTotal":0,"dead":""}]}

i set the contents 

       fibaro.setGlobalVariable(gName, gData)

 

 

 

one line after 

in the same function 

 

i  get the value of the same GlobalVariable 

       fibaro.debug("zwave_monitor", "isGlobal: fibaro.getGlobalVariable(gName) " .. fibaro.getGlobalVariable(gName))

 

[ZWAVE_MONITOR]: isGlobal: fibaro.getGlobalVariable(gName)

 

but the contents is blank ?? 

do i miss something ? 

 

 

i find the problem :  

 

we need to create the variable before by hand directly in général/variables , before using the LUA 

when the variable is already created then everything went OK 

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