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

LUA - few questions of new user


Didytz

Question

Hi,

I am still trying to learn LUA. I tried to follow few examples from internet but I still don't understand few things, so would appreciate if someone could clarify me following:

 

1) Can I write and paste somewhere in my hub code like this:

Please login or register to see this code.

 

or I must follow   DECLARATIONS (Conditions/Triggers)    - >  ACTIONS

 

 

2) If I must use DECLARATIONS  /  ACTIONS is it allowed to put condition in action part.  If it is allowed what is format?

I try to control heating by opening/closing windows and want to turn on heating only if it was ON before windows were open and to keep it OFF if it was OFF before windows opening.

  Is this valid "ACTIONS" code:

Please login or register to see this code.

As I am not able to set variable like this. I try to get Walli output state into variable at the moment of the windows opening. If this is possible then I would not need condition in ACTIONS.

 

 

3) When I translate block scene to LUA, why I see "hub.*" instead of "fibar.*" as it is in every example.

 

 

Sorry for mix of all kind questions but I just can't progress in learning without clearing this.

 

 

 

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
7 hours ago, Didytz said:

Hi,

I am still trying to learn LUA. I tried to follow few examples from internet but I still don't understand few things, so would appreciate if someone could clarify me following:

 

1) Can I write and paste somewhere in my hub code like this:

Please login or register to see this code.

 

or I must follow   DECLARATIONS (Conditions/Triggers)    - >  ACTIONS

 

no, don't use these HC2/HCL examples, i mean the trigger section. You have HC3L, so you must use the declarations->actions way. Of course on the action side, you might still check "who" run the scene, by checking the sourceTrigger, but that's different story (use search to find examples here in forum)

 

 

7 hours ago, Didytz said:

 

2) If I must use DECLARATIONS  /  ACTIONS is it allowed to put condition in action part.  If it is allowed what is format?

I try to control heating by opening/closing windows and want to turn on heating only if it was ON before windows were open and to keep it OFF if it was OFF before windows opening.

  Is this valid "ACTIONS" code:

Please login or register to see this code.

As I am not able to set variable like this. I try to get Walli output state into variable at the moment of the windows opening. If this is possible then I would not need condition in ACTIONS.

 

 

the getValue will return boolean value, the setGlobalVariable need string, you can see it:

Please login or register to see this code.

 

type is string

 

Please login or register to see this code.

 

type is boolean

 

Please login or register to see this code.

 

thsi returns an error:

 

[26.09.2022] [18:37:23] [ERROR] [SCENE78]: (load):8: Assertion failed: Expected string

 

so the proper way is to convert the boolean to string

 

Please login or register to see this code.

 

 

7 hours ago, Didytz said:

3) When I translate block scene to LUA, why I see "hub.*" instead of "fibar.*" as it is in every example.

 

FIBARO is part of Nice S.p.A., there are other gateways using same firmware engine, like Yubii Home sold by

Please login or register to see this link.

or

Please login or register to see this link.

Therefore, to unifi the code, the fibaro.* has been changed to hub.*

 

Examples has been not yet updated, is actually not necessary to care, as the fibaro.* will be still executed (as backward compatibility)

Link to comment
Share on other sites

  • 0
14 hours ago, Didytz said:

Hi,

I am still trying to learn LUA. I tried to follow few examples from internet but I still don't understand few things, so would appreciate if someone could clarify me following:

 

1) Can I write and paste somewhere in my hub code like this:

Please login or register to see this code.

 

or I must follow   DECLARATIONS (Conditions/Triggers)    - >  ACTIONS

 

 

2) If I must use DECLARATIONS  /  ACTIONS is it allowed to put condition in action part.  If it is allowed what is format?

I try to control heating by opening/closing windows and want to turn on heating only if it was ON before windows were open and to keep it OFF if it was OFF before windows opening.

  Is this valid "ACTIONS" code:

Please login or register to see this code.

As I am not able to set variable like this. I try to get Walli output state into variable at the moment of the windows opening. If this is possible then I would not need condition in ACTIONS.

 

 

3) When I translate block scene to LUA, why I see "hub.*" instead of "fibar.*" as it is in every example.

 

 

Sorry for mix of all kind questions but I just can't progress in learning without clearing this.

 

 

 

 

 

Use the blocks to create rules, it’s much more easier than lua. ?

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