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

Need script/scene switch lights on, extend or restart the scene if motion sensor is breached and not change anything when lights are already on


Lucas.hannink

Question

Hello,

I'm new to Fibaro Home Center and LUA scripts.

This script is serving me well, but I want to make it a bit smarter.

 

--[[
%% properties
288 value
196 value
%% events
%% globals
--]]

local lightID = 288 -- ID van de lamp
local Motion = 196 -- ID van de bewegingsensor
local sleepTime = 5*60 -- tijd in seconden, dat de lampen aanblijven
local DagNacht = fibaro:getGlobalValue("DagNacht")

if

fibaro:getValue(Motion,'value') == '1' and fibaro:getGlobalValue("DagNacht") == "Nacht"

then

fibaro:debug("Someone moved, turn on light and abort")
    fibaro:call(lightID, "setSlider", "3", "50")
    fibaro:call(lightID, "pressButton", "1")
fibaro:killScenes(__fibaroSceneId)

end

fibaro:debug("No one moving...")
fibaro:sleep(1000*sleepTime)
fibaro:debug(string.format("No one moved moved for %ss, turn off light %s",sleepTime,lightID))
fibaro:call(lightID,"pressButton", "2")

 

Now I want this scene to only turn on the lights in the room when they are off and the motion sensor reports motion. When the lights are already on, the scene doesn't have to change anything.

All of the lights are setup with the Philips Hue AIO VD. Can someone help me?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

I assume your lamp variable is the lightID is for a dimmer type lamp

 

change the code part like this


 

Please login or register to see this code.

 

 

.... 

Edited by Neo Andersson
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hello Neo,

     

    The lightID is a philips hue lamp inside a virtual device. I could be wrong but I think there is no value to read out.

    Is there an other option?

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
    2 hours ago, Lucas.hannink said:

    Hello Neo,

     

    The lightID is a philips hue lamp inside a virtual device. I could be wrong but I think there is no value to read out.

    Is there an other option?

    Please login or register to see this attachment.

     

    Is this on HC3 at all?

    I think you are on HC2, sorry...i could have noticed this sooner..

     

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