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

Code problems - switch off light if motion from either sensor is breached else switch on


Question

Posted

This code seems to have all sorts of problems; sometimes the lights never switch on, othertimes they never switch off, sometimes they flick on, then off, occasionally the lights are dim! I'd like some clues if possible as to what's wrong with the code. I'm happy to try some alternative ideas, but ideally I'd like to keep this scene using this logic! Oh one other thing, the scene runs in duplicate (originally I had problems with the or so had two separate scenes for each sensor, is this a better idea?). As always, thanks guys!

 

Please login or register to see this code.

 

2 answers to this question

Recommended Posts

  • 0
Posted

Hi @slowpoke115 ,

 

Scene above has many flaws, but that is for some other topic. Fore beginning you have to remove 276 value from scene header since it is virtual device with button and slider so it does nothing and you should put missing 113 value so that scene is also triggered by other sensor:

Please login or register to see this code.

Second problem is your first IF check where you turning off lights if one of the two motion sensors is not breached or scene is run manually. That is very strange since motion sensors are located in two different rooms landing and bathroom so there is no chance that they will be breached at the same time. Also you didn't tell us where that HUE light is located is it in the bathroom or landing?

 

Since you failed to explain what do you really want to achieve with this two motion sensors and a light which location is unknown it is difficult to give any more recommendations.

 

I can tell you for sure that scene is doing exactly how it is written. So if you breach motion sensor on landing, but bathroom sensor is not breached then light will turn off. Then if you breach motion in bathroom while motion on landing is still breached then nothing will happen since bathroom motion is not set to trigger this scene. But if you exit bathroom and trigger motion on landing while bathroom motion is still breached then light will turn on and so on....

 

I suggest that you change IF line to this:

Please login or register to see this code.

This will ensure that light is turned on which ever motion sensor is breached and will stay on until both motion sensors change to safe state.

 

Then you can definitely remove those double commands to HUE virtual device and depending on code that is under brightness slider you can just send command:

Please login or register to see this code.

To turn HUE light on. If it doesn't work then go to forum DOWNLOAD section and get my Philips HUE AIO VD that can control all sorts and types of lamps connected to HUE bridge :-) 

 

Of course you can also find here some nice and simple code that can control lights in a simple way.

 

  • 0
  • Inquirer
  • Posted (edited)

    I ended up putting the code into a fibaro lua debugger, there were problems with the if statement requiring binary logic and not a string comparison (== rather than >) (

    Please login or register to see this link.

    ). I'm still seeing problems with the lights dimming rather than switching to full brightness but, repeating the code seems to resolve this (this I'm pretty sure is a virtual device problem). I also removed the presence of two scenes as I think this was causing a race condition. Not seeing any problems anymore.

     

    Quote

    Scene above has many flaws

     

    Thanks for your kind words.

    Edited by slowpoke115

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