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

IF / THEN LUA Script error..


Question

Posted

Hi!

 

I want to get the information about the on/off-status of a HUE device and based on that, it should change... with a simple IF/THEN-script. Unfortunatley, it seems that I did something wrong. Could someone help me, please?

 

Please login or register to see this code.

I receive this error:

Quote

[DEBUG] 13:38:45: 2019-01-13 13:38:45.397112 [ fatal] Unknown exception: /opt/fibaro/scenes/33.lua:2: unexpected symbol near 'then'

 

What's wrong? I hope you can help me... thank you very much!

 

Dan

5 answers to this question

Recommended Posts

  • 0
Posted

@Danielos

I don't have hue devices but maybe if you try.

 

If (tonumber(fibaro:getValue(17, ui.onOff.value)) == 0 ) 

Then

Fibaro:call(17, "turnOn")

else

fibaro:call(17, "turnOff")

end

  • 0
  • Inquirer
  • Posted

    @Reinhold Thank you, but the next error shows up then...

     

    Quote

    [DEBUG] 15:36:24: 2019-01-13 15:36:24.771480 [ fatal] Unknown exception: /opt/fibaro/scenes/33.lua:31: syntax error near 'fibaro'

     

    The error is for the first "Then"...

    • 0
    Posted
    2 minutes ago, Danielos said:

    @Reinhold Thank you, but the next error shows up then...

     

     

    The error is for the first "Then"...

    Lua is case-sensitive. It's 'if', 'then', 'else', and  'end'

    • 0
  • Inquirer
  • Posted

    @jgab unfortunatley, it didn't help...

    Quote

    [DEBUG] 15:45:09: 2019-01-13 15:45:09.118841 [ fatal] Unknown exception: /opt/fibaro/scenes/33.lua:30: unexpected symbol near 'then'

    Now the error is then and before Then ;-)

    • 0
    Posted (edited)

    I have found a website where some lua commands are posted if i look into this then you can try. 

     

    if fibaro:getValue(17' "on") 

    then

    fibaro:call(17, "turnOff")

    else

    fibaro:call(17, "turnOn")

    end

     

    Look on the next website en scroll douwn to lua commands. 

     

    Please login or register to see this link.

    Edited by Reinhold

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