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



jgab

Recommended Posts

  • Topic Author
  • 2 hours ago, ChristianSogaard said:

    Hi Jan
    I started playing with you new project, it looks great.

    Would it support the hierarchy as EV4 ?

    Please login or register to see this code.

    QuickApp:main gets an argument 'er' that is a table with the functions. You need to pass that to the modules. Look how it's done in the beginning of QuickApp:main(er)...

     

    2 hours ago, ChristianSogaard said:

    When i press the "list rules" button , i dont see any of my rules (i copied a few from my EV4) and the same when saving the rules.

    Please login or register to see this code.

     

    [11.11.2023] [12:08:07] [TRACE] [QUICKAPP1961]: UIEvent:  {"values":[],"eventType":"onReleased","deviceId":1961,"elementName":"listRules"}
    [11.11.2023] [12:08:07] [TRACE] [QUICKAPP1961]: Posting {"type":"UI","cmd":"listRules"} at Sat Nov 11 12:08:07 2023 
    [11.11.2023] [12:08:08] [TRACE] [QUICKAPP1961]: UIEvent:  {"values":[],"eventType":"onLongPressReleased","deviceId":1961,"elementName":"listRules"}
    [11.11.2023] [12:08:08] [TRACE] [QUICKAPP1961]: Posting {"type":"UI","cmd":"listRules"} at Sat Nov 11 12:08:08 2023

     

    Should rules have the log added like     rule("log('Wind is %sms',weather:wind)",msgOpts)

    What's new with ER5 is that it logs system messages under ER<ID>, so look at console tag ER1961...

    (it is configurable to have all under the same tag)

    • Like 1
    Link to comment
    Share on other sites

    2 hours ago, ChristianSogaard said:

    Hi Jan
    I started playing with you new project, it looks great.

    Would it support the hierarchy as EV4 ?

    Please login or register to see this code.

     

    When i press the "list rules" button , i dont see any of my rules (i copied a few from my EV4) and the same when saving the rules.

    Please login or register to see this code.

     

    [11.11.2023] [12:08:07] [TRACE] [QUICKAPP1961]: UIEvent:  {"values":[],"eventType":"onReleased","deviceId":1961,"elementName":"listRules"}
    [11.11.2023] [12:08:07] [TRACE] [QUICKAPP1961]: Posting {"type":"UI","cmd":"listRules"} at Sat Nov 11 12:08:07 2023 
    [11.11.2023] [12:08:08] [TRACE] [QUICKAPP1961]: UIEvent:  {"values":[],"eventType":"onLongPressReleased","deviceId":1961,"elementName":"listRules"}
    [11.11.2023] [12:08:08] [TRACE] [QUICKAPP1961]: Posting {"type":"UI","cmd":"listRules"} at Sat Nov 11 12:08:08 2023

     

    Should rules have the log added like     rule("log('Wind is %sms',weather:wind)",msgOpts)

    Thank you

    I created the "import" in the main section


    Please login or register to see this attachment.

     

    Reused a working rule from main in a new section, DaySchedule

     

    Please login or register to see this attachment.

     

    I dont this there is any typos, but getting a Rule setup error(s) - fix & restart...

    Please login or register to see this attachment.

     

     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 17 hours ago, ChristianSogaard said:

    Thank you

    I created the "import" in the main section


    Please login or register to see this attachment.

     

    Reused a working rule from main in a new section, DaySchedule

     

    Please login or register to see this attachment.

     

    I dont this there is any typos, but getting a Rule setup error(s) - fix & restart...

    Please login or register to see this attachment.

     

     

     

     

    Yes, there is no evalScript function anymore. There is 'eval' and 'rule' that are synonyms with 'evalScript'.

    If you have many rules with evalScript you can just do

    local evalScript = rule

    in the beginning of main

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    1 hour ago, jgab said:

    Yes, there is no evalScript function anymore. There is 'eval' and 'rule' that are synonyms with 'evalScript'.

    If you have many rules with evalScript you can just do

    local evalScript = rule

    in the beginning of main

    Please login or register to see this code.

     

    I dont think i use evalScript - my goal was to make the different sections to work as i have in EV4, reusing the old syntax seems to give some issues

    Please login or register to see this attachment.

     

    Edited by ChristianSogaard
    Typo
    Link to comment
    Share on other sites

  • Topic Author
  • Change this
     

    Please login or register to see this code.

     

    to

     

    Please login or register to see this code.

     

    and then in the for loop when you call the modules

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    Jan, on restart Qa I used this but in ER5 it does't work anymore.

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 43 minutes ago, Sjakie said:

    Jan, on restart Qa I used this but in ER5 it does't work anymore.

     

    Please login or register to see this code.

     

    Do you get an error message? Can you see in QA 267 log if it gets an ‘onAction’ ?

    Link to comment
    Share on other sites

    Jan does't work in ER5

    Please login or register to see this code.

    I don't think it is working at all if I create a scene with push it does't generate message either.

    Edited by Sjakie
    added info push msg
    Link to comment
    Share on other sites

  • Topic Author
  • 2 hours ago, Sjakie said:

    Jan does't work in ER5

    Please login or register to see this code.

     

    Both fibaro.call and fibaro.alert you can help debug yourself by trying them out in Lua outside the rules.

    Check if

    Please login or register to see this code.

    and

    Please login or register to see this code.

    works in Lua. If it works outside but not inside rule() then its a bug.

    However, for me in ER5 it works both inside and outside rules - so check your user id's and that you can receive push messages at all from Fibaro...

     

    ...and why do fibaro.alert?

    It's the same as

    user:msg = '1061 - Let Op; Voordeur - OPENNNNNNNNN -'

    Link to comment
    Share on other sites

    Hi Jan

    i have some issue for migrating this start up rule

    Rule are compiled, but i dont get the trigger after reboot. to be honest, im not sure at it ever worked, 
    How can i post the the result of this line or ?
        if os.time() - (api.get("/settings/info").serverStatus or 0) < 60 then self:post({type='se-start'}) end

    i tried    

    rule("log(os.time() - (api.get("/settings/info").serverStatus or 0))")

    rule("log(api.get('/settings/info').serverStatus")

    and a few more versions, but no cigar

     

    Or did you come up with an alternative way to verify a reboot ?

     

    Please login or register to see this code.

     

    Edited by ChristianSogaard
    Typo
    Link to comment
    Share on other sites

    Jan, shoot me!

    On my wifes phone she receives push messages (as default switched off)

    You are right its me. I reverted back to ER4 and there the same problem. In my phone it's enabled.

     

     

    Telegram I receive but only one scene if HC3 restarts.

    Link to comment
    Share on other sites

    Jan, push messages does't work on my phone anymore.

    I checked my wifes phone and she receive them without any problem.

    Telegram at re-start I fixed with test3 followed by a message

    Link to comment
    Share on other sites

  • Topic Author
  • Settings and options

     

    The structure of the main file in ER5 is like

    Please login or register to see this code.

    Our QuickApp's :onInit() function will create the EventRunner "engine" that knows how to define and run rules.

    When the engine is setup and ready it calls our provided callback function and hands it a variable 'er'.

    The 'er' variable is important because it's a Lua table with important functions and variables we will need when

    setting up our rules.

     

    In the callback we can then setup general/global settings and debug preferences and other stuff.

    ...and then finish by calling self:main(er)

     

    So, the simple approach is to have all our rule definitions in QuickApp:main(er), but we can put rule definitions them in other QA files to.

    Ex. if we define a QA file 'u_myrules' (name is not important but u_ prefix is required)

    we can then define our "module" like this

    Please login or register to see this code.

    and the rule(seller) function will be called in the priority order we specified (lower priority called first)

    Per default, the QuickApp:main(er) function has priority 0 so we can load modules before by giving them priority < 0.

    We can also leave out QuickApp:main(er) and only load rules from our own modules. In this way we can keep the main QA file untouched and make it easier to upgrade the main file (it needs to be upgraded "manually" as the QAUpdater don't touch the main file)

     

    So, there are a lot of settings and debug flags we can set

     

    Global debug flags that can be overridden by individual rules using ruleOptions 

    er.debug.ruleTrigger = false -- log rules being triggered

    er.debug.ruleTrue = true -- log rules with condition succeeding

    er.debug.ruleFalse = true -- log rules with condition failing

    er.debug.ruleResult = false -- log results of rules running

    er.debug.evalResult = true -- log results of evaluations

    er.debug.post = true -- log events being posted

    er.debug.sourceTrigger = false -- log incoming sourceTriggers

    er.debug.refreshEvents = false -- log incoming refreshEvents

     

    Global settings - affects EventRunner behaviour in general

    er.settings.marshall = true -- autoconvert globalVariables values to numbers, booleans, tables when accessed

    er.settings.systemLogTag = "ER"..self.id -- log tag for ER system messages, defaults to __TAG

    er.settings.ignoreInvisibleChars = false -- Check code for invisible characters (xC2xA0) before evaluating

    er.settings.truncLog = 100 -- truncation of log output

    er.settings.truncStr = 80 -- truncation of log strings

    er.settings.logFibaro = true -- log to fibaro.call, fibero.setVariable, etc.

    er.settings.logApi = true -- log all api.* calls

    er.settings.bannerColor = "orange" -- color of banner in log, defaults to "orange"

    er.settings.listColor = "purple" -- color of list log (list rules etc), defaults to "purple"

    er.settings.statsColor = "green" -- color of statistics log, defaults to "green"

    er.settings.userLogFunction = function(rule,tag,str) return fibaro.debug(tag,str) end -- function to use for user log(), defaults to fibaro.debug if nil

     

     

    The er.settings are global and affect all rules, and so is er.debug.

    However, debug info can also be passed to individual rules together with some other options that can be useful to tailor the behaviour of the rule.

    Please login or register to see this code.

     

    Ex, if we want a rule/expression to always log in green we can define

    Please login or register to see this code.

    The 'silent' option makes the output of rules/expression less noisy. Especially it doesn't log the result of an rule/expression.

    So, ex. typically we may want to run expressions that just output messages in the console when the rules are created.

    Options allow us to silent the extra result logs of these expressions and also give them a distinct color

    Please login or register to see this code.

     

    In fact, we can easily define our own expressions function that just evaluates an expression without noise...

    Please login or register to see this code.

    and use that to evaluate expression and log messages in the console.

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • v0.05 pushed....

    - Lots of bugfixes

    - Alarm handling in place

    - Support for "speed running" ER to debug scheduled rules 

     

     

     

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • Alarm rules

     

    Alarm in the HC3 is implemented by Fibaro using the concept of partitions.

    Partitions are armed and disarmed. Individual devices (typically sensors) belongs to partitions

    and if a devices is breached that belongs to a partition, the partition is breached and we have an alarm.

     

    In ER5 we have properties to query partitions for their state

    <partition>:armed - returns true if the partition is armed - 0 means the house

    <partition>:tryArm - will try to arm the partitions - 0 means the house

    <partition>:isArmed - returns true if the partition is armed - 0 means the house

    <partition list>:isAllArmed - returns true if all partitions are armed

    <partition>:isDisarmed

    <partition list>:isAnyDisarmed - returns true if all partitions is disarmed

    <partition>:isAlarmBreached

    <partition>:isAlarmSafe

    <partition list>:isAllAlarmBreached - returns true if all partitions are breached

    <partition list>:isAnyAlarmSafe - returns true if any partitions is safe

     

    and properties to change the alarm states

    <partition>:armed=true - arms the partition - 0 means the house

    <partition>:armed=false - disarms the partition - 0 means the house

     

    <partition>:tryArm is special as it will try to arm the partition/partitions and if it doesn't succeed because their

    is a breached device in any of the partitions it will post an event that list the partitions and devices that are breached.

    Note that the arming will continue and if not cancelled, the partition will be armed and at the same time breached because of

    the breached devices.

     

    To handle that, one can make a rule that trigger on the posted event,

    Ex:

    Please login or register to see this code.

     

    To trigger a rule if there is a breached partition/home, it's easiest to trigger on the events generated (in the future there may be properties)

    Please login or register to see this code.

     

    Unfortunately, if a partition is armed using the web UI/Yubii app, we don't get any warning from the fibaro api before the partition is armed - maybe in the future...

    Edited by jgab
    Link to comment
    Share on other sites

    Jan, a lot of errors

    Please login or register to see this code.

     

    Edited by Sjakie
    Link to comment
    Share on other sites

  • Topic Author
  • 9 hours ago, Sjakie said:

    Jan, a lot of errors

    Please login or register to see this code.

     

    Yes, need to implement postRemote...

    Do you use 'subscribe' too?

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