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

Trying to make following - when a scene is triggered then turn on lights then wait for x minutes before turning off, everytime movement is detected start countdown over


Carsten6000

Question

Hi guys, haven't get any clue on how to solve the above mentioned problem. 

 

Can anybody help?

 

Did try to convert the blockscene to Lua (but no experience with Lua).

Can anybody give me the solution. 

 

Further I would like that If lights are manually turned on I don´t want it to turn off automatically. (then the motion scene must be deactivated before lights manually turned off again) 

 

 

Please login or register to see this attachment.

Edited by Carsten6000
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I use this one, maybe it will help you. With a little modification it can be adapted to suit you.

 

-- This scene includes one or more lights:

-- when the Lux level is below a certain level (see DECLARATIONS) and

-- shows the lux level of one or more lux sensors and

-- turns off the light after a certain time (maxTime),

-- if there is no movement from one or more motion sensors

 

-- Enter the correct IDs (if there is more than one, separate them with a ",") and the desired maximum time the light should remain on.

 

local light = {636, 766} -- ID lights to turn on

local motion = {1059} -- ID motion sensors to check if they are broken

local Presence = (1369) -- ID Presence sensor

local maxTime = 3*60  -- Maximum time the sensor must be safe before turning off (n * 60, where n is minutes)

local sleepTime = 5 -- Time in seconds between each motion sensor check (default = 5)

local debug_TAG = " Scene BATH light " --- Tag for debug messages

-- Let's see who started the scene –

local trigger = sourceTrigger

-- print(json.encode(trigger)) -- Who started the scene, trigger

-- print(json.encode(trigger["id"])) -- ID launched the scene

    if (json.encode(trigger["id"])) == "1059" -- If triggered by a motion sensor

        then

            maxTime = 3*60 -- bet counter for N minutes

            fibaro.debug(debug_TAG, '<font color="yellow"> Lights on AUTOMATICALLY

</font>')

            fibaro.debug(debug_TAG," The counter is set to: " ..maxTime)

        else

            maxTime = 10*60 -- bet counter for N minutes

            fibaro.debug(debug_TAG, '<font color="blue"> Light turned on MANUALLY </font>')

            fibaro.debug(debug_TAG," The counter is set to: " ..maxTime.. " секунд.")

        end

  

for i in pairs(light) do -- Turn on the light

  fibaro.debug(debug_TAG,"Turn on (ID " ..light[i] ..") " ..fibaro.getName(light[i]) .." for " ..maxTime .." seconds")

  fibaro.call(light[i],"turnOn")

  fibaro.call(light[i], 'setValue', 100)

end

 

local safeTime = 0

while safeTime < maxTime do -- Loop until maxTime is reached

  fibaro.sleep(sleepTime*1000)                

  safeTime=safeTime+sleepTime

  -- fibaro.debug(debug_TAG," Seconds passed (safeTime) " ..safeTime .. " up to maximum (maxTime) "  ..maxTime)

--------------

for i in pairs(light) do -- Check if the light is turned off manually

  if fibaro.getValue(light[i], "value") == 0

    then

        fibaro.debug(debug_TAG, '<font color="blue"> Manually turned off lamp: </font>' ..light[i] .." " ..fibaro.getName(light[i]))

        --fibaro: abort (327)

        fibaro.scene("kill", {327})

    end

end

--------------

  for i in pairs(motion) do

    if fibaro.getValue(motion[i], "value") then -- Check if the motion sensors are broken

        fibaro.debug(debug_TAG," Resetting the timer using a motion sensor " ..motion[i] .." " ..fibaro.getName(motion[i]))

        safeTime = 0 -- Reset safeTime to zero

    end

    if fibaro.getValue(Presence, "value") then -- Checking the presence sensor

        fibaro.debug(debug_TAG," Resetting the timer by presence sensor " ..Presence .." " ..fibaro.getName(Presence))

        safeTime = 0 -- Reset safeTime to zero

    end

  end

end

 

for i in pairs(light) do -- count up to maxTime, turn off the light

  fibaro.debug(debug_TAG, '<font color="yellow"> Turn off automatically </font>' ..light[i] .." " ..fibaro.getName(light[i]))

  fibaro.call(light[i],"turnOff")

end

Link to comment
Share on other sites

  • 0

perhaps parts of this is useful.... 

 

To stop the scene whenever there is manual settings done to the lights I have a separate scene looking at if any of the manual available actions have been triggered. In my case it is the S1-switch on a dimmer2 and it has a number of different SCENE ID values. Values are available in the manual of fibaro products. 

 

DECLARATIONS
 

Please login or register to see this code.

 

ACTION:

Please login or register to see this code.

 

Edited by Whswede
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...