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

LUA help - triggering scenes


15green

Question

Hi All

 

Following on from posts elsewhere about my issue I am convinced the problem lies with the block/lua conversion. However as a newbie I do not know enough to decipher the flow of the code.

Primarily I need to understand how this scene is triggered when %%autostart is not used. I get that a manual start will set things going by the first 4 lines but how does the scene trigger otherwise?

If someone could add some comments to the offending code below for me it would be most useful!

 

--[[
%% properties
172 value
%% weather
%% events
%% globals
--]]

local startSource = fibaro:getSourceTrigger();
if(startSource["type"] == "other") then
 fibaro:call(64, "turnOff");
 fibaro:call(66, "turnOff");
else
if (( tonumber(fibaro:getValue(172, "value")) == 0 )) then
setTimeout(function()
local delayedCheck0 = false;
local tempDeviceState0, deviceLastModification0 = fibaro:get(172, "value");
if (( tonumber(fibaro:getValue(172, "value")) == 0 ) and (os.time() - deviceLastModification0) >= 200) then
 delayedCheck0 = true;
end

local startSource = fibaro:getSourceTrigger();
if (
 ( delayedCheck0 == true )
or
startSource["type"] == "other"
)
then
 fibaro:call(64, "turnOff");
 fibaro:call(66, "turnOff");
end
end, 200000)
end
end

   

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 1

yes the scene as it is will start at any change of the value of the motion sensor ID 172. When it is breached (0) or when it is safe (1).  You have to check also how many instances of this scene are set in the main scene window. I think you need to have 4 or more at the maximum running instances as the scene will start a different instance every time the sensor changes state to safe.  

 

Please mind that the scope is to limit the number of running instances of any scene, as the more there are , the bigger impact will be on the system, resulting even in delays or partial freezes if more scenes like this are run at the same time.

Link to comment
Share on other sites

  • 0

It triggers whenever the device with ID 172 changes the value parameter.  I guess that is a motion sensor and the scene checks for the motion sensor to be safe for more than 200 seconds then turns some switches off.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Correct @Momos  the motion sensor should turn the lights off, but it does not work.  Am I to understand the HC2 is constantly looking for the state of sensor 172  via this scene?

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thanks @Momos for the info. It is helping me understand the code and I will check it out the insyances.  

    Could you enlighten me regard the timings? If 200000 is the timeout, i.e. the 200 seconds time during which the "off" timer will be reset. What is the mumber 200 used for after deviceLastModification?   Thanks in advance.

    Link to comment
    Share on other sites

    • 0

    the 200 from deviceLastModification is seconds. The 200000 is 200 seconds (200*1000). So you have a timeout of 200 seconds and a check for 200 seconds also.

    Link to comment
    Share on other sites

    • 0

    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.

    ".

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Ok @Momos I am getting it slowly!  

    I have increased the instances and things seem to be working better, however I am little confused as if a new instance is triggered every time the sensor sees motion surely over a period of say an hour there could be hundreds of such changes of state, and in which case how I limit these?

     

    Thanks again.

    Edited by 15green
    typo
    Link to comment
    Share on other sites

    • 0

    well i have a different approach to such scenes. I have one scene for all the lights and that scene runs on a loop every 10 mins.

     

    for you it would be something like:

     

    Please login or register to see this code.

    This way i make sure there is only one instance of the scene running and it takes care of all the lights. Granted the lights can be switched off anywhere between 200 and 400 seconds in this case. Try it see how it is.

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