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

    I have released EventRunner 7. 
    It's to a high degree backward compatible with ER6 but a total rewrite of the internal engine and script functions.
    It's cleaner architecture and cleaner code, coming from the experience of writing ER6.
    It should be better and faster and produce better error messages when something goes wrong with rules.
    I have a backlog of stuff still missing in ER7 that are mostly old things from earlier ER implementations - questionable if they are needed. If you miss something, let me know and I'll add it.
    I'm still keeping EventRunner 6 around for people that are happy with it, otherwise I recommend to make the jump to EventRunner7. You need to move over the rules by hand from ER6/ER5.
    After that, ER7 is upgradable/downgradable using

    Please login or register to see this link.

    .

    I will come back with what's new in ER7 and roadmap in a separate post.

  • Topic Author
  • Posted (edited)

    🎉 EventRunner7 v0.1.8 — Rule Modifiers, Named Scenes & Rule Groups

    Three new language features landed in v0.1.7–v0.1.8 that make rules more expressive and easier to maintain: Rule Modifiers, Named Scenes, and Rule Groups.


    ⚙️ Rule Modifiers

    Modifiers are optional keywords placed between the condition and =>. They change when or how often the action fires — without touching the condition itself.

    Please login or register to see this code.

    Modifier Syntax Effect
    single cond since => Cancel all pending timers and wait() suspensions from the previous run before starting a new one
    since T cond since 00:02 => Condition must stay continuously true for T seconds before firing
    debounce T cond debounce 0.5 => Wait T seconds of silence after the last trigger; any re-trigger cancels and restarts the wait (implies restart)
    cooldown T cond cooldown 00:05 => Suppress re-triggering for T seconds after the last fire
    every N cond every 4 => Fire only on every N-th true evaluation of the condition
    first_in W cond first_in 07:00..08:00 => Fire at most once per opening of time window W; the latch resets automatically when the window closes. W must be a .. time range.

    What each modifier desugars to

    All modifiers except restart and debounce are pure condition sugar — they rewrite the condition expression before compilation. restart and debounce also carry a runtime flag that clears active timers on each invocation.

    Modifier Expands to Clears timers?
    cond single => action RULE node flag {restart=true} set; action unchanged cancels pending wait() / timers before each run
    cond since T => action condition becomes trueFor(T, cond)
    cond debounce T => action RULE flag {restart=true} set; wait(T) prepended to action block cancels previous wait(T) on each re-trigger
    cond cooldown T => action condition becomes cond AND cool_down(T)
    cond every N => action condition becomes cond AND every_other(N)
    cond first_in W => action condition becomes cond AND once(W)

    Examples

    Please login or register to see this code.

    ℹ️ first_in requires a .. time window as its argument. Passing anything else (a number, a variable, etc.) is a parse-time error. Under the hood it desugars to cond AND once(W) — the existing once() latch function, which auto-resets when the window closes.

    🎬 Named Scenes

    A named scene groups a set of device property assignments under a name. Scenes are declared with the soft keyword scene and activated or deactivated via the familiar obj:property syntax inside any rule action.

    Short form — activate-only

    Please login or register to see this code.

    Long form — separate activate and deactivate bodies

    Please login or register to see this code.

    Using scenes in rules

    Please login or register to see this code.

    Dynamic values — re-evaluated at activation time

    Literal values (10, true, "off") are stored at declaration time. Any non-literal expression is wrapped in a thunk and re-evaluated every time the scene activates:

    Please login or register to see this code.

    ℹ️ Calling :deactivate on a short-form (activate-only) scene is a runtime error that disables the rule, so you know immediately if you forgot a deactivate body.

    �️ Rule Groups

    Rules can now be tagged with a group name at registration time. The entire group can then be enabled or disabled in a single call — from outside in Lua, or from inside any rule action using the built-in enable / disable functions.

    Registering rules in a group

    Please login or register to see this code.

    Enabling / disabling a group from a rule action

    Please login or register to see this code.

    The built-in enable / disable accept:

    • A group name string — acts on every rule in the group
    • A rule object — acts on that rule only
    • A numeric rule id — acts on that rule only
    • No argument — acts on the current rule (self-disable pattern)

    Vacation mode example

    Please login or register to see this code.

    Accessing groups from Lua

    Please login or register to see this code.


    📥 Download

    • GitHub Releases: 

      Please login or register to see this link.

    • Direct download: 

      Please login or register to see this link.

    📚 Documentation

    • Please login or register to see this link.

       — updated with modifiers and scenes sections
    • Please login or register to see this link.

    • Please login or register to see this link.

    Edited by jgab
    • Like 2
    Posted
    On 5/24/2026 at 4:58 PM, jgab said:

    Direct download: 

    Please login or register to see this link.

    I did download the FQA file: using the above direct link and also going to your GitHub but I am always getting an error without any code followed by error 500 when trying to upload the fqa file in my HC3 Version 5.210. Any other FAQ file is accepted.

    What I am doing wrong?

  • Topic Author
  • Posted (edited)
    41 minutes ago, Christb said:

    I did download the FQA file: using the above direct link and also going to your GitHub but I am always getting an error without any code followed by error 500 when trying to upload the fqa file in my HC3 Version 5.210. Any other FAQ file is accepted.

    What I am doing wrong?

    Sorry, it was an error when I packed it to an fqa. I fixed it now - try to download 0.1.10.

    Edited by jgab
  • Topic Author
  • Posted

    EventScript Debug Tooling (ER7)

    EventScript provides a set of runtime debug functions that help you understand why rules fire (or don't). All functions work on both plua (development) and the real HC3 (production) — output goes through the standard log console in both environments.

    Table of Contents

    • Please login or register to see this link.

    • Please login or register to see this link.

    • Please login or register to see this link.

    • Please login or register to see this link.

    • Please login or register to see this link.

    • Please login or register to see this link.


    Named Rules

    All debug functions identify rules by name. Give a rule a name via the {name=...} option:

    Please login or register to see this code.

    Without a name, rules get an automatic name like "RULE3" (based on their registration order). You can still address them by name or by numeric ID:

    Please login or register to see this code.

    The rule name also appears in all standard log output:

    Please login or register to see this code.


    Rule Inspector — info()

    info(rule) prints a snapshot of everything known about a rule at that moment: its source, triggers, enabled/disabled status, active modifier state, and history recording status.

    Please login or register to see this code.

    Sample output:

    Please login or register to see this code.

    For a rule with modifiers and active state:

    Please login or register to see this code.

    Please login or register to see this code.

    Trigger from another rule:

    Please login or register to see this code.


    Live Watch — watchOn() / watchOff()

    Watch prints a log line immediately every time a rule's condition is evaluated — pass or fail. Use it when you want real-time feedback without needing to dump a buffer later.

    Please login or register to see this code.

    Every trigger now produces a line like:

    Please login or register to see this code.

    Turn it off:

    Please login or register to see this code.

    Watch all rules at once:

    Please login or register to see this code.

    Schedule a watch window from a rule:

    Please login or register to see this code.

    watchOn and historyOn are independent — you can use both on the same rule simultaneously.


    Invocation History — historyOn() / showHistory()

    History records the last N invocations of a rule in a circular buffer. Unlike watch, it doesn't print anything immediately — you dump it on demand with showHistory().

    Start recording:

    Please login or register to see this code.

    Stop recording (buffer is preserved):

    Please login or register to see this code.

    Dump the buffer:

    Please login or register to see this code.

    Sample output:

    Please login or register to see this code.

    All-rules variants:

    Please login or register to see this code.

    Set buffer size at definition time (recording still starts off):

    Please login or register to see this code.

    Scheduled history window:

    Please login or register to see this code.


    Combining Tools

    The debug functions compose freely. A typical investigation pattern:

    Please login or register to see this code.


    Function Reference

    Function Description
    info(rule) Print full rule snapshot: src, triggers, modifier state, history status
    watchOn(rule) Print a log line immediately on every condition evaluation
    watchOff(rule) Stop live logging for this rule
    watchOnAll() Enable live logging for all rules
    watchOffAll() Disable live logging for all rules
    historyOn(rule, size?) Start recording invocations into a circular buffer; resets buffer
    historyOff(rule) Stop recording (buffer is preserved)
    historyOnAll(size?) Start recording on all rules
    historyOffAll() Stop recording on all rules
    showHistory(rule) Print the recorded buffer for this rule

    All functions accept a rule name (string), numeric ID, or the rule object itself.

    Posted (edited)

    Jan I am playing but what ever I do the light does't shine over me.

     

     

    Please login or register to see this code.

     

    Edited by Sjakie
    Fibaro.call
    Posted (edited)

    I have been able to load the version 1.13 into my HC3 but QA crashes with the following error:

    [26.05.2026] [20:44:00] [DEBUG] [QUICKAPP767]: EventRunner 7, v0.1.13

    [26.05.2026] [20:44:00] [ERROR] [QUICKAPP767]: QuickApp crashed

    [26.05.2026] [20:44:00] [ERROR] [QUICKAPP767]: rule.lua:691: attempt to index a nil value (upvalue 'vm')

    I have not been able to understand why...

    Edited by Christb
  • Topic Author
  • Posted
    2 hours ago, Christb said:

    I have been able to load the version 1.13 into my HC3 but QA crashes with the following error:

    [26.05.2026] [20:44:00] [DEBUG] [QUICKAPP767]: EventRunner 7, v0.1.13

    [26.05.2026] [20:44:00] [ERROR] [QUICKAPP767]: QuickApp crashed

    [26.05.2026] [20:44:00] [ERROR] [QUICKAPP767]: rule.lua:691: attempt to index a nil value (upvalue 'vm')

    I have not been able to understand why...

    13 is an unlucky number. Try 0.1.14

    The error was the order that the QA files are loaded - I didn't see that I had a dependency on the load order and I was always lucky - but you didn't on your HC3.... Anyway, I fixed that now so it should work. Thanks for the patience.

    • Like 1
  • Topic Author
  • Posted
    12 hours ago, Sjakie said:

    Jan I am playing but what ever I do the light does't shine over me.

     

     

    Please login or register to see this code.

     

    I need more info. I assume ER7? You need to tell me 6 or 7 as they do have different implementations.

     

    This works: rule("@19:38 | 178:breached => 496:on")
    This makes no sense: fibaro.call(keuken.Keuken_Spots,"turnOn","Energie");
    turnOn don't take "Energie" as argument.

    I see you load HT. Do you also set it up as variables? I.e..

    local var = er.variables
    for k,v in pairs(HT) do var[k] = v end
    ?

    Posted (edited)

    Okay fixed my error.

    Please login or register to see this code.

    give error

    Please login or register to see this code.

    Please login or register to see this code.

     

    Please login or register to see this code.

     

    Edited by Sjakie
    Eventrunner fade and dim error
    Posted

    Hello everyone,
    I have been using ER5 for many years now. It works great for me. Now I would like to switch to ER7.
    In ER5, I have the following function:

    Please login or register to see this code.

     

    Can I use this in ER7 as well? I can't seem to find the right way to implement it.

     

    Another Question:
    I use 

    Please login or register to see this code.

    Is it no longer possible to create rules with "||...." in ER7?

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

    Okay fixed my error.

    Please login or register to see this code.

    give error

    Please login or register to see this code.

    Please login or register to see this code.

     

    Please login or register to see this code.

     

    triggerVariables is named triggerVars.
    local triggerVar = er.triggerVars

    The way to patch in setProps commands are not in ER7 in this way.
    You need to do
     

    Please login or register to see this code.

     

  • Topic Author
  • Posted (edited)
    1 hour ago, KaWi said:

    Hello everyone,
    I have been using ER5 for many years now. It works great for me. Now I would like to switch to ER7.
    In ER5, I have the following function:

    Please login or register to see this code.

     

    Can I use this in ER7 as well? I can't seem to find the right way to implement it.

     

    Another Question:
    I use 

    Please login or register to see this code.

    Is it no longer possible to create rules with "||...." in ER7?

    stdProps is a bit different...

    Please login or register to see this code.


    The ||>> construct requires case ... end around it (ER6 and ER7)

    Please login or register to see this code.



     

    Edited by jgab
    Posted

    Thanks for the quick reply 😀.
    Unfortunately, I'm getting an error with the function:

    Please login or register to see this code.


     

    Please login or register to see this code.

     

    Posted

    Jan where to place?

    " {name="Badkamer__Vrij"};"

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    49 minutes ago, KaWi said:

    Thanks for the quick reply 😀.
    Unfortunately, I'm getting an error with the function:

    Please login or register to see this code.


     

    Please login or register to see this code.

     

    Sorry, fixed in previous post. It's not a function def, just a call to er.addStdProp

    28 minutes ago, Sjakie said:

    Jan where to place?

    " {name="Badkamer__Vrij"};"

    Please login or register to see this code.

     

    I don't know/understand. What do you want to accomplish?

    • Like 1
    Posted

    Sorry I want to name that rule as in:

    Please login or register to see this code.

     

  • Topic Author
  • Posted (edited)

    🔧 EventRunner7 — Adding a Custom Device Property with er.addStdProp

    EventRunner7 comes with a set of built-in device properties you can use in rule conditions, such as value, batteryLevel, dead, and so on. If you need to use a property that is not built-in — for example a sensor's lastBreached timestamp — you can register it yourself with er.addStdProp.

    Once registered, the new property works exactly like the built-in ones: you can read it, trigger on its changes, and use it with multiple device IDs.

    Basic syntax

    Please login or register to see this code.

    The definition table fields:

    • trigger — the HC3 event that fires when the property changes. Usually {type='device', property='...'}.
    • get — called when the rule reads the property value. Receives the definition table and the device id.
    • set — called when the rule assigns a value to the property. Optional.
    • reduce — aggregation function used when the rule references a list of device IDs. table.mapF returns a list of values, table.mapOr returns true if any are true, table.mapAnd returns true if all are true. Optional.
    • setCmd — alternative HC3 action name to use for set. Optional.

    Register the property inside your main(er) callback or in a module with a negative priority (so it is available before rules are compiled).

    Example 1 — reading a sensor timestamp

    Many Fibaro sensors expose a lastBreached property that records the last time they were triggered. It is not a built-in ER7 property, but you can add it:

    Please login or register to see this code.

    The rule fires whenever the HC3 fires a device event with property='lastBreached' for device 42. The getfunction is called when the rule reads 42:lastBreached inside the action.

    Example 2 — a boolean wrapper property

    The built-in value property of a dimmer is a number (0–99). If you want to react to "is the light on or off" as a boolean, you can add a custom property: (note, :isOn is already defined, in a similar way)

    Please login or register to see this code.

    Example 3 — a writable property

    You can also register a set function to allow writing from a rule:

    Please login or register to see this code.

    When to use addStdProp vs a custom PropObject

    addStdProp is the right tool when you are working with standard device IDs and the HC3 property system. The property is always accessed as <deviceId>:propertyName.

    If you need a reactive variable that is not tied to a numeric device ID — for example a weather object, a third-party API, or any other data source — use a custom PropObject instead. That is covered in a separate post.

    Edited by jgab
  • Topic Author
  • Posted

    🌐 EventRunner7 — Custom Reactive Objects with er.definePropClass

    EventRunner7 lets you create custom reactive objects that can be used in rule conditions just like device properties. These are called PropObjects. Unlike er.addStdProp which extends the built-in device-ID system, a PropObject is a standalone variable that can wrap any data source: the HC3 weather API, a third-party REST service, a virtual sensor — anything you can read from Lua.

    addStdProp vs PropObject — which to use?

    • er.addStdProp — use when you want to add a new property to existing devices. The property is always accessed as <deviceId>:propertyName, e.g. 42:lastBreached. The trigger must be a device event.
    • PropObject — use when the data source is not a numbered device. The object is a named variable, accessed as varName:propertyName, e.g. weather:temp. The trigger can be any HC3 event type (weather, custom-event, global-variable, etc.).

    The four steps

    1. Call er.definePropClass("ClassName") to create the class.
    2. Define an __init method that calls PropObject.__init(self).
    3. Populate the getProp and trigger tables with functions for each property.
    4. Create an instance and store it in er.variables so rules can access it.

    Example — Weather object

    The HC3 has a built-in weather API. Here is how to wrap it as a reactive PropObject with four properties:

    Please login or register to see this code.

    Now you can write rules like this:

    Please login or register to see this code.

    The rule weather:temp < 0 fires every time the HC3 posts a weather event for Temperature. The getProp.temp function is called to read the current value for the condition check.

    Example — Custom REST API object

    PropObjects are not limited to HC3 data. Here is a minimal example wrapping a custom event:

    Please login or register to see this code.

    Adding a set property

    If you want to allow rules to write to a property, add a function to the setProp table:

    Please login or register to see this code.

    Where to define PropObjects

    PropObjects must be defined and instantiated before the rules that use them are compiled. The safest place is in a module with a negative prio value, which runs before your main(er) callback:

    Please login or register to see this code.

    Alternatively, define the PropObject at the start of your main(er) callback, before any rule(...) calls that reference it.

    Summary

    • Use er.definePropClass to create a reactive variable wrapping any data source.
    • Populate getProp, trigger, and optionally setProp tables.
    • Store the instance in er.variables so rules can read and trigger on it.
    • The trigger can be any HC3 event — not just device events.
    • For properties on existing numbered devices, use er.addStdProp instead.
  • Topic Author
  • Posted
    1 hour ago, Sjakie said:

    Sorry I want to name that rule as in:

    Please login or register to see this code.

     

    The same

    Please login or register to see this code.

    Please login or register to see this code.

     

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