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

Dimmer scene issue


Question

Posted

Hi all,

 

I have an issue with a script I am making.

 

What I want to do:

I have hallway lights which I want to be full on during the day if I click on one of the dimmers. But at night time I want them to automatically go to a dimmed mode.

 

Issue

I made a script which I think is almost there. It activates on whether de device is triggered. However, if I change the state of the dimmer, it retriggers the scene..

 

I thought of using fibaro:getSourcetrigger but that doesn't work as it can see whether it was triggered by pressing the dimmer or if it was triggered by a scene. Anybody an idea on how to solve this?

 

The Script

Please login or register to see this code.

2 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 (edited)

This works for me.  ;-)  

 

 

--[[ 
%% properties 
38 value
51 value
%% globals 
--]]

 

------------------ Do not start a double scene ----------------------------------
if (fibaro:countScenes()>1) then fibaro:abort(); end

 

function debug(color, message)
    fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); 
end

 

-------------------- VARIABLES ---------------------------------------------------
local scene = 66 -- ID this scene
local motion = 38 -- ID for PIR
local switch = 51 -- ID for switch
local starttimer = 50; -- time in seconds for the light to be turned on
local timer = (starttimer); -- timer
local currenttime = os.date('*t'); -- What time is it?
local currenthour = currenttime['hour']; -- Convert time to integer number

 

----------------- Lights ON/OFF --------------------------------------------------
if (tonumber(fibaro:getValue(motion, "value")) > 0 ) and (tonumber(fibaro:getValue(switch, "value")) < 1) then -- Movement?

-- Late night - then 20% light    
      if (currenthour >= 22 ) then
          fibaro:call(switch, "setValue", "20"); 
        debug("grey", "20%");
-- Evening then 40% light    
      elseif (currenthour >= 18) then
           fibaro:call(switch, "setValue", "40");
        debug("grey", "40%");
-- Late afternoon then 60%  light   
      elseif (currenthour >= 16) then
           fibaro:call(switch, "setValue", "60");
        debug("grey", "60%");
-- Daytime then 80% light
    elseif (currenthour >= 6) then
           fibaro:call(switch, "setValue", "80");
        debug("grey", "80%");
  -- After midnight then 3% light
      else
          fibaro:call(switch, "setValue", "3");
        debug("grey", "3%");
      end     
end

debug("green", "Light On");
  
---------------------- Loop starts -----------------------------------------------
 repeat 
 timer=timer-1; 
 fibaro:sleep(1000);
    
-- If movement then reset time
     if (tonumber(fibaro:getValue(motion, "value"))) > 0 then 
         timer=starttimer; 
         debug("grey", "Movement - time start again");
     end 
 
-- Turn off it switch is used manually
    if (tonumber(fibaro:getValue(switch, "value"))) < 1 then 
        debug("red", "Switch used - Lights Off");
        timer=0
    end 
 until (timer<1) 

 

--------------- Times up. Light Off -----------------------------------------------
fibaro:call(switch, "turnOff");
debug("red", "Light Off");

Edited by Thomasn

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