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


Recommended Posts

Hello Jan,

Debug true and debug false Im understand

What means null?

Triggers are present but no action.

Please advice

Please login or register to see this image.

/monthly_2019_06/image.png.496b20e2f8c628814147d69e4c2ad9a5.png" alt="image.png.496b20e2f8c628814147d69e4c2ad9a5.png" />

Link to comment
Share on other sites

  • Topic Author
  • 16 hours ago, Sjakie said:

    Hello Jan,

    Debug true and debug false Im understand

    What means null?

    Triggers are present but no action.

    Please advice

    Please login or register to see this link.

    Well, :closed does not exist. It's called :isClose, which I can agree is not the best language...

    :close is the action to close the device, :isClose is the test that returns true/false depending on if it's closed

    Edited by jgab
    Link to comment
    Share on other sites

    Hello Jan,

    This was your advice for curtains open

    Please login or register to see this code.

    Here a rule to close curtains:

     Rule.eval("once(oprit.luxsensor:lux < 100 )=> post(#eveningMsg)")
               Rule.eval("#eveningMsg  => remote(_myNodeRed,#speak{data='de gordijnen worden gesloten'}) ; wait(00:00:10) ; woonkamer.gordijnvoor:value=0 ; wait(00:00:8) ; woonkamer.gordijnoprit:value=0 ; wait(00:00:07) ; woonkamer.gordijnzijkant:close ;  wait(00:00:05) ; eetkamer.gordijnzijkant:close")  

     

    So far so good

    If we close the door let say 30 minutes after the  post(#eveningMsg) >>>>This does not work and why I dont understand.
                   Rule.eval("#eveningMsg & eetkamer.deur:safe => remote(_myNodeRed,#speak{data='het gordijnachter wordt gesloten'}); wait(00:00:15) ; eetkamer.gordijnachter:close")
    As a test I tried this, changed the post msg with a wall plug and the curtain closed!
                     Rule.eval("woonkamer.test:isOn & eetkamer.deur:safe => remote(_myNodeRed,#speak{data='het gordijnachter wordt gesloten'}); wait(00:00:15) ; eetkamer.gordijnachter:close")

    Please advice

    Link to comment
    Share on other sites

  • Topic Author
  • 8 hours ago, Sjakie said:

    Hello Jan,

    This was your advice for curtains open

    Please login or register to see this code.

    Here a rule to close curtains:

     Rule.eval("once(oprit.luxsensor:lux < 100 )=> post(#eveningMsg)")
               Rule.eval("#eveningMsg  => remote(_myNodeRed,#speak{data='de gordijnen worden gesloten'}) ; wait(00:00:10) ; woonkamer.gordijnvoor:value=0 ; wait(00:00:8) ; woonkamer.gordijnoprit:value=0 ; wait(00:00:07) ; woonkamer.gordijnzijkant:close ;  wait(00:00:05) ; eetkamer.gordijnzijkant:close")  

     

    So far so good

    If we close the door let say 30 minutes after the  post(#eveningMsg) >>>>This does not work and why I dont understand.
                   Rule.eval("#eveningMsg & eetkamer.deur:safe => remote(_myNodeRed,#speak{data='het gordijnachter wordt gesloten'}); wait(00:00:15) ; eetkamer.gordijnachter:close")
    As a test I tried this, changed the post msg with a wall plug and the curtain closed!
                     Rule.eval("woonkamer.test:isOn & eetkamer.deur:safe => remote(_myNodeRed,#speak{data='het gordijnachter wordt gesloten'}); wait(00:00:15) ; eetkamer.gordijnachter:close")

    Please advice

     

    Yes, because #events don't have a state.

    When a device (e.g. a lamp) turns on we can continue to test if the lamp is on afterwards, and if the lamp turns off 30min later the test will return false. Like your use of woonkamer.test.

    An #event is sent once to trigger rules, but there is no way to test later if that event was sent.

    In your later example, when would you say that #eveningMsg should not be true anymore? 1 hour after?, 3 hours after?

    Here it's more like you want to set a "time of day" variable, so when it's evening certain rules should trigger, like if eetkamer.deur:safe =>...

    However, you also need to have a rule that tells you when it's not evening.

    Please login or register to see this code.

    There is another way you could achieve this too. You could save the time the eveningMsg was sent and test if it was less then x minutes since it was sent.

    Please login or register to see this code.

    In this example, if eetkamer.deur:safe and it was less than 1 hour since the evening message was sent the rule will trigger. It may work in your case but it's more difficult to estimate when it is not evening anymore.

    Link to comment
    Share on other sites

  • Topic Author
  • One way to do/set a "flexible" TimeOfDay status is the following

    Please login or register to see this code.

    Here we set a variable _TimeOfDay to morning/day(evening/night at specified hours. However, events like a lux meter and a motion sensor can set the variable too and in that way adjust the absolute times.

    If the lux goes below a certain value in the afternoon we consider it being evening. If the motion sensor in the kitchen is triggered in the morning we consider it being morning.

    Because the variable is prefixed with an underscore '_' we can also use that variable to trigger rules, like playing a morning greeting.

    Edited by jgab
    Better handling for restart of scene
    Link to comment
    Share on other sites

    Good morning Jan,

    Thanks for explanation. I used this to be inline with the other trigger.

    I will go for a more simple solution. Most curtains are closed so I will use this as trigger.

    Jan is it possible a that a trigger is mentioned in debug but no execution of that rule?

    I just noticed twice now something like that, I re triggered and the action was done.

    Thanks again

     

    Link to comment
    Share on other sites

    1 minute ago, jgab said:

    One way to do/set a "flexible" TimeOfDay status is the following

    Please login or register to see this code.

    Here we set a variable _TimeOfDay to morning/day(evening/night at specified hours. However, events like a lux meter and a motion sensor can set the variable too and in that way adjust the absolute times.

    If the lux goes below a certain value in the afternoon we consider it being evening. If the motion sensor in the kitchen is triggered in the morning we consider it being morning.

    Because the variable is prefixed with an underscore '_' we can also use that variable to trigger rules, like playing a morning greeting.

    Hi Jan,

    I have a GV for the time of the day.

    What is system wise better to use the GV or what you post above?

    Suppose I use the above than I need also to use remote to inform another scene for usage Time of the day. TimeofDay is used in 2 scenes.

    My goal is to use as little as possible GV,>>> back to 6 and mainly using for VD. I prefer to have something in the ER scene.

    Any way thanks for the advice

    Link to comment
    Share on other sites

  • Topic Author
  • 7 minutes ago, Sjakie said:

    Hi Jan,

    I have a GV for the time of the day.

    What is system wise better to use the GV or what you post above?

    Suppose I use the above than I need also to use remote to inform another scene for usage Time of the day. TimeofDay is used in 2 scenes.

    My goal is to use as little as possible GV,>>> back to 6 and mainly using for VD. I prefer to have something in the ER scene.

    Any way thanks for the advice

     

    If you need to share it between scenes use a GV. replace _TimeOfDay with $TimeOfDay (or whatever you have called the GV)

    Link to comment
    Share on other sites

    Good morning Jan,

     

    This morning it happens again the curtains did not open!Trigger is present. See true Posting morningMsg

    Please login or register to see this image.

    /monthly_2019_06/image.png.63e207bd2c46328ead29f81ebcd24be4.png" />

     

    This is the rule:

        

        --  Rule.eval("@sunrise => post(#morningMsg)")
         Rule.eval("#morningMsg & once(05:00..09:15) =>  remote(_myNodeRed,#speak{data='de gordijnen worden geopend'}); wait(00:00:15); woonkamer.gordijnvoor:open; wait(00:00:08);woonkamer.gordijnzijkant:open; wait(00:00:05);   woonkamer.gordijnoprit:open; wait(00:00:06);  eetkamer.gordijnachter:open; wait(00:00:05);  eetkamer.gordijnzijkant:value=100")         

     

    Because you said "why you need sunrise" its blanked out
    What is going on? Please advice

    Link to comment
    Share on other sites

  • Topic Author
  • 14 minutes ago, Sjakie said:

    Good morning Jan,

     

    This morning it happens again the curtains did not open!Trigger is present. See true Posting morningMsg

    Please login or register to see this link.

     

    This is the rule:

        

        --  Rule.eval("@sunrise => post(#morningMsg)")
         Rule.eval("#morningMsg & once(05:00..09:15) =>  remote(_myNodeRed,#speak{data='de gordijnen worden geopend'}); wait(00:00:15); woonkamer.gordijnvoor:open; wait(00:00:08);woonkamer.gordijnzijkant:open; wait(00:00:05);   woonkamer.gordijnoprit:open; wait(00:00:06);  eetkamer.gordijnachter:open; wait(00:00:05);  eetkamer.gordijnzijkant:value=100")         

     

    Because you said "why you need sunrise" its blanked out
    What is going on? Please advice

     

    You can still have @sunrise .- did I say you should remove it? (I left it out of the previous example to shorten it)

    Anyway, your rule seems perfectly ok to me. I remember you had problem with this rule a week or two ago?

    For this scene can you set  _debugFlags.rule=true (now it's only _debugFlags.ruleTrue=true it seems), because then we would also see if the rule was triggered and if it returned false. And have an eye on the debug output if the curtains don't open.

    Meanwhile, can you post the whole scene to me (PM) and I can have a look at it?

     

    Link to comment
    Share on other sites

    Hi Jan,

    Nope you did not tell me to remove it. With your remark I thought indeed why sunrise? it should work without that is why I removed it.

    In debugflags rule =true done. Yep two weeks ago also no open curtain.

    I doubt but yesterday morning my complex did not disarmed when I activated the trigger. When I activated for the  second time the trigger it did the job.

    Now I am more attend to see what happens. Will pm the scene to you,

    thanks for the support excellence!

    Link to comment
    Share on other sites

  • Topic Author
  • 5 hours ago, Sjakie said:

    Hi Jan,

    Nope you did not tell me to remove it. With your remark I thought indeed why sunrise? it should work without that is why I removed it.

    In debugflags rule =true done. Yep two weeks ago also no open curtain.

    I doubt but yesterday morning my complex did not disarmed when I activated the trigger. When I activated for the  second time the trigger it did the job.

    Now I am more attend to see what happens. Will pm the scene to you,

    thanks for the support excellence!

     

    Thank you, you found a bug! :-)

    There are 2 issues that your rule uncovered. First I had a bug that's been there since April that made rules with intervall tests, <time1>..<time2> behave wrong in some cases. I hoped I fixed that. Pushed a new version B60 of ER.

     

    The other problem is more fundamental and concerns how 'once' behaves. 'once' executes whatever expression it is given and if it's evaluates to true then 'once' return true. However, 'once' will not return true again until the expression has evaluated to false and then true. So 'once' remembers the last value and keeps a state.

    It means that it almost always does the right thing... however, there is an issue with using it with time intervals

     

    Rule.eval("88:isOn & once(08:00..12:00) => log('HUP')")

    The idea here is that the rule should only trigger once if 88 turns on between 8:00 and 12:00. 

    If 88 turns on and then time is ex. 9:00, once(08:00..12:00) will return true. However, if 88 isn't turned on again until 9:00 the next day 08:00..12:00 will be true but 'once' will return false as it requires the expression to turn false before it can turn true again...

    We can fix it in this case by rewriting the rule like this

    Rule.eval("once(88:isOn & 08:00..12:00) => log('HUP')")

    because when 88 turns off it will "re-trigger" the 'once' statement.

    However, this doesn't work with #events.

    Rule.eval("#myEvent &  once(08:00..12:00) => log('HUP')") 

    doesn't work because of explanation above.

    Rule.eval("once(#myEvent & 08:00..12:00) => log('HUP')") 

    doesn't work because there is no "not #myEvent" event sent that can re-trigger the 'once' statement.

     

    The fix here is to re-write it as 

    Rule.eval("once(#myEvent) &  08:00..12:00 => log('HUP')")

    which may seem strange but works because the rules triggers on #myEvent, at 08:00 and at 12:00:01. The latter two time triggers will re-trigger the 'once' statement.

     

    So, @Sjakie, re-writing your rule like this should work.

    Please login or register to see this code.

     

    In any case, this has given me something to think about, and maybe I need to add special support for rules that should only trigger once in a given time intervall because using the 'once' construct is much more tricky than it looks at first glance (I implemented it and I still discover new nuances with it :-) )

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • A quick "enhancement" to the 'once' issue... pushed B62 of ER.

    The problem is that sometimes we want to reset the state that 'once' has remembered so it can start from fresh - see discussion in previous post.

    Please login or register to see this code.

    This will not work unless the light 88 goes off and on again outside the time window so that 'once' is reset.

    Now, 'once' can take an extra argument when in time the 'once' state should be reset.

    Please login or register to see this code.

    This example will reset the 'once' state at every midnight. We could have reset the state at 13:00 (n/13:00) too, it's only important that it's after the time interval.

    The advantage is that this will also work with #event triggers

    Please login or register to see this code.

    I'm not super happy about this fix, but mixing events and states can create complexities and this is an example. I will continue to look for a more intuitive model to solve this.

    Link to comment
    Share on other sites

    Hello Jan,

     

    Rule.eval("#morningMsg & once(05:00..09:15,t/13:00) =>   instead of t/24:00

    Rule.eval("#eveningMsg & once(16:00..23:15,t/24:00) =>

     

    Its not good to hear you are not happy with the fix.

    Perhaps another way to use  GV? I can create GV sunrise / sunset with that time setting . Or  give this also with every change of lux value a trigger?

    Or is still your fix a better system option?

     

    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, Sjakie said:

    Hello Jan,

     

    Rule.eval("#morningMsg & once(05:00..09:15,t/13:00) =>   instead of t/24:00

    Rule.eval("#eveningMsg & once(16:00..23:15,t/24:00) =>

     

    Its not good to hear you are not happy with the fix.

    Perhaps another way to use  GV? I can create GV sunrise / sunset with that time setting . Or  give this also with every change of lux value a trigger?

    Or is still your fix a better system option?

     

     

    No, almost anything is better than GVs :-)

    For now use the fix with extra time argument for 'once'. The only important thing is that the time is after the time interval.

    If you have an interval that spans over midnight, ex. 23:00..02:00, use 'once(23:00..02:00,n/03:00)'

    I'm not happy because it's not very intuitive and that's the goal with eventscript. I'm planning to introduce a new command that hides the complexity but I've not decided on the syntax yet.

    Oh, and you need to specify the time with 'n/' prefix, like n/13:00...

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Hello Jan,

    I am using Sonos in two ways.

    One post http >>>>>>>>>>>sounds great

    Two by SonosPollyTTs , mainly the speak cmd, with different voices >>>>sound bassy

    Why I dont have any clue but I must see how too set it proper.

    You helped me excellent with  remote  (_myNodeRed,#speak{data='de gordijnen worden gesloten'})

    How to start to play music? Sometimes play list must be loaded first

    Please advice,

     

    Link to comment
    Share on other sites

  • Topic Author
  • 33 minutes ago, Sjakie said:

    Hello Jan,

    I am using Sonos in two ways.

    One post http >>>>>>>>>>>sounds great

    Two by SonosPollyTTs , mainly the speak cmd, with different voices >>>>sound bassy

    Why I dont have any clue but I must see how too set it proper.

    You helped me excellent with  remote  (_myNodeRed,#speak{data='de gordijnen worden gesloten'})

    How to start to play music? Sometimes play list must be loaded first

    Please advice,

     

     

    In my node-red flow, that I guess you are using, there are some basic sonos support

    Please login or register to see this code.

    It uses the node-red node "Control Sonos" that need to be configured to point at your sonos player (better-sonos-control)

    It supports some commands like
    • "stop": stop playing 
    • "pause": pause playing 
    • "play": resume play 
    • "playpause": toggle play/pause state 
    • "next": play next track 
    • "previous": play previous track 
    • "mute": mute volume 
    • "unmute": unmute volume 
    • number: 0-100: set volume to N% 
    • "vol_up": increase volume by 5% 
    • "vol_down": decrease volume by 5% 
    • "vol+": increase volume by 5% 
    • "vol-": decrease volume by 5% 
    • +N: increase volume by N% 
    • -N: decrease volume by N% 

    In the same package (better-sonos-control) there is a node to manipulate the Sonos queue but I have not played with that and you would need to make a separate flow handler for that (in the SwitchOnType node)

     

    I guess you can choose the female Dutch voice to get it less bassy? :-)

    Edited by jgab
    Link to comment
    Share on other sites

    Good morning Jan,

    Its the Dutch lady with the bassy voise but also the other voices! If I use Sonos lua script Nl-nl  it will play Google voice???

    Ok Sonos plays and volume set.

    When I try:

     Rule.eval("@6:48 => remote(_myNodeRed,#sonos{cmd='number: 35'})")
      Rule.eval("@6:48 => remote(_myNodeRed,#sonos{cmd='play'})")
      bad property field #48

    Please advice

    Link to comment
    Share on other sites

    11 minutes ago, Sjakie said:

    Good morning Jan,

    Its the Dutch lady with the bassy voise but also the other voices! If I use Sonos lua script Nl-nl  it will play Google voice???

    Ok Sonos plays and volume set.

    When I try:

     Rule.eval("@6:48 => remote(_myNodeRed,#sonos{cmd='number: 35'})")
      Rule.eval("@6:48 => remote(_myNodeRed,#sonos{cmd='play'})")
      bad property field #48

    Please advice

    Your volume command is wrong, see my example below

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Hi Jonny,

    Possible but why this is working?

    Rule.eval(" remote(_myNodeRed,#sonos{cmd='number: 35'})")
      Rule.eval(" remote(_myNodeRed,#sonos{cmd='play'})")

    I have this in my test scene if I save the scene it start to play no error at all?
     

    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
    Reply to this topic...

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