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


  • 4

HC3 no motion for X time = lights off, how to?


Pete123

Question

Hi,

 

How do you configure a scene that will turn on lights when motion and does not turn off until motion sensor has been safe for X time?

I am looking for both Lua and block options, if available.

Until now I have only found option for "delay" meaning lights will turn off after given time no matter if there has been motion during "delay" period.

 

Hope someone has found a solution for this.

Link to comment
Share on other sites

Recommended Posts

  • 0

Please login or register to see this image.

/monthly_2021_07/image.png.3408a90eb58864da5387a0125e976930.png" />

 

 

@jgab, your Portuguese is perfect :-) 

 

 

 

  • Like 1
Link to comment
Share on other sites

  • 0
20 minutes ago, SmartHomeEddy said:

@jgab, your Portuguese is perfect :-) 

Yeah, isn't it? :-)

If I translate the Portuguese to Swedish and back to English with Google translate it doesn't sound as impressive.... or maybe it does :-)

Please login or register to see this code.

 

  • Like 2
Link to comment
Share on other sites

  • 0
On 05/07/2021 at 08:10, jgab said:

Nada, pois todos os sensores binários retornam verdadeiro quando aberto / violado e falso se fechado / seguro

jgab@, how are you?
please one more help......if I have Dimmer and RGB along with modules On/Off what do I need to change in Scene? I just tried to include the Ids but the Scene doesn't read the original status.....Dimmers and RGBs always turn off....even if they're lit at the start of the Scene.

thanks,

Link to comment
Share on other sites

  • 0

So it is the isON() test that fails?

Dimmers and RGBs don't return true/false for their value, they return a number 0..99. 0 when off, and >0 when on.

We can allow for that if we modify isON()

Please login or register to see this code.

I think it should be possible to use the 'state' property too, but I'm a bit unsure how consistently it is supported/used.

Link to comment
Share on other sites

  • 0
18 hours ago, jgab said:

So it is the isON() test that fails?

Dimmers and RGBs don't return true/false for their value, they return a number 0..99. 0 when off, and >0 when on.

We can allow for that if we modify isON()

Please login or register to see this code.

I think it should be possible to use the 'state' property too, but I'm a bit unsure how consistently it is supported/used.

jgab@, thank you.....perfect!

Link to comment
Share on other sites

  • 0
On 05/07/2021 at 08:55, jgab said:

Sim, não é? :-)

Se eu traduzir o português para o sueco e de volta para o inglês com o Google Translate, não soará tão impressionante ... ou talvez pareça :-)

Please login or register to see this code.

 

@jgab how are you?
one more guidance / help please ....
when condition (3) of the scene is met, I would like the scene to check the time (hour range) and based on that, turn on the RGB in a specific color ...... I tried to use
local time = os.date ("%H:%M")
if time> = "17:00" or time <="20:30"
then
but it didn't work, I looked in the Lua HC3 manual, but I couldn't find examples.... Could you guide me once again how this encoding works on the HC3.
thank you so much.
 

part of the code

 

local time = os.date("%H:%M")


if isON(light1) and isON(light2) and isONx(light3) then 
light = {35}                                          
print("conditions 1")                           

 

elseif isON(light1) and isON(light2) then             
light = {35,25}                                       
print("conditions 2")                                            

 

elseif isON(light1) and isONx(light3) then       
light = {35,259}                                               -- TurnOn ID 35 and RGBW
print("conditions 3") 

--------------------------------------------------
if time >= "17:00" or time <= "20:30" then
fibaro.call(259, "setColor", "0","255","0","0") -- R,G,B,W
print ("Pool Color Green")


elseif time >= "20:31" or time <= "22:00" then
fibaro.call(259, "setColor", "0","255","255","255") -- R,G,B,W
print("Pool Color white")


else
fibaro.call(259, 'setColor', "8","0","165","0") -- R,G,B,W
print ("Pool Color Blue")
end

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

  
elseif isON(light2) and isONx(light3) then              
light = {35,46}                                          
print ("conditions 4")

 

elseif isON(light1) then                                
light = {35,25,259}                                      
print("conditions 5")   

 

elseif isON(light2) then                                
light = {35,46,25}                                    
print("conditions 6")                                           

 

elseif isONx(light3) then                               
light = {35,46,259}                                   
print("conditions 7")                                           
end

  • Like 1
Link to comment
Share on other sites

  • 0

You should use 'and' instead of 'or'

if time >= "17:00" and time <= "20:30" then

Link to comment
Share on other sites

  • 0
19 hours ago, jgab said:

You should use 'and' instead of 'or'

if time >= "17:00" and time <= "20:30" then

jgab@,

thanks again for the help .....gratitude.

Att.

Jorge

Link to comment
Share on other sites

  • 0
Guest Benrive

Hello,
I have just implemented all this, it works perfectly for me .
In my case all the lights are dimmable.
Would it be possible to implement that when the lights are turned on at the same time the brightness level is adjusted depending on the amount of lux there is at that moment?

Link to comment
Share on other sites

  • 0
Guest Benrive

Hello,

Something very strange happens to me.

 

