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

Little help on a scene (turning on garage lights when the garage door opens)


Question

Posted (edited)

Hey Guys,

I've got a scene that turns my garage lights on when the garage door opens although i want to do a check that in the event the lights are already on to not turn them off after two minutes.

Below is the code i've got so far but i think there's an issue with the IF statements and need someones keen eye to quickly find where my fault is. I believe i havent correctly closed of the second if statement.

Its currently turning the lights on all the time instead of only at night

 

--[[
%% properties
99 state
9 value
%% weather
%% events
%% globals
--]]
if
(fibaro:getValue(99, "state")== "Open" and  tonumber(fibaro:getGlobalValue("NightTimev2")) == tonumber("1") )
then
    if (
 ( tonumber(fibaro:getValue(9, "value")) > 0 ))
    then
end
    else
    fibaro:call(9, "turnOn");
      fibaro:sleep(120000)
      fibaro:call(9, "turnOff")
end

Edited by I.Srodka

4 answers to this question

Recommended Posts

  • 0
Posted

The topic has been moved from "

Please login or register to see this link.

" to "

Please login or register to see this link.

".

 

Temat został przeniesiony z "

Please login or register to see this link.

" do "

Please login or register to see this link.

".

  • 0
Posted

I use my VSL scene with door sensor, motion sensor and light sensor to control lights in garage. If garage or side door is opened light turns on if there is no enough light in garage measured by lights sensors. Lights stay turned on as long as any of the door stay opened or motion is detected, but will switch off or not turn on when there is enough light in garage.

 

I have working table in one corner of the garage with table light. If I enter garage and close doors and I sit by the table light will turn off after some time because also motion sensor is not seeing me. But scene is checking consumption from wall plug and if it is grater than 10W (at least table light turned on) then it keeps lights turned on until I finish with my job and turn table light and soldering iron off.

 

With this solution I don't need to use wall switch for garage lights. I use it sometimes only to turn light off if I want to leave side door opened but don't need light.

Current version of VSL scene checks only if any of the lights is manually turned off so it then turns all lights off before timer reaches 0

 

New version of VSL scene that I didn't publish yet does have light checking if turned on manually, but must be turned on before motion is detected or door opened and then scene can either keep lights on until it is turned off manually, or can extend timer for user definable time.

 

  • 0
Posted
On 8/15/2017 at 1:11 AM, amurray85 said:

Hey Guys,

I've got a scene that turns my garage lights on when the garage door opens although i want to do a check that in the event the lights are already on to not turn them off after two minutes.

Below is the code i've got so far but i think there's an issue with the IF statements and need someones keen eye to quickly find where my fault is. I believe i havent correctly closed of the second if statement.

Its currently turning the lights on all the time instead of only at night

 

--[[
%% properties
99 state
9 value
%% weather
%% events
%% globals
--]]
if
(fibaro:getValue(99, "state")== "Open" and  tonumber(fibaro:getGlobalValue("NightTimev2")) == tonumber("1") )
then
    if (
 ( tonumber(fibaro:getValue(9, "value")) > 0 ))
    then
end
    else
    fibaro:call(9, "turnOn");
      fibaro:sleep(120000)
      fibaro:call(9, "turnOff")
end

 

 

If you look closer to your code it looks like this...

 

--[[
%% properties
99 state
9 value
%% weather
%% events
%% globals
--]]
if (fibaro:getValue(99, "state")== "Open" and tonumber(fibaro:getGlobalValue("NightTimev2")) == tonumber("1") ) then
        if (( tonumber(fibaro:getValue(9, "value")) > 0 )) then  
       end
else
      fibaro:call(9, "turnOn");
      fibaro:sleep(120000)
     fibaro:call(9, "turnOff")
end

 

Your inner if statement does not execute anything if value is greater than 0.  I suggest you close the if statements in a proper way when coding. Then it is easier to see this. Use MS Vscode for example (free) with Lua plugins to help see errors and visualise the code better.

 

And instead of turn a string into a number in the comparison, you could write the number directly.

== tonumber("1") 

change to...

== 1

 

But maybe you have already solved your problem...

 

/Peo

  • 0
Posted

It's a duplicate of

 

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