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

Posted

How do i check/evaluate this 

- its the uptime / reboot check 

 

 

Please login or register to see this code.

 

 
  • Topic Author
  • Posted

    Please login or register to see this code.

     

  • Topic Author
  • Posted (edited)

    So, I develop EventRunner5 in my VSCode emulator for QuickApps -

    Please login or register to see this link.

    .

    One of the cool things with VSCode is that they have a ChatGPT like feature named co-pilot (I'm not sponsored :-) )

    Anyway, just wrote this ER rule

    Please login or register to see this code.

    ...and then I asked co-pilot to /explain the rule

    GitHub Copilot

    used @workspace
     

    Please login or register to see this link.

     

    The provided Lua code is a rule definition in the EventRunner5 framework, which is used for home automation tasks. This framework allows you to define rules in a declarative way, specifying the conditions under which certain actions should be performed.

    The rule @sunset & 77:isOn => 88:on can be broken down as follows:

    • @sunset: This is a special condition that becomes true at sunset. The '@' symbol is used to denote special conditions related to time or astronomical events.

    • &: This is the logical AND operator. It means that both conditions on either side of it must be true for the rule to be activated.

    • 77:isOn: This is a device condition. It checks if the device with the ID 77 is turned on. The :isOn part is a method that checks the state of the device.

    • =>: This is the implication operator. It means that when the conditions on the left side are true, the actions on the right side should be performed.

    • 88:on: This is an action. It turns on the device with the ID 88. The :on part is a method that changes the state of the device.

    So, in plain English, this rule says: "At sunset, if device 77 is on, then turn on device 88." It's a simple way to automate device control based on time and the state of other devices.

     

    ...and then

    /explain "rule("@@00:00:05 => i=i+1; log('ping: %s seconds',i*5)",{ruleResult=false,ruleTrue=false})"

     

        GitHub Copilot
    used @workspace
     

    Please login or register to see this link.

     

    The provided Lua code is a rule definition in the EventRunner5 framework, which is used for home automation tasks. This framework allows you to define rules in a declarative way, specifying the conditions under which certain actions should be performed.

    The rule @@00:00:05 => i=i+1; log('ping: %s seconds',i*5) can be broken down as follows:

    • @@00:00:05: This is a special condition that becomes true every 5 seconds. The '@@' symbol is used to denote periodic conditions. The time '00:00:05' specifies the period of the condition, which is 5 seconds in this case.

    • =>: This is the implication operator. It means that when the condition on the left side is true, the actions on the right side should be performed.

    • i=i+1; log('ping: %s seconds',i*5): These are the actions that are performed when the condition is true. The first action, i=i+1, increments the value of the variable i. The second action, log('ping: %s seconds',i*5), logs a message. The message includes the string 'ping: %s seconds', where '%s' is a placeholder that is replaced with the value of i*5. The log function is a built-in function that logs messages to the Home Center's event log.

    • {ruleResult=false,ruleTrue=false}: These are options that modify the behavior of the rule. The ruleResult=false option means that the result of the rule (i.e., the value returned by the actions) is not stored. The ruleTrue=false option means that the rule is not marked as true when the actions are performed.

    So, in plain English, this rule says: "Every 5 seconds, increment the value of i and log a message that includes the value of i multiplied by 5." It's a simple way to perform actions periodically and log their results.

     

    That's pretty good (just misunderstands the options a bit)
    - maybe I will let co-pilot write the documentation for me ;-) 

     

    Then I asked "@workspace Add a rule that turns off the device 88 at sunrise, but only if device 77 is off"

         GitHub Copilot
    used @workspace

    Please login or register to see this link.


     

    To add a rule that turns off device 88 at sunrise, but only if device 77 is off, you can use the following code:

     
    ("@sunrise & 77:isOff => 88:off")
     

    This rule can be read as: "At sunrise, if device 77 is off, then turn off device 88."

    Please add this rule in the appropriate place in your 

    Please login or register to see this link.

     script or wherever you are defining your rules.

     

    Well, it's a start... however, more complicated rules it stumbles on - too few samples to deduce from....

    Edited by jgab
    • Like 2
    Posted
    2 hours ago, jgab said:

    Please login or register to see this code.

     

    Hei Jan

     

    seems that my cut'n'paste is playing tricks also ;-) 

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    40 minutes ago, ChristianSogaard said:

    Hei Jan

     

    seems that my cut'n'paste is playing tricks also ;-) 

     

    Please login or register to see this code.

     

    Yes the api.get calls needs it argument with single quotes, because the whole rule is defined with double quotes.

    Please login or register to see this code.

     

    Posted

    Hei Jan

    I tried you examples from the documentation, Events Section

     

    it gives bad expression

    Please login or register to see this code.

     

    My goal is to make this working in EV5

    Please login or register to see this code.

    I also tried the post without self: 

     

    What the magic .-) ?=

     

     

  • Topic Author
  • Posted

    It's Lua - outside rules?

    Please login or register to see this code.

     

    • Thanks 1
    Posted

    Jan, this is in seconds how to convert in days and hours?

    Please login or register to see this code.

     

    Posted
    29 minutes ago, Sjakie said:

    Jan, this is in seconds how to convert in days and hours?

    Please login or register to see this code.

     

    rule("@@00:00:60 => log('HC3 uptime %.0f hours',(os.time() - api.get('/settings/info').serverStatus)/3600)")
     

    • Like 1
  • Topic Author
  • Posted

    v0.2 pushed

    - fixed bugs in bug reporting.

    - cosmectics.

    - New examples in main file

    • Thanks 1
    Posted

    Jan I was surprised that my wife informed me that the light in the bath room did not switch on.

    By investigation I saw that the QA was crashed because of an error (probally created by myself).

    Can you re-design your controller or adding crosswover in all QA's so that when it happens again I am informed before wifey complains?

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

    Jan I was surprised that my wife informed me that the light in the bath room did not switch on.

    By investigation I saw that the QA was crashed because of an error (probally created by myself).

    Can you re-design your controller or adding crosswover in all QA's so that when it happens again I am informed before wifey complains?

    Did it crash and restart or crash and hang?

    Posted

    crash and hang, debug screen empthy in both cases

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

    crash and hang, debug screen empthy in both cases

    How do you know it crashed - any error message before it hung?

    I'm asking because we have this mysterious QA hangs since a long time back...

    Posted

    Hei Jan

     

    I tried to create a pair of rules.

    I have other rules for open/close of windows, so the close windows rule are linked to this open rule.

     

    Is there a better way to do this? (delay before closing the windows). - im not happy for the wait 30 min command.

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted (edited)
    On 11/20/2023 at 9:40 AM, ChristianSogaard said:

    rule("@@00:00:60 => log('HC3 uptime %.0f hours',(os.time() - api.get('/settings/info').serverStatus)/3600)")
     

    In next version of ER5 there will be 2 variables defined

    'uptimeStr' that gives a string with uptime in days hour and minutes.

    Ex.

    Please login or register to see this code.

    and uptimeMinutes that return the number of uptime minutes as a number.

     

    So, a rule like

    Please login or register to see this code.

    should work...

    Edited by jgab
    • Thanks 1
    Posted

    the QA did nothing anymore so I asume it crashed

    Person_in_Batroom >>>nothing nothing in screen screen empthy

    Posted

    [20.11.2023] [20:51:34] [ERROR] [ER1061]: [Rule:4:uptimeMinutes < 5 => post(#HC3_restart)] Rule: No triggers in rule
    uptimeMinutes < 5 => post(#HC3_restart)

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

    [20.11.2023] [20:51:34] [ERROR] [ER1061]: [Rule:4:uptimeMinutes < 5 => post(#HC3_restart)] Rule: No triggers in rule
    uptimeMinutes < 5 => post(#HC3_restart)

    I said next version…

    Posted (edited)

    Hi Jan

    I have been working with EV5 most of the evening, and therefor it has been restartet multiple times

    Looking at rule 35, somehow its not listed in the timers were my time is 21:57 (no restart after this time) and was not triggered at 22.00

    Rule 35 -   rule("@22.00 => {myLight1,myLight2}:off")

    myLight1+2 are defined.

     

    Would you know why ?

    Please login or register to see this code.

     

    Edited by ChristianSogaard
    Typo

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