For testing purposes, I have changed the virtual lights to multilevel virtual light. ( I have dimmer )
But now something very curious happens, only the first one is turned on and off.


Of course, I have changed the ID of the new virtual multilevel lights in the script.
What can be?

 

Updated: 21/08/11

 

Work's Ok:

Witch Virtual Switch binary

 

local light = {61,62,63-- ID's of all the lights to turnOn and turnOff
local function isON(light) return fibaro.getValue(light,"value"end
 

Testing, because I don't understand what happens.

I have noticed in the Debug that if I use Binary Switches it works and even looks like the function

 

When I use virtual devices multilevel , the same function is just looping only to first ID.

 

local light = {55,59,60-- ID's of all the lights to turnOn and turnOff
local function isON(light) return fibaro.getValue(light,"value"end
 
It's very strange.
 
Thx a lot
Edited by Benrive
Link to comment
Share on other sites

  • 0

I need some quick help?

 

How can i modify this scene to :

End the scene,  if light (ID 481) is turned off by a person on a switch or by app ? This way turning off the light doesnt stop the scene and it keeps counting thil the end..

 

DECLARATIONS (Conditions/Triggers)

{
  conditions = { {
      id = 481,
      isTrigger = true,
      operator = "==",
      property = "value",
      type = "device",
      value = true
    } },
  operator = "all"
}

 

ACTIONS

 
local light = {201} 
local motion = {481} 
local maxTime = 2*60  
local sleepTime = 5 
local debug_TAG = "IZKLOP WC LUČI PO 3 min" 
 
 

 for i in pairs(light) do 
  fibaro.debug(debug_TAG,"vklapljam luci (ID " ..light[i] ..") " ..fibaro.getName(light[i]) .." za " ..maxTime .." sekund")
  fibaro.call(light[i],"turnOn")
end
 
local safeTime = 0
while safeTime < maxTime do 
  fibaro.sleep(sleepTime*1000)                 
  safeTime=safeTime+sleepTime 
  fibaro.debug(debug_TAG,"  Štetje do maksimalnega časa  ki znaša ... " ..safeTime .." maksimalni čas znaša ... " ..maxTime)
  for i in pairs(motion) do 
    if fibaro.getValue(motion[i],"value") then 
       fibaro.debug(debug_TAG,"Reset na podlagi senzorja gibanja  št.... " ..motion[i] .." " ..fibaro.getName(motion[i]))
       safeTime = 0 
    end
  end
end 
  
for i in pairs(light) do 
  fibaro.debug(debug_TAG, "Ugašanje luči " ..light[i] .." " ..fibaro.getName(light[i]))
  fibaro.call(light[i],"turnOff") 
end
 

Link to comment
Share on other sites

  • 0

Please login or register to see this code.

 

This is just for 1 light - if you have several lights in the lua table 'light' the code needs to be modified.

Link to comment
Share on other sites

  • 0

Thanks a lot for your help.

 

 

I do have another scene i would like to do the same. With multiple LED Strips (ID 324, ID 325) and one klassic non dimmable LED light (ID 74). How do i have to change the code this time?

 

 

DECLARATIONS (Conditions/Triggers)

{
  conditions = { {
      id = 516,
      isTrigger = true,
      operator = "==",
      property = "value",
      type = "device",
      value = true
    }, {
      id = 74,
      isTrigger = false,
      operator = "==",
      property = "state",
      type = "device",
      value = false
    }, {
      isTrigger = false,
      operator = "==",
      property = "SLEEP_MODE",
      type = "global-variable",
      value = "OFF"
    }, {
      conditions = { {
          isTrigger = false,
          operator = "==",
          property = "Dan_Noc",
          type = "global-variable",
          value = "NOC"
        }, {
          id = 518,
          isTrigger = false,
          operator = "<",
          property = "value",
          type = "device",
          value = 25
        } },
      operator = "any"
    } },
  operator = "all"
}

 

ACTIONS


 

local light = {324,325} 
local motion = {516} 
local maxTime = 1*60  
local sleepTime = 5 
local debug_TAG = " kuhinja ON/OFF SENZOR " -- oznaka scene
 

 

 for i in pairs(light) do -- vklop vseh luči 
  fibaro.debug(debug_TAG,"Vklapljam (ID " ..light[i] ..") " ..fibaro.getName(light[i]) .." za čas   " ..maxTime .." sekund") -- debug vklopa luči
  fibaro.call(324,"setValue",30) 
  fibaro.call(325,"setValue",15) 
  end

local safeTime = 0
while safeTime < maxTime do 
  fibaro.sleep(sleepTime*1000)                 
  safeTime=safeTime+sleepTime 
  if fibaro.getValue(74, "value") 
    then
    break
end
  fibaro.debug(debug_TAG," Štetje do maksimalnega časa ki znaša ...  " ..safeTime .." maksimalni čas znaša ..." ..maxTime)
  
  for i in pairs(motion) do 
    if fibaro.getValue(motion[i],"value") then -- preveri če se je sprožil senzor gibanja
       fibaro.debug(debug_TAG,"  Reset na podlagi senzorja gibanja  št.  " ..motion[i] .." " ..fibaro.getName(motion[i]))
       safeTime = 0 -- resetira čas na 0 če zazna gibanje
    end
  end
end 

if fibaro.getValue(74, "value") 

then 

  fibaro.debug(debug_TAG, "Ker je zaznan prižig druge luči se luč ne ugasne")

else

  for i in pairs(light) do -- Štetje do maksimalnega časa nato izklop luči

    fibaro.debug(debug_TAG, " Turning off  " ..light[i] .." " ..fibaro.getName(light[i]))

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

  end
end

Link to comment
Share on other sites

  • 0

Doesn’t there exist an ALC LUA like the of @Sankotronic for the HC3?

 

I have 2 lights with Fibaro Plug, 2 HUE lamps and 2 motion sensors. I want the "normal" lights to become on by motion and stay on for 10m and restart counting after motion. This works perfect with the script of @SmartHomeEddy

But at sunset the HUE lights should also become active with a certain color and using the same motion script as above. 

 

Can this be done?

 

 

Edited by Sjekke
Link to comment
Share on other sites

  • 0
On 2/16/2020 at 1:22 PM, jgab said:

 

This was a half-joke but it actually works. If you set "Allow to restart a running scene" to 'no' (similar to "if fibaro:countScenes() > 1 then fibaro:abort() end") 

you can code like this (almost like in the old days).

Please login or register to see this code.

In practice the fibaro.sleep loop should be changed to a setTimeout loop to adopt the new coding style imposed, because sleep is a bit heavy on the system...  - but that's left as an exercise to the reader.

The condition sections to trigger on motion sensor with id 32 being breached should be:

Please login or register to see this code.

 

Hi everyone. I'm a baby user OF HC3 and I'm interested in this issue to do as well.

But when I copied and pasted this code in my HC3 and try to make it run. I have this error :

 

[16.06.2022] [16:44:25] [ERROR] [SCENE32]: (load):19: attempt to compare number with boolean

 

Line 19 is this one

Please login or register to see this code.

 

Could you please gimme help ?

 

Thank you.

Link to comment
Share on other sites

  • 0

Hello @YannickKARCHER

 

Try

 

if fibaro.getValue(motion,"value") then

 

end

 

Because I think the motion Sensor gives only "true" or "false"

Link to comment
Share on other sites

  • 0

I use this ...

 

2 sensors, 2 lights. Lux I don't use yet

 

DECLARATIONS

{
  conditions = { {
      id = 78,
      isTrigger = true,
      operator = "==",
      property = "value",
      type = "device",
      value = true
    }, {
      id = 263,
      isTrigger = true,
      operator = "==",
      property = "value",
      type = "device",
      value = true
    } },
  operator = "any"
}

 

Actions

-- This scene turns on one or more lights: 
--    when Lux level is below a certain level (see DECLARATIONS) and 
--    shows the Lux level of one ore more Lux sensors and 
--    turns off the lights after a certain time (maxTime), 
--    unless there is motion from one or more Motion sensors
 
-- Please enter the right ID's (if more than one, seperate by ",") and the prefered maxTime for the lights to stay on 
 
local light = {26, 62} -- ID's of the lights to turn on
local motion = {78, 263} -- ID's of the Motion sensors to check if they are breached
local lux = {80, 265} -- ID's of the Lux sensors to (only) show the lux level
local maxTime = 1*600 -- Maximum time the sensor should be safe before turning off (n*60 where n is minutes)
local sleepTime = 5 -- Time in seconds between each check of the Motion sensor (default = 5)
local debug_TAG = "Woonkamer licht" -- Tag for the debug messages
 
-- Below here no changes are necessary
 
for i in pairs(light) do -- Turn on the lights
  fibaro.debug(debug_TAG,"Turning on (ID " ..light[i] ..") " ..fibaro.getName(light[i]) .." for " ..maxTime .." seconds")
  fibaro.call(light[i],"turnOn")
end
 
for i in pairs(lux) do -- Show the lux level of the Lux sensors
  fibaro.debug(debug_TAG,"Current Lux level " ..lux[i] .." " ..fibaro.getName(lux[i]) ..": " ..fibaro.getValue(lux[i],"value"))
end
 
local safeTime = 0
while safeTime < maxTime do -- Loop until maxTime is reached
  fibaro.sleep(sleepTime*1000)                 
  safeTime=safeTime+sleepTime 
  fibaro.debug(debug_TAG,"Counting up safeTime " ..safeTime .." to maxTime " ..maxTime)
  for i in pairs(motion) do 
    if fibaro.getValue(motion[i],"value") then -- Check if Motion sensors are breached
       fibaro.debug(debug_TAG,"Reset by Motion sensor " ..motion[i] .." " ..fibaro.getName(motion[i]))
       safeTime = 0 -- Reset safeTime to zero
    end
  end
end 
  
for i in pairs(light) do -- Counted down to maxTime, turn off the lights
  fibaro.debug(debug_TAG, "Turning off " ..light[i] .." " ..fibaro.getName(light[i]))
  fibaro.call(light[i],"turnOff") 
end
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...