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

Jan, Is it possible in ER 3 HC2 to send a push message?

If yes please can you give me an example?

//Sjakie

 

Please login or register to see this attachment.

sorry for picture I deleted it but its still here

 

Link to comment
Share on other sites

  • Topic Author
  • 1 hour ago, Sjakie said:

    Jan, Is it possible in ER 3 HC2 to send a push message?

    If yes please can you give me an example?

    //Sjakie

     

    Please login or register to see this attachment.

    sorry for picture I deleted it but its still here

     

    push is just :msg=...

    or do you mean interactive push +

    Link to comment
    Share on other sites

    9 minutes ago, jgab said:

    push is just :msg=...

    or do you mean interactive push +

    Yes inter active push please, now I have it inFibaro push.

    //Sjakie

    Link to comment
    Share on other sites

    Jan,

    If I arm the house I use to get the information needed:

    msg,Telegram or inter active push.

    Fa frontDoor:armed==true => 

    ER execute this rule 3 times

    How to avoid to get the message also 3 times? Or this ist possible?

    Please advice,

    //Sjakie 

    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, Sjakie said:

    Jan,

    If I arm the house I use to get the information needed:

    msg,Telegram or inter active push.

    Fa frontDoor:armed==true => 

    ER execute this rule 3 times

    How to avoid to get the message also 3 times? Or this ist possible?

    Please advice,

    //Sjakie 

    Sorry, need more information. Is it ER3 or ER4? ER4 are you using the alarm rules I posted earlier?

    Link to comment
    Share on other sites

    Jan,

    HC3 is paused wits for a new Children of HUe?

    Sorry this is ER 3 HC2.

    All the messages I reviewed and if necessary I want to add also Interactive push.

    I am still using your alarm rules but removed all seperate Telegram messages>>this solved the Telegram error I had.

    I see in debug rule <true>  Rule.eval([[eetKamer.deur:armed==true & badKamer.dakRaam:armed==true & kamerBoven.deur:armed==true & kamerBeneden.voorDeur:armed==true =>
            fibaro:call(210, "sendDefinedPushNotification", "259");
            fibaro:call(455, "sendDefinedPushNotification", "259");
            Telegram.msg(TID,'Beveiliging actief - Aanwezig, Dakraam, KamerBeneden en KamerBoven');
            log('259 - Beveiliging actief - Aanwezig, Dakraam, KamerBeneden en KamerBoven')
                   ]])

    3 times 

    On that way I recieve also 3 messages.

    //Sjaak

    Link to comment
    Share on other sites

    • 2 weeks later...
    I've got two questions:
    1. Why this rule is "ok" but doesn't work? It start to wok when I leave only one month range ex. oct-dec .

    rule("once(oknazuzia:isOff & (outsideTemp < 12) & month ('jan-apr' | 'oct-dec') )=> ZuziaOgrzAutoOn:start")
     
    2. Is it possible to use seconds instead minutes?
    Link to comment
    Share on other sites

  • Topic Author
  • 8 minutes ago, michal85pl said:
    I've got two questions:
    1. Why this rule is "ok" but doesn't work? It start to wok when I leave only one month range ex. oct-dec .

    rule("once(oknazuzia:isOff & (outsideTemp < 12) & month ('jan-apr' | 'oct-dec') )=> ZuziaOgrzAutoOn:start")
     
    2. Is it possible to use seconds instead minutes?

     

    I think you want to write the first rule like this

    Please login or register to see this code.

     

    So if oknazuzia is. off and outsideTemp goes under 12 then

        If its jan-apr or oct-dec

        then start ZuziaOgrzAutoOn

     

    Note that the temp needs to go above or equal to 12 before the rule can trigger again (the 'once')

     

    The month('jan-apr,oct-dec') can also be written (month('jan-apr') | month('oct-dec'))

     

    Yes minutes can be specified

    rule("@12:00:10 => log('10s after 12')")

    rule("@@00:00:10 => log('Log every 10s')")

    • Thanks 1
    Link to comment
    Share on other sites

    23 minuty temu, jgab napisał:

     

    I think you want to write the first rule like this

    Please login or register to see this code.

     

    So if oknazuzia is. off and outsideTemp goes under 12 then

        If its jan-apr or oct-dec

        then start ZuziaOgrzAutoOn

     

    Note that the temp needs to go above or equal to 12 before the rule can trigger again (the 'once')

     

    The month('jan-apr,oct-dec') can also be written (month('jan-apr') | month('oct-dec'))

     

    Yes minutes can be specified

    rule("@12:00:10 => log('10s after 12')")

    rule("@@00:00:10 => log('Log every 10s')")

    Thank You

    Link to comment
    Share on other sites

    On 9/25/2020 at 12:27 PM, jgab said:

    Example of alarm handling on the HC3 and ER4

    Please login or register to see this code.

    Of course these events could be used to start other rules like simulating presence, turning off stuff etc.

    The cool thing here is that we get a notification when the user turns on the alarm and we have the "delay time" to check if partition is safe. If not we abort the arming.

    One could also setup a rule that watches if something is breached during the arm delay timespan and also cancel the arming.

    Could you use a Logic Group Matrix as KeyPad of ARM/DisARM the alarm - like a trippleklik on one button and a double klik on another? Perhaps a trippleklik is enough, who would know "this is the way" 

    Link to comment
    Share on other sites

  • Topic Author
  • You can combine clicks from the Matrix. Here we concatenate keyId and KeyAttributes from 2 keys clicked within 2s.

     

    Please login or register to see this code.

     

    • Like 1
    Link to comment
    Share on other sites

    On 11/11/2020 at 3:25 PM, jgab said:

    You can combine clicks from the Matrix. Here we concatenate keyId and KeyAttributes from 2 keys clicked within 2s.

     

    Please login or register to see this code.

     

    I´m trying to understand everything in this Rule

     

    matrix1 = 77 -- DeviceID of matrix device - This is Clear

    • The [[ ]] is for indicating more that one expression is being evaluated ?
    • central is CentralSceneEvent
    • keyPrim - is a Key Pressed 

    So :central & keyPrim = Event from CentralScene and there is a Key Pressed ?

     

    So what is this?

     post({type=fmt('%s_%s_%s',keyPrim,matrix1:central.keyId,matrix1:central.keyAttribute)}); 

    -- Post a LIST  - Save the LIST for later use ??

    -- type=fmt -- not sure -- is this the Formating of the LIST

    -- matrix1:central -- Read CentralSceneEvent

    -- central.keyId -- What Key 

    -- matrix1:central.keyAttribute -- Is pressed

         keyPrim=nil -- is Empty keyPrim variable

     

    rule([[matrix1:central & keyPrim =>
         post({type=fmt('%s_%s_%s',keyPrim,matrix1:central.keyId,matrix1:central.keyAttribute)}); 
         keyPrim=nil
    ]])

     

    So now we again detect CentralSceneEvent and key pressed - and keyPrim should be empty (nil)?

    So this part has a 2 sec wait - before deleting keyPrim. When keyPrim is empty 3 rule wont trigger.

     

     

    rule([[matrix1:central & keyPrim==nil =>
        keyPrim=fmt('Key%s_%s_%s',matrix1,matrix1:central.keyId,matrix1:central.keyAttribute); 
        wait(2);  ---- 
        keyPrim=nil
    ]])

     

    # - this is a new trigger created, based on the former rules.

    This rule triggers when both rules are triggered?

     

    rule("#Key77_2_Pressed3_4_Pressed2 => post(#disArm)") -- Matrix iD 77, key 2 3-clicks, key 4 2-clicks

     

    I can just accept it working - But them I wont be able to create something like this from scratch - And this i my goal. Would you have time to do a detailed explanation?

     

    Link to comment
    Share on other sites

  • Topic Author
  • 35 minutes ago, ChristianSogaard said:

    I´m trying to understand everything in this Rule

     

    matrix1 = 77 -- DeviceID of matrix device - This is Clear

    • The [[ ]] is for indicating more that one expression is being evaluated ?

     

    [[ ...  ]] is the Lua way to write a string that is spanning multiple lines. Sometimes it is convenient to format a rule over multiple lines if it is a long expression.

    Every rule(<string) only defines one rule.

    The other advantage of using  [[ ... ]] is that you can freely use " and ' inside the rule. Otherwise if you use " ... " to define a rule you must use ' ... ' for strings inside the rule (for log commands ex)

     

    35 minutes ago, ChristianSogaard said:
    • central is CentralSceneEvent

    Yes.

     

    35 minutes ago, ChristianSogaard said:
    • keyPrim - is a Key Pressed 

    Not really, keyPrim is a variable that is bound to the first key press if any. Otherwise keyPrim is nil - which works as 'false' in a boolean expression.

     

    35 minutes ago, ChristianSogaard said:

    So :central & keyPrim = Event from CentralScene and there is a Key Pressed ?

    Not really. matrix1:central is that we got a centralSceneEvent from the device with deviceID matrix1.

    keyPrim is true if we have seen a key before (the first click)

     

    So this rule only triggers if we have seen a key before and the key we get now is the second key. Now we need to put them together into an event that we can post

     

    35 minutes ago, ChristianSogaard said:

     

    So what is this?

     post({type=fmt('%s_%s_%s',keyPrim,matrix1:central.keyId,matrix1:central.keyAttribute)}); 

    -- Post a LIST  - Save the LIST for later use ??

     

    So fmt is like Lua's string.format that is a bit like C's sprintf. Here we use it to concatenate 3 strings with '_' between

    The first key string (keyPrim), the second key's id, and the second key's keyAttribute

     

    'post' see below

     

    35 minutes ago, ChristianSogaard said:

    -- type=fmt -- not sure -- is this the Formating of the LIST

    Formatting of expression into a string

     

    35 minutes ago, ChristianSogaard said:

    -- matrix1:central -- Read CentralSceneEvent

    -- central.keyId -- What Key 

    The second key, see above.

    35 minutes ago, ChristianSogaard said:

    -- matrix1:central.keyAttribute -- Is pressed

         keyPrim=nil -- is Empty keyPrim variable

    When we put together a double-click-event, we clear the keyPrim variable so that we don't trigger the rule again until we press a new first key.

     

    35 minutes ago, ChristianSogaard said:

     

    rule([[matrix1:central & keyPrim =>
         post({type=fmt('%s_%s_%s',keyPrim,matrix1:central.keyId,matrix1:central.keyAttribute)}); 
         keyPrim=nil
    ]])

     

    So now we again detect CentralSceneEvent and key pressed - and keyPrim should be empty (nil)?

    So this part has a 2 sec wait - before deleting keyPrim. When keyPrim is empty 3 rule wont trigger.

     

     

    rule([[matrix1:central & keyPrim==nil =>
        keyPrim=fmt('Key%s_%s_%s',matrix1,matrix1:central.keyId,matrix1:central.keyAttribute); 
        wait(2);  ---- 
        keyPrim=nil
    ]])

    So this rule triggers the first key click. We know it's the first because keyPrim is. nil

    We assign keyPrim the string (deviceID) .."_"..(keyId).."_"..keyAttribute.

    This string will be the prefix when we create the string for the second key, so we get

    (deviceID)_(keyID first key)_(keyAttribute first key)_(keyID second key)_(keyAttribute second key)

     

    35 minutes ago, ChristianSogaard said:

     

    # - this is a new trigger created, based on the former rules.

    This rule triggers when both rules are triggered?

     

    rule("#Key77_2_Pressed3_4_Pressed2 => post(#disArm)") -- Matrix iD 77, key 2 3-clicks, key 4 2-clicks

     

    Rules are started (triggered) when they match incoming events.

    An event is a lua table with a type key. Ex. {type='device', id=88, property='value', value=true}

    It's similar to sourceTrigger in HC3 scenes.

    A short format (macro) for writing events in ER is to use the # prefix.

    #device{id=88, property='value', value=true} is the same as  {type='device', id=88, property='value', value=true}

    We actually save a few characters by that, and we make the type of the event stand out.

    The shortest event just have a type field. #foo is the same as {type='foo'}

     

    Rules always trigger on events but ER has some syntactic sugar for timers, devices being breached etc.

     

    If we have a rule that trigger on {type='foo'} we can write it as

    Please login or register to see this code.

     

    To trigger the rule someone has to post a #foo event.

     

    Please login or register to see this code.

    This will post the event #foo at sunset and the previous rule will trigger and print the message.

     

    In our case we have created that long string that uniquely identified the two keypresses. "Key77_2_Pressed3_4_Pressed2"

    We post that event with 

    Please login or register to see this code.

     

    And then we have other rules that triggers on the various types combined key events. like 

    Please login or register to see this code.

     

    The post/event-handler model is key to understand how to do some of the more advanced stuff in ER.

    It's actually a complete programming model that allows to express all types of traditional control structures.

     

    post cab take a delay before it will post an event

    Please login or register to see this code.

     

    This creates a loop that logs ding every 5min. We need the second rule to start the loop.

    Etc.

    There are some attempts to tutorials <

    Please login or register to see this link.

    >, <

    Please login or register to see this link.

    >, and <

    Please login or register to see this link.

    > (they may not explain 'fmt' specifically)

    There is also a tutorial in writing event handlers in Lua instead of my made up ERscript language <

    Please login or register to see this link.

    >.

    It gives a good background on the underlying mechanism of ERscript (it compiles to lua event handlers)

    The only difference in ER4 is that it's a QA and the Event.rule() function is self:event() and Event.post() is self:post()

     

    35 minutes ago, ChristianSogaard said:

    I can just accept it working - But them I wont be able to create something like this from scratch - And this i my goal. 

    That's the spirit! The source code to ER is <

    Please login or register to see this link.

    :-) 

    • Like 1
    Link to comment
    Share on other sites

    7 hours ago, jgab said:

     

    [[ ...  ]] is the Lua way to write a string that is spanning multiple lines. Sometimes it is convenient to format a rule over multiple lines if it is a long expression.

    Every rule(<string) only defines one rule.

    The other advantage of using  [[ ... ]] is that you can freely use " and ' inside the rule. Otherwise if you use " ... " to define a rule you must use ' ... ' for strings inside the rule (for log commands ex)

     

    Yes.

     

    Not really, keyPrim is a variable that is bound to the first key press if any. Otherwise keyPrim is nil - which works as 'false' in a boolean expression.

     

    Not really. matrix1:central is that we got a centralSceneEvent from the device with deviceID matrix1.

    keyPrim is true if we have seen a key before (the first click)

     

    So this rule only triggers if we have seen a key before and the key we get now is the second key. Now we need to put them together into an event that we can post

     

     

    So fmt is like Lua's string.format that is a bit like C's sprintf. Here we use it to concatenate 3 strings with '_' between

    The first key string (keyPrim), the second key's id, and the second key's keyAttribute

     

    'post' see below

     

    Formatting of expression into a string

     

    The second key, see above.

    When we put together a double-click-event, we clear the keyPrim variable so that we don't trigger the rule again until we press a new first key.

     

    So this rule triggers the first key click. We know it's the first because keyPrim is. nil

    We assign keyPrim the string (deviceID) .."_"..(keyId).."_"..keyAttribute.

    This string will be the prefix when we create the string for the second key, so we get

    (deviceID)_(keyID first key)_(keyAttribute first key)_(keyID second key)_(keyAttribute second key)

     

     

    Rules are started (triggered) when they match incoming events.

    An event is a lua table with a type key. Ex. {type='device', id=88, property='value', value=true}

    It's similar to sourceTrigger in HC3 scenes.

    A short format (macro) for writing events in ER is to use the # prefix.

    #device{id=88, property='value', value=true} is the same as  {type='device', id=88, property='value', value=true}

    We actually save a few characters by that, and we make the type of the event stand out.

    The shortest event just have a type field. #foo is the same as {type='foo'}

     

    Rules always trigger on events but ER has some syntactic sugar for timers, devices being breached etc.

     

    If we have a rule that trigger on {type='foo'} we can write it as

    Please login or register to see this code.

     

    To trigger the rule someone has to post a #foo event.

     

    Please login or register to see this code.

    This will post the event #foo at sunset and the previous rule will trigger and print the message.

     

    In our case we have created that long string that uniquely identified the two keypresses. "Key77_2_Pressed3_4_Pressed2"

    We post that event with 

    Please login or register to see this code.

     

    And then we have other rules that triggers on the various types combined key events. like 

    Please login or register to see this code.

     

    The post/event-handler model is key to understand how to do some of the more advanced stuff in ER.

    It's actually a complete programming model that allows to express all types of traditional control structures.

     

    post cab take a delay before it will post an event

    Please login or register to see this code.

     

    This creates a loop that logs ding every 5min. We need the second rule to start the loop.

    Etc.

    There are some attempts to tutorials <

    Please login or register to see this link.

    >, <

    Please login or register to see this link.

    >, and <

    Please login or register to see this link.

    > (they may not explain 'fmt' specifically)

    There is also a tutorial in writing event handlers in Lua instead of my made up ERscript language <

    Please login or register to see this link.

    >.

    It gives a good background on the underlying mechanism of ERscript (it compiles to lua event handlers)

    The only difference in ER4 is that it's a QA and the Event.rule() function is self:event() and Event.post() is self:post()

     

    That's the spirit! The source code to ER is <

    Please login or register to see this link.

    :-) 

    I tried create two Event runner4  Rules

    Please comment on them :-)

     

    Bathroom

    Condition
    •    Monday 2 Friday
    Action
    •    Turn on Switch for Heating 06.15
    •    Turn off after 90 min

    OR Condition

    All Days
    •    If manuel turned ON
    Action
    •    Turn off after 90 min

    Heating = { 356 } – Device/Switch 

    Rule ("@(06:15) & wday('mon-fri' => Heating:on
    Rule ("Matrix:central.keyId==2) => Heating:on")
    Rule("trueFor(90:00) & Heating:on => Heating:off)")
        

    In Real live ER trigger looks like this
    Incoming trigger:{"value":{"keyAttribute":"Pressed","keyId":2},"type":"device","id":182,"property":"centralSceneEvent"}

    ------------------------------------------------------------------------------------------------------------------------

    Entre
    Condition
    •    Between Sunset to Sunrise
    •    Door Switch i Breach
    Action
    •    Turn ON.
    •    Turn off after 10 min

    lamps = { 101 }
    rule("@sunset ) => $SunStatus='Nat'")
    rule("@sunrise) => $SunStatus='Dag'")
    rule("door:breached => lamps:on")
    rule("trueFor(00:05, 101:isOn & door:safe) => lamps:off")

    OR

    rule("@sunset-sunrise & door:breached  => 101:off”)
    rule("trueFor(00:05, 101:isOn & door:safe) => 101:off")

    Link to comment
    Share on other sites

  • Topic Author
  • 12 hours ago, ChristianSogaard said:

    I tried create two Event runner4  Rules

    Please comment on them :-)

     

    Bathroom

    Condition
    •    Monday 2 Friday
    Action
    •    Turn on Switch for Heating 06.15
    •    Turn off after 90 min

    OR Condition

    All Days
    •    If manuel turned ON
    Action
    •    Turn off after 90 min

    Heating = { 356 } – Device/Switch 

    Rule ("@(06:15) & wday('mon-fri' => Heating:on
    Rule ("Matrix:central.keyId==2) => Heating:on")
    Rule("trueFor(90:00) & Heating:on => Heating:off)")

    Please login or register to see this code.

    90min is 00:90, or 01:30

    Parenthesis missing and misplaced, I changed a bit.

    trueFor(<time>,<expression>)

    takes 2 argument, a time and and expression that should be true for that time.

    Now it triggers on key 2 for Pressed, Pressed2. etc. You could add

    Rule("Matrix:central.keyId==2 & Matrix:central.keyAttribute=='Pressed' => Heating:on")

     

    Quote

    In Real live ER trigger looks like this
    Incoming trigger:{"value":{"keyAttribute":"Pressed","keyId":2},"type":"device","id":182,"property":"centralSceneEvent"}

    ------------------------------------------------------------------------------------------------------------------------

    Entre
    Condition
    •    Between Sunset to Sunrise
    •    Door Switch i Breach
    Action
    •    Turn ON.
    •    Turn off after 10 min

    lamps = { 101 }
    rule("@sunset ) => $SunStatus='Nat'")
    rule("@sunrise) => $SunStatus='Dag'")
    rule("door:breached => lamps:on")
    rule("trueFor(00:05, 101:isOn & door:safe) => lamps:off")

    OR

    rule("@sunset-sunrise & door:breached  => 101:off”)
    rule("trueFor(00:05, 101:isOn & door:safe) => 101:off")

     

    @ is a timmer that starts the rule at a specific time. To test a time use interval test <timeA>..<timeB>

    In general you don't need to use global variables ($) unless you use it to communicate with other scenes

     

    Please login or register to see this code.

    The last rule turns off the light if light is on and door is safe for 10min (both) during the sunset..sunrise period.

    Edited by jgab
    • Like 1
    Link to comment
    Share on other sites

    On 9/9/2020 at 10:33 PM, jgab said:

     

    With the "new" location trigger one can do rules like this

    Please login or register to see this code.

    The set of rules keep track of the number of people at home, all, some, and none.

    It can trigger rules with the trigger variables 'allAway', 'allAtHome' and 'someAtHome'

    Now 'allAtHome' causes 'someAtHome' to trigger too - it's easy to modify if you want it exclusive.

    When the QA starts locations are unknown - need some more code to lookup current positions.

    I was looking into doing something like that - and someone already thought about it?. I just want to have a trigger more for ALARM Armed, so I can send a push message when ALARM NOT ARMED and allAway = True. 

    Link to comment
    Share on other sites

    Jan,

    Weird two curtains opens and rest stay closed the trigger is there the action is there too but practical>>nothing

    Please login or register to see this attachment.

    Please advice,

    //Sjakie

    Link to comment
    Share on other sites

    Jan, sorry for bothering it was hanging on NodeRed error.

    Fixed now.

    //Sjakie

    Link to comment
    Share on other sites

    Jan,

    In your arming scene HC3 there is a beautiful msg service.

    It was working when I left the admin panel in the evening when arming the house no msg.

    I upload a backup of Arming scene msg worked. I

    deleted the new scene and armed the house and the "old" arming scene sends the msg.

    What happend?

    Please advice,
    //Sjakie
    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...