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

Question

Posted

Hi,

Since I'm fairly new to LUA i have some questions. Thanks for all help!

- Can i create a record in the Event log using LUA? Eg. to monitor the execution for scenes.

- Im using a customer VD for my Samsung TV, but id like to change the volume slider to instead control the volume of my SONOS speaker. How?

- Does it matter if i use single ' or double " with text strings?

- When should i really use semikolons?

- Does it matters how to i use brackets in conditions? Does the first bracket make any sense?

eg.if (tonumber(fibaro:getValue(36, "value")) > 0 and tonumber...

3 answers to this question

Recommended Posts

  • 0
Posted

I'll quickly answer what I know. Lua definitive guide is

Please login or register to see this link.

1) Write to event panel: not possible. Alternative: send yourself a mail or if you run your own web server it's technically possible to dump information there. I vaguely remember seeing it mentioned somewhere

2) Samsung / Sonos slider... I don't know. I suppose you want this because you have a playbar connected to your TV?

3) Single versus double quote. Doesnt't matter but... I have my preference. With double quotes I can say "It doesn't matter" and with single quotes it has to be 'It doesn\'t matter'

4) I can't remember when I last used a semicolon. It's only in the language to solve "ambiguous" statements. I don't know why they are so popular... they are c/c#/java thingies I think... So you can write on a single line:

Please login or register to see this code.

Look ma! No semicolons!

5) Brackets are only needed if the standard precedence (see "3.4.7 Precedence" in the lua manual) doesn't suit your purpose. Or for clarity, of course

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

  • 0
  • Inquirer
  • Posted

    Thanks a lot! It all makes sense!

    2) Yes, a playbar and would help a lot.

    • 0
    Posted
    4) I can't remember when I last used a semicolon. It's only in the language to solve "ambiguous" statements. I don't know why they are so popular... they are c/c#/java thingies I think... So you can write on a single line:

    Code:

    if a > b then fibaro:debug("'a' is greater than 'b'") end

    Look ma! No semicolons!

    Semicolons are just a carret character. So if you are writing multiple lines of code on a single line (which is poor coding practice to begin with if you ask me) you use semicolons to divide the line into sequential lines.

    But it is right, when you see it in Lua, it is mainly due to people having a hard time giving it up. Many languages require them as "enter" is just seen as a whitespace and not read as a new line.

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