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

do triggers keep triggering?


Question

Hi

sorry for the stupid title, I dont have any better right now :)

 

tl/dr: do a trigger keep rerunning/starting a new instance of a scene?

 

long version:

I want to create a scene where my bathroom fan turns on if humidity sensor is over 70%, then turn off.

If I do this:

 

if 
 ( tonumber(fibaro:getValue(298, "value")) > 70 )
then
    fibaro:call(413, "turnOn");
      fibaro:debug('WC humidity over 70. Turning fan on.');
      fibaro:sleep(120000);
    fibaro:call(413, "turnOff");
     fibaro:debug('WC humidity under 70. Turning fan off.');
end

 

will the HC2 check for the humidity every second or so? and if yes, will it start a new instance of the same scene, or somehow lenghten this?

 

or shall I do this?

if 
 ( tonumber(fibaro:getValue(298, "value")) > 70 )
then
    fibaro:call(413, "turnOn");
      fibaro:debug('WC humidity over 70. Turning fan on.');

else
    fibaro:call(413, "turnOff");
     fibaro:debug('WC humidity under 70. Turning fan off.');
end

 

but in this case, will the fan turn off is the humidity falls under 70?

 

I cannot find a good description of triggers, and it seems so important...

thanks in advance

Link to post
Share on other sites

11 answers to this question

Recommended Posts

  • 0

You want your humidity sensor as the trigger in your header.then everytime the humidity sensors value changes the scene will look at your conditions.

You might want to control triggering by setting the parameters in your humidity sensor to send  update only after humidity has changed by a certian percentage.

 

Also have a differential between off and  on say 10 %

And something to stop multible instances 

Edited by Jamie mccrostie
Link to post
Share on other sites
  • 0

Can I shamelessly promote a topic started by me? It's all about "bathroom fan control".

 

 

