• Professional advice
  • Order before 16.30 uur shipped today
  • Always reachable (+31 73 762 0 762)
  • Monday open late

Smarthome Lightning 2

LUA example for automatic toiletlights 

The smallest room in the house is also often the darkest. With this smarthome mini project you can automate the light in the smallest room in the house. When you enter the toilet the light will go on and when you leave it will automaticly turn off. If you want you can activate the ventilator. 

What do we need:

- A Z-wave gateway (in this case a Home Center 2)
- A FIBARO door and window sensor (in 7 kleuren beschikbaar)
- A FIBARO dim- of switch module to control the light
- A script to turn on and off the lights.

What does the script exactly?
When the doorsensor detects open (or close) the script is executed. When the door is opened (and the light is off) we write the actual time in Linux format to a variable called  'ToiletGeopend'. When the door is closed we check if the passed time is more than 20 seconds since the door was opened. When the time has passed we turn of the lights.

ID 8 the ID of the doorsensor
ID 45 is the ID of the FIBARO dimmer (or switch)
Create the following variables in the variable panel.
- ToiletGeopend
- TijdToiletOpen

The script

--[[
%% properties
8 value                  
%% globals
--]]

IDlamp =45      -- ID of toiletlight
local ToiletGeopend =tonumber(fibaro:getModificationTime(IDlamp, "value"));
local TijdToiletOpen = tonumber( os.time() ) - tonumber(fibaro:getModificationTime(IDlamp, "value"));
local StatusDeur =fibaro:getValue(8, "value")
local LampAan =fibaro:getValue(IDlamp, "value")
fibaro:debug(TijdToiletOpen)
if ( tonumber(StatusDeur) == 1 ) then
    if ( tonumber(LampAan) == 0 ) then 
         fibaro:call(IDlamp, "setValue", "50");
         fibaro:setGlobal("ToiletGeopend", tonumber(os.time() )); --write actual time to variable
         fibaro:sleep(2*1000)
         fibaro:call(IDlamp, "setValue", "50")  -- in this case we use a dimmer and its set to 50%
     end 
elseif ( tonumber(StatusDeur) == 0 ) then              --door is being close
    if ( tonumber(TijdToiletOpen) > 20 ) then            --Turn of light when more than 20 seconds are passed
       fibaro:call(IDlamp, "setValue", "00"); 
    end
end
-- End of the toilet light script

 

 

8 Result(s)

Why ROBBshop?

  • 14 day return policy
  • Reach us 24/7
  • Ordered before 16:30 shipped today
  • Over 1000 positive reviews
  • Standard 2 year warranty
  • Call us at +31737620762
8 Result(s)
 
Customer Service Phone

+31737620762
mon-fri: 10am-5pm and sat 10am-3pm

 
Adress

Gerstakker 16 5236 VG Empel Netherlands

Google maps