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

  • Topic Author
  • Posted
    17 hours ago, ChristianSogaard said:

    Converting ER4>EV5

     

    Works in Ev4 but not in EV5

    Please login or register to see this code.

     

    [23.11.2023] [17:48:20] [ERROR] [QUICKAPP1961]: Last err: [Rule:57:trueFor(00:04:00,Flisegang:safe & entre.FliseAutoORManuelt) => 1184:off; entre..] Rule: nil is not a valid device trueFor(00:04:00,Flisegang:safe & entre.FliseAutoORManuelt) => 1184:off; entre.FliseAutoORManuelt=false ^

     

    Works in EV5

    Please login or register to see this code.

     

    is this by design or me messing up ?

    Ahhh, that was a big fat bug in my rule compiler - thanks for running into it. Will release a new version within an hour...

    17 minutes ago, Neo Andersson said:

    I am a bit confused now..

    I think || >> lines never needed any ; in ER4

    Only after the whole ||>> part is finished, and you needed to add some other statements after, there you needed the ;; to mark the end of the ||>> part

    Did this change in ER5 to some other pttern? I doubt,because my ER5 based home system never complained about this

    In ER4 I think you could end with an ';' before next '||'. In ER5 you can't. The double ';;' was to mark the end of the whole ||>> sequence.

    • Like 1
    Posted

    Jan for me it's not clear how to write in ER5

    I have HUE switch to open frontdoor

    Please login or register to see this code.

    If I try 

    Please login or register to see this code.

    Result is hal.keukenDeur is breached in white! color

    What am I doing wrong?

    How to do for post or remote in a different color?

    Posted

    Jan, i have nothing showing up in debug window except Setting up rules...

    This is the global debug settings from ER5

    I dont have any rule debug options directly in rules.

    Why don't I see nothing?

     

    Please login or register to see this attachment.

  • Topic Author
  • Posted

    So, per default it logs user logs on the tag QUICKAPP<ID>

    and "system logs" on ER<ID>, so you need to choose both tags in the console.

     

    It's actually a settings

    er.settings.systemLogTag = "ER"..self.id

     

    and if you set it to nil it will use the standard QUICKAPP<ID> tag for system logs too.

    er.settings.systemLogTag =nil
    Just now, jgab said:

    So, per default it logs user logs on the tag QUICKAPP<ID>

    and "system logs" on ER<ID>, so you need to choose both tags in the console.

     

    It's actually a settings

    er.settings.systemLogTag = "ER"..self.id

     

    and if you set it to nil it will use the standard QUICKAPP<ID> tag for system logs too.

    er.settings.systemLogTag =nil

     When the rules are working it can be nice to just have the user logs in the console and not clutter/mix it with system logs too.

    • Like 1
    Posted
    5 minutes ago, jgab said:

    So, per default it logs user logs on the tag QUICKAPP<ID>

    and "system logs" on ER<ID>, so you need to choose both tags in the console.

     

    It's actually a settings

    er.settings.systemLogTag = "ER"..self.id

     

    and if you set it to nil it will use the standard QUICKAPP<ID> tag for system logs too.

    er.settings.systemLogTag =nil

     When the rules are working it can be nice to just have the user logs in the console and not clutter/mix it with system logs too.

    and how to chage colors?

    Like this blue on the picture,

    Please login or register to see this attachment.

  • Topic Author
  • Posted
    2 minutes ago, Neo Andersson said:

    and how to chage colors?

    Like this blue on the picture,

    Please login or register to see this attachment.

    Strange that it's blue....?

    Below the settings there is a custom rule log function

    Please login or register to see this code.

    and it should set the true and false to light green and lighter resp.

    Posted (edited)
    2 minutes ago, jgab said:

    Strange that it's blue....?

    Below the settings there is a custom rule log function

    Please login or register to see this code.

    and it should set the true and false to light green and lighter resp.

    Yeah i have noticed that but since for me its BLUE i thought this is not the place to define

    Actually the TRUE is in green

    Edited by Neo Andersson
  • Topic Author
  • Posted

    It's strange because it should translate to html font color, like

    <font color='lightgreen'>....</font>

    Posted
    2 minutes ago, jgab said:

    It's strange because it should translate to html font color, like

    <font color='lightgreen'>....</font>

    Please login or register to see this image.

    /monthly_2023_11/image.png.7a125b073d3b192198d54db1ca331ff8.png" />

     

    I think the lightgreen is okay, only the lightred doesnt work..its blue for me, maybe it is browser sepcific problem, but this blue for me is almost unreadable

    2 minutes ago, Neo Andersson said:

    Please login or register to see this link.

     

    I think the lightgreen is okay, only the lightred doesnt work..its blue for me, maybe it is browser sepcific problem, but this blue for me is almost unreadable

    I have used #d45767 as in hex format for lightred and it works

  • Topic Author
  • Posted
    1 hour ago, Sjakie said:

    Jan for me it's not clear how to write in ER5

    I have HUE switch to open frontdoor

    Please login or register to see this code.

    If I try 

    Please login or register to see this code.

    Result is hal.keukenDeur is breached in white! color

    What am I doing wrong?

    How to do for post or remote in a different color?

    You define warningOptions but use warnOptions which is nil…

    Posted

    Jan, sorry just copied from you where you discribed  "You define warningOptions"

    How can I do simular for post or remote? to give it their own log color?

     

  • Topic Author
  • Posted
    2 minutes ago, Sjakie said:

    Jan, sorry just copied from you where you discribed  "You define warningOptions"

    How can I do simular for post or remote? to give it their own log color?

     

    How does the post and remote rules look like?

  • Topic Author
  • Posted
    3 hours ago, Neo Andersson said:

    @jgab Jan we also had a conversation about the better trace of timers in trueFor.

    Somehow, i need to get the information about a trueFor rule's timer. Where is the counting at a moment. ex how much seconds remains to the trigger..Like in case of delayed opening of a door, i can show the remaining seconds to the user..is that too complicated?

    And also we tlaked about action calls where the state should be chceked first and not performed any operation if the desired state is already present. Now i am using for it my own function that actuially follows this logic ... => device:isOff & device:on

    Sorry, one more thing

    using push and simplePush somehow..i think at this moment only push is working..notifications for devices doesn't have support even in ER4..maybe i am wrong

     

    Look at (and try) this rule(s)

    Please login or register to see this code.

    We have a trueFor that is started by assigning a triggerVar true.

    When a trueFor starts, run the action, or is cancelled, it will post an event #trueFor{status=..., time=<time>, id=<ruleId>}

    We save the rule in the variable tfr and check against tfr.id in our next rule.

    If it is a trueFor event from our previous rule (id=tfr.id) we check if status is 'started' and then we start to count down every second.

    Here we could do other stuff, like update an UI label.

    If the rule is triggered by an #trueFor event with another status ('cancelled' or 'action') we don't start the loop and count down.

    ....but because we have set the rule to .mode('killOthers') it will kill the first instance of the rule that is counting down...

     

    Let me come back on push - I'm just using what's available in the fibaro api and I think there is no simplePush anymore...

    • Like 1
    Posted

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    2 minutes ago, Sjakie said:

    Please login or register to see this code.

     

    Ok, you have different colours for different logs in the same rule - then you need to do something like you do.

    The option option is only for the whole rule.

    Pushed v0.31 with a bug fix, thanks @ChristianSogaard

    Also some small additions.

     

     

    Posted

    ok, thanks.

    How to write as trigger?

    Please login or register to see this code.

  • Topic Author
  • Posted
    3 minutes ago, Sjakie said:

    ok, thanks.

    How to write as trigger?

    Please login or register to see this code.

    rule("hal.Switch_Voordeur_Slot:central.keyId==1 & hal.Switch_Voordeur_Slot:central.keyAttribute=='Pressed' => ...

     

    ...but there is coming a better (shorter) way of doing it....

  • Topic Author
  • Posted (edited)

    Custom properties

    Defining your own properties can be done in two ways.... (Obs. need v0.31)

    This describes the first way - adding property functions to standard devices - the devices/resources we describe with numbers.

    Like

    55:isOn

     

    To add an :onIfOff property we can do

    Please login or register to see this code.

    and use it like

    Please login or register to see this code.

     

    So there are 3 things ER want to know about a property to be able to use it.

    What should 

    <id>:<property>

    mean. We call this the 'getProp' function for a property. It is when we return the property value of a device/ID.

    Then, what should 

    <id>:<property> = <value>

    mean. We call this the 'setProp' function of a property.

    And lastly, when used in the condition part of a rule, what sourceTrigger should it trigger the rule on.

     

    If we leave the setProp out we can't assign to the property (which is ok for some properties)

    If we leave the trigger out they will not act as triggers in the condition part of a rule (which is also ok for some properties).

     

    Assume we have a property 'windowOpened' and we would like to make that a user :property.

    Please login or register to see this code.

    Here we declare the getProp, and it just returns the fibaro.get(id,'windowOpened')

    We also define a setProp function (I'm not sure we can set it but lets pretend) that sets the property

    and lastly we define how the sourceTrigger should look like for triggering the rule.

    We can now write

    rule("8888:windowOpened == true => ....")

    and the rule will trigger when device 8888's property 'windowOpened' changes value.

    In the condition we access the value with the getProp function and we compared it to true and if ok we run the action.

     

    A useful extension is to make a simpler centralSceneEvent property - we know it's a key and a keyAttribute

    Please login or register to see this code.

    Now we have a :key attribute that returns the key..":"..keyAttribute as a string

    The 

    Please login or register to see this code.

    3x'=' is the string match function and the same as string.match(a,b)

    So the rule triggers on centralSceneEvent, return the :key that is something like "4:Pressed"

    and we string match that against "4:.*" that will match keyId 4 and any keyAttribute in this case.

    If we are only looking for "Pressed" we can just do

    Please login or register to see this code.

    Edited by jgab
  • Topic Author
  • Posted (edited)

    Custom objects

     

    The other :property functions are those we define for custom objects.

    The stdProp in the previous example assumed that the id was a number, the way we describe devices and rooms and sections and alarmPartitions etc.

     

    If we would like to have a weather property we can't use this approach as the weather resource don't have a number id.

     

    But we can define our own custom object and define property functions on that

    Please login or register to see this code.

    We define a new class Weather and for that class we define property methods similar to the previous example, getProp, setProp, and trigger functions.

    In this case we don't have setProps as we can't change the weather...

    To use this we need to make the Weather object available in ER so we declare a variable

    var.weather = Weather()

     

    We can then in rule use

    rule("weather:temperature > 40 => log('It is hot!')")

     

    In fact, the weather variable/object is already available in ER5 defined in this way - so go ahead and use it...

     

    Anyway, this is a bit more advanced usage, but works if we want to define :property methods for resource that doesn't have number ids...

    Edited by jgab
    Posted
    1 hour ago, jgab said:

    Custom properties

    Defining your own properties can be done in two ways.... (Obs. need v0.31)

    This describes the first way - adding property functions to standard devices - the devices/resources we describe with numbers.

    Like

    55:isOn

     

    To add an :onIfOff property we can do

    Please login or register to see this code.

    and use it like

    Please login or register to see this code.

     

    So there are 3 things ER want to know about a property to be able to use it.

    What should 

    <id>:<property>

    mean. We call this the 'getProp' function for a property. It is when we return the property value of a device/ID.

    Then, what should 

    <id>:<property> = <value>

    mean. We call this the 'setProp' function of a property.

    And lastly, when used in the condition part of a rule, what sourceTrigger should it trigger the rule on.

     

    If we leave the setProp out we can't assign to the property (which is ok for some properties)

    If we leave the trigger out they will not act as triggers in the condition part of a rule (which is also ok for some properties).

     

    Assume we have a property 'windowOpened' and we would like to make that a user :property.

    Please login or register to see this code.

    Here we declare the getProp, and it just returns the fibaro.get(id,'windowOpened')

    We also define a setProp function (I'm not sure we can set it but lets pretend) that sets the property

    and lastly we define how the sourceTrigger should look like for triggering the rule.

    We can now write

    rule("8888:windowOpened == true => ....")

    and the rule will trigger when device 8888's property 'windowOpened' changes value.

    In the condition we access the value with the getProp function and we compared it to true and if ok we run the action.

     

    A useful extension is to make a simpler centralSceneEvent property - we know it's a key and a keyAttribute

    Please login or register to see this code.

    Now we have a :key attribute that returns the key..":"..keyAttribute as a string

    The 

    Please login or register to see this code.

    3x'=' is the string match function and the same as string.match(a,b)

    So the rule triggers on centralSceneEvent, return the :key that is something like "4:Pressed"

    and we string match that against "4:.*" that will match keyId 4 and any keyAttribute in this case.

    If we are only looking for "Pressed" we can just do

    Please login or register to see this code.

    I have a lot of rule like this - i guess i can convert them to the new format ?   

    rule("matrix_Kitchen_Bottom:central.keyId==4 & matrix_Kitchen_Bottom:central.keyAttribute=='Pressed' => {1980,1981}:close")

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