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; what am I doing wrong?


Question

Posted

I've made a script that should switch another lamp if I press the main switch for that room. According to the level of the main lamp, the other lamp should be adjusted. That is, unless I manually control the secondary lamp. In that case it should stop adjusting according to the other lamp. As soon as I switch off the main lamp, the override is reset.

Basically everything is working. The lamps are interacting nicely, override is working and it is reset once the main lamp is switched off. Except for the 3rd elseif statement. For some reason the light won't be adjusted if "salontafel_status" get's over 50%. As far as I can see it doesn't deviate from the other 2 elseif statements, so I don't understand why it doesn't work.

Please login or register to see this code.

What is wrong here? I was so proud finally having written something a little more advanced than "Hello world!" now...

Please login or register to see this image.

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

3 answers to this question

Recommended Posts

  • 0
Posted

Why the loop?

not tested but something like this and you can use the device variable to check if it is running due to change in master or slave

Please login or register to see this code.

  • 0
  • Inquirer
  • Posted

    Thanks Robmac, this is working much better than what I had done. Using a trigger seems much better for stability of the HC2, in stead of then having scenes running sleep cycles every second or so and then doing a check in regard to a status. Just didn't know how to do it yet. Haven't found any problems yet, but then again, I only have 10 active (and rather simple) scenes.

    I've solved the problem with the last "elseif", for some reason it didn't accept < '100', but <= '99' does do the trick.

    Now I only have to figure out what you mean with the master and slave settings to replace the override local that I have now. Could you point me a bit in the right direction?

    Please login or register to see this image.

    /emoticons/default_icon_redface.gif" alt=":oops:" />

    • 0
    Posted

    Could you set override based on the device that triggered the scene. So if the master triggers the scene and master dimmer level is at a level override is turned off. If slave turn override on.

    [ Added: 2013-11-25, 17:20 ]

    Just spotted a big issue. You need to change text to numbers for > etc!!! That is why 99 works not 100 as you are doing text comparisons. Sorry did not spot earlier. Use tonumber() > 100

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