Link to post
Share on other sites
  • 0
  • Inquirer
  • Hi @petergebruers  i have spent a couple of hours reading your post about your scene. I was very impressed with it but it’s not really for my needs. First you stated yours is only for one sensor, and while I could use the bathroom sensor to sense the shower too, I’d rather have both. Even more importantly, I live in a much less humid area, but the room has toilet too, so ‘odor removal’ is more important. For this I can only use the motion sensor, which is not something your scene can handle. 

     

    I think my my question is more programmatical. If a trigger is placed in the header, every change starts a new instance of a scene? If one scene turns a light on and waits, the other will later turn it on again. But then the second one will turn it off early, right?

     

    Link to post
    Share on other sites
    • 0
    3 minutes ago, rbhun said:

    i have spent a couple of hours reading your post about your scene. I was very impressed with it but it’s not really for my needs.

     

    Thanks, I am flattered by the fact you spent so much time and liked reading all that...

     

    I understand, it is not for your needs. It's the kind of thing you store in your brain and say "I'll revisit that later".

     

    A small warning: all "motion control" scenes start with simple questions and simple requirements, but end being quite complex. You have already uncovered on of the issues: "multiple instances".

     

    6 minutes ago, rbhun said:

    If a trigger is placed in the header, every change starts a new instance of a scene?

     

    Yes.

     

    6 minutes ago, rbhun said:

    f one scene turns a light on and waits, the other will later turn it on again. But then the second one will turn it off early, right?

     

    Maybe. They run in parallel, so it is hard to say without knowing the exact contents and the exact timing.

     

    I would say... The most commonly used way to solve the issues with parallel execution is... Do not allow a second instance.

     

    Please login or register to see this code.

     

    Now you got rid of the parallelism, but you get a new problem... All triggers after the first are lost. So, scenes usually run a loop to check the state of your devices.

     

    If you look at the scene from my other topic, you'll find:

     

    Please login or register to see this code.

     

    Sometimes it is even easier to write a so called "%% autostart" scene... This special trigger makes the scene run at boot and when you save it. There is some debate, if too many of these cause too much load on your system. I do not have a strong opinion on this.

     

    There is also "%% killOtherInstances" but it is undocumented and Fibaro says "better not to use it".

     

    Does this help?

    Link to post
    Share on other sites
    • 0
  • Inquirer
  • Wow that was educational. Exactly the in depth problem I need :) thanks! I’ll take some time to devour this, right now I’m sitting on a ski lift :) (it’s unbelievable what you find time on a holiday, especially if you bring a laptop because you need to do some paperwork! :D

     

    whats the the point of autostart? Why should I not wait till the first auto trigger?

    Link to post
    Share on other sites
    • 0
  • Inquirer
  • Also, sorry for my questions, but does an IF statement checks only once? If I say

     

    if humidity >70

    then turn on

    else turn off

     

    can I have the same scene check the sensor repeteadly?

    idk something like

     

    if humidity >70

    then

       Turn on

        Goto check again

    else

        Turn off

         Exit loop

     

    then I can just kill all the other processes and keep this one only. 

    Link to post
    Share on other sites
    • 0
    2 hours ago, rbhun said:

    whats the the point of autostart? Why should I not wait till the first auto trigger?

     

    Maybe you want to make a scheduler (at XX:YY do scene x)? So you want to start your scheduler at boot.

     

    Or this. I have a heater connected to a Wall Plug 1st generation. I want it to turn of after 20 minutes. So I can use "value" as a trigger, sleep 20 minutes then turn it off (it is a bit more complicated than that).

     

    But what if you shutdown or reboot your HC when it is timing? So I make it autostart and turn of the plug...

     

    1 hour ago, rbhun said:

    can I have the same scene check the sensor repeteadly?

     

    Lua supports "if", "for", "while" and "repeat", so you make your own loops.

     

    Please login or register to see this link.

    Link to post
    Share on other sites
    • 0

    I have this LUA scene running for 2 bathrooms (controlled by the same fan)

    Very simple, works perfect......

     

    --[[
    %% properties
    695 value
    857 value
    %% weather
    %% events
    %% globals
    --]]

    local vochtvinpeet = fibaro:getValue(695, "value")
    local vochtkids = fibaro:getValue(857, "value")
    local fanspeed = 99
    local zone = fibaro:getGlobalValue("tijdzone")

    fibaro:debug ("vocht badkamer vinpeet is " .. vochtvinpeet)
    fibaro:debug ("vocht badkamer kids is " .. vochtkids)
    fibaro:debug ("Huidige tijdzone is " .. zone)

    if (
     (tonumber(fibaro:getValue(695, "value")) >= 85 and zone ~= "Nacht")
        or
     (tonumber(fibaro:getValue(857, "value")) >= 85 and zone ~= "Nacht")
    )
    then
        fibaro:call(311, 'setValue', fanspeed);
    end

    if (
     ( tonumber(fibaro:getValue(695, "value")) < 85 or zone == "Nacht")
    and
     ( tonumber(fibaro:getValue(857, "value")) < 85 or zone == "Nacht")
    )
    then
        fibaro:call(311, "turnOff");
    end
     

    Link to post
    Share on other sites
    • 0
  • Inquirer
  • hmm. @Vinisz's scene is basically determines if the humidity is over 85, then decides to turn the fan on or not, then immediately shuts itself. Since the sensor report is once in every few minutes, the scene will definietly be finished by the time the new value comes in... and so the new value will decide to stop or not. Sounds very simple. Even too simple - most scenes I see spend a lot of energy to deal with this situation :) but I'll see how it works. The same can be done for motion sensor.

    Link to post
    Share on other sites
    • 0

    It works, there is no need to keep the scene running, why should it ? Triggers are the solution and via parameters in your sensor you can set at what rates or time interval new values will be sent (my humidity sensor is set at 5% here)

    so, the scene will fire every time there is a 5% or more change in the value, and that works perfect !

     

    oh, and by the way, you do not “check” (pull) the sensor, the sensor reports....... (push) that is a different way of thinking....

    Edited by Vinisz
    Link to post
    Share on other sites
    • 0
  • Inquirer
  • okay, so I have this now:

    --[[
    %% properties
    295 value
    298 value
    317 value
    %% weather
    %% events
    %% globals
    --]]

    local startSource = fibaro:getSourceTrigger();
    if (
     ( tonumber(fibaro:getValue(295, "value")) > 0 )  -- wc motion triggered
    or
     ( tonumber(fibaro:getValue(298, "value")) > 70 )  -- wc humidity triggered
    or
     ( tonumber(fibaro:getValue(317, "value")) > 0 )  -- wc smoke triggered
    -- or
    -- startSource["type"] == "other"
    )
    then
        fibaro:call(413, "turnOn");
          fibaro:debug('turning wc fan on');
    else
        fibaro:call(413, "turnOff");
          fibaro:debug('turning wc fan off');
    end


    its not the best, as the debug is pretty stupid - I cannot tell which sensor caused the fan to come on. I can have the debug line list the value of all 3 triggers, I guess, or I can write 4 IFs, 3 for the 3 triggers, and one to turn off if all 3 triggers are off (since ELSE would not work then). That approach may let me have the fan run longer than the motion sensor's alarm time (better for odor removal)

    I tested with motion and it works ok, and will test with humidity (hopefully not smoke :D)

    however, there is one thing. The debug window looks like this:

     

     

    [DEBUG] 09:41:55: turning wc fan off
    [DEBUG] 09:46:55: turning wc fan off
    [DEBUG] 10:21:57: turning wc fan off
    [DEBUG] 10:26:58: turning wc fan off
    [DEBUG] 10:46:09: turning wc fan off
    [DEBUG] 10:47:00: turning wc fan off
    [DEBUG] 10:52:00: turning wc fan off
    [DEBUG] 10:57:00: turning wc fan off
    [DEBUG] 14:32:13: turning wc fan off
    [DEBUG] 17:27:24: turning wc fan off

     

    and so on. Something is causing to the scene to run, but then it finds all 3 triggers off..now it cannot really be the motion or the smoke, because changing those would start the fan, too. And the humidity is set to report at 5% change. But just for safety, I looked in the event panels. There are about 20 debug lines today (all fan off), and there was no report today from either the motion of humidity sensors (as I wasnt home). But I cannot see anything else causing the scene to run...

     

    any ideas?

    is there and 'event panel' for scenes?

    thanks

    Balazs

     

    Link to post
    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...