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
10 hours ago, jgab said:

 

Ok, so this is specific for ER4.

The QA has a tight loop that reads system events from the /refreshStates api. It transforms some of these events to triggers in a similar format as the sourceTriggers we see in a Scene.'

So, example the event that a binary device with ID 88 has turned on is represented as the trigger (lua table)

{type='device', id = 88, property='value', value=true, old=false}

The loop sends these events into the ER4 rule engine that then run relevant rules etc.

Normally there are a lot of events/triggers generated so the self:enableTriggerType is a function that allow us to filter out triggers that we don't want to send to the ER4 rule engine. By being conservative here we can save some unnecessary computing and this lower the CPU load.

The set of types enabled in your example is an ok standard set of triggers. If you never have any ER rules dealing with alarms you can exclude the "alarm" trigger in the declaration - just to save some CPU cycles.

The types of triggers currently available is best viewed in the QA file Toolbox_triggers.

At the moment they are

Please login or register to see this code.

 

ER allows you to write rules that trigger on these types even if there is no builtin support. For devices that are turned on one can use 88:isOn as a trigger

rule("88:isOn => log('Light 88 turned on')")

However we can also use

rule("#device{id=88,property='value',value=true} => log('Light 88 turned on')")

 

If want to trigger if scene 99 is started we can do

rule("#sceneEvent{id=99,value='started'} => log('Scene 99 just started')")

Note that we need to add "sceneEvent" to self:enableTriggerType or we will not get the trigger.

 

 

If want to trigger if scene 99 is started we can do

rule("#sceneEvent{id=99,value='started'} => log('Scene 99 just started')")

Note that we need to add "sceneEvent" to self:enableTriggerType or we will not get the trigger.

 

=>=>

 

Please login or register to see this code.

 

 

Does this work?

  • Topic Author
  • Posted
    4 hours ago, Earybeongbeong7 said:

     

     

    If want to trigger if scene 99 is started we can do

    rule("#sceneEvent{id=99,value='started'} => log('Scene 99 just started')")

    Note that we need to add "sceneEvent" to self:enableTriggerType or we will not get the trigger.

     

    =>=>

     

    Please login or register to see this code.

     

     

    Does this work?

    Yes

    Posted

    @jgab ?

     

    Heating is uppon us :(  we got struck with 35-37 Celsius , so i figured i move my AC controls over to ER4.

     

    I have some Remotec ZX-120 that control my AC units.

     

    the actions of those devices are:

     

    Actions:%s{"reconfigure":0,"setCoolingThermostatSetpoint":1,"setHeatingThermostatSetpoint":1,"setThermostatFanMode":1,"setThermostatMode":1}
     
    So i made a rule to turn on the AC on Cool mode when solar power is high.
     
    rule("trueFor(00:01:00,(PVFronius:value > 1000 & DanfosRSHolEtajTemp:value > 26)) => (ACScara:setThermostatMode=Cool)")
     
    Conditions are met, but rule returns an error:
     
     in Rule:8[trueFor(00:01:00,(PVFronius:value > -1000 & DanfosRSHolEtajTemp:value > 27)) => ...]: {"msg":"Error executing instruction:'["%setprop",2,false,["setThermostatMode"]]'","ERR":true,"err":"./include/EventRunner.lua:1927: bad property 'setThermostatMode'","src":"Rule:8[trueFor(00:01:00,(PVFronius:value > -1000 & DanfosRSHolEtajTemp:value > 27)) => ...]"}
     
    My LUA scene for this was:
            fibaro.call(ACScara, "setThermostatMode""Cool")
            fibaro.sleep(2000)
            fibaro.call(ACScara, "setCoolingThermostatSetpoint""18")
            fibaro.sleep(2000)
            fibaro.call(ACScara, "setThermostatFanMode""High")
     
    This is basically the LUA i would like to transpose into an ER4 rule (including the sleeps and all)
     
    At this point i am stuck and need your precious help :) 
     
    Cheers:)
     
  • Topic Author
  • Posted
    12 minutes ago, Momos said:

    @jgab ?

     

    Heating is uppon us :(  we got struck with 35-37 Celsius , so i figured i move my AC controls over to ER4.

     

    I have some Remotec ZX-120 that control my AC units.

     

    the actions of those devices are:

     

    Actions:%s{"reconfigure":0,"setCoolingThermostatSetpoint":1,"setHeatingThermostatSetpoint":1,"setThermostatFanMode":1,"setThermostatMode":1}
     
    So i made a rule to turn on the AC on Cool mode when solar power is high.
     
    rule("trueFor(00:01:00,(PVFronius:value > 1000 & DanfosRSHolEtajTemp:value > 26)) => (ACScara:setThermostatMode=Cool)")
     
    Conditions are met, but rule returns an error:
     
     in Rule:8[trueFor(00:01:00,(PVFronius:value > -1000 & DanfosRSHolEtajTemp:value > 27)) => ...]: {"msg":"Error executing instruction:'["%setprop",2,false,["setThermostatMode"]]'","ERR":true,"err":"./include/EventRunner.lua:1927: bad property 'setThermostatMode'","src":"Rule:8[trueFor(00:01:00,(PVFronius:value > -1000 & DanfosRSHolEtajTemp:value > 27)) => ...]"}
     
    My LUA scene for this was:
            fibaro.call(ACScara, "setThermostatMode""Cool")
            fibaro.sleep(2000)
            fibaro.call(ACScara, "setCoolingThermostatSetpoint""18")
            fibaro.sleep(2000)
            fibaro.call(ACScara, "setThermostatFanMode""High")
     
    This is basically the LUA i would like to transpose into an ER4 rule (including the sleeps and all)
     
    At this point i am stuck and need your precious help :) 
     
    Cheers:)
     

    Ok, they didn't exist as ER4 commands.

    I pushed v0.5fix62 with new commands:

    Please login or register to see this code.

    Bit unsure if you need to quote number values like '18' or it is ok with 18.

    You need to stringify 'Cool' etc as they are sent as strings. Without quotes, ER will interpret Cool as a variable (that is probably nil)

     

    For actions I don't support yet you can use the fibaro call in the rule...

    Ex.

    rule("trueFor(00:01:00,(PVFronius:value > 1000 & DanfosRSHolEtajTemp:value > 26)) => fibaro.call(ACScara,'setThermostatMode','Cool')")

    ...and then tell me to implement it as a :command.

     

     

    Posted (edited)
    2 hours ago, jgab said:

    rule("trueFor(00:01:00,(PVFronius:value > 1000 & DanfosRSHolEtajTemp:value > 26)) => fibaro.call(ACScara,'setThermostatMode','Cool')")

    ...and then tell me to implement it as a :command.

    Super:) works !

     

    Then can you please implement the following commands:

    setCoolingThermostatSetpoint

    setHeatingThermostatSetpoint

    setThermostatFanMode

    setThermostatMode

     

    And the interfaces:

    Please login or register to see this code.

    So we can use something like 

    ACScara:thermostatMode~='Cool'
     

    Thank you :) 

    Edited by Momos
    Posted

    Jan,  what do I miss?

    Please login or register to see this code.

    Despite the hal.voorDeur is open, see debug!! it will secure the lock

     

    If change in:

    Please login or register to see this code.

    It will work according the rule

    Please login or register to see this attachment.

    Thanks for your time and efford!

    //Sjakie

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

    Jan,  what do I miss?

    Please login or register to see this code.

    Despite the hal.voorDeur is open, see debug!! it will secure the lock

     

    If change in:

    Please login or register to see this code.

    It will work according the rule

    Please login or register to see this attachment.

    Thanks for your time and efford!

    //Sjakie

    Well, in the first. example you test if door is closed and then you wait 15 min before securing. Are you sure that no one opens the door in that period?

    The second example makes sure that the door is closed during  a time period of 15 min. (trueFor), then it. secures the door and prints the logs.

    Posted

    Jan

    Yes I had some probs lock closes if door was open is explained now by you..

    No problem now it checks if door is closed "x"time, more secure rule.

    Another error if I may:

    Please login or register to see this code.

    //Sjakie

     

     

    Posted
    On 5/2/2021 at 5:08 PM, jgab said:

    However, it should throw an error message - I will fix that in the next version.

    Hi Jan

     

    I tried to finalize my extractor hood automation i started on long time ago

    Im still using

     

    Please login or register to see this code.

     

    I want to be able to using the variables extractor_step and extractor_light for other places in this EV4. Also as triggers. 

    Examble, i want to open my Velux window a little when my extractor_step is 3 or 4.

     

    So first neither my log command or trigger of the rule seems to work - i dont see the [true] for rule 17 .

    Please login or register to see this code.

     

    second i know i need the use the post (# command to create a new trigger, bot at the same time i want the post trigger to contain the value of light is on or off or what step the extractor is running.

     

    I could use some assistance here :-)

     

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

    Hi Jan

     

    I tried to finalize my extractor hood automation i started on long time ago

    Im still using

     

    Please login or register to see this code.

     

     

    You need  to add an extra ';' at the end of the || >> sequence. to break it.

    Please login or register to see this code.

    otherwise the log will only belong to the last test.  This is because the action. after >> can be a sequence of actions delimited with. ';'.

     

    Secondly, you can't declare extractor_step. and extractor_light local, because then ER can't. use them inside the rules.

    Make them Lua globals (remove local)

    Actually, in this case they will become ER variables as they will be created when not found.

     

    I don't see why your rule doesn't trigger.

    You have listed self:enableTriggerType({"device"} ?

    Do you have other device ID rules that do work in the QA?

     

    Instead of declaring them as lua variables, you can declare them as trigger variables and they can be used to trigger rules when they  change values.

    Please login or register to see this code.

     

     

    • Like 1
    Posted (edited)
    1 hour ago, jgab said:

     

    You need  to add an extra ';' at the end of the || >> sequence. to break it.

    Please login or register to see this code.

    otherwise the log will only belong to the last test.  This is because the action. after >> can be a sequence of actions delimited with. ';'.

     

    Secondly, you can't declare extractor_step. and extractor_light local, because then ER can't. use them inside the rules.

    Make them Lua globals (remove local)

    Actually, in this case they will become ER variables as they will be created when not found.

     

    I don't see why your rule doesn't trigger.

    You have listed self:enableTriggerType({"device"} ?

    Do you have other device ID rules that do work in the QA?

     

    Instead of declaring them as lua variables, you can declare them as trigger variables and they can be used to trigger rules when they  change values.

    Please login or register to see this code.

     

     

    Yes - i'm using 


    function QuickApp:main()    -- EventScript version
      local rule = function(...) return self:evalScript(...) end          -- old rule function
      self:enableTriggerType({"device","global-variable","custom-event","profile"}) -- types of 

     

    It still dont trigger.

    I see the trigger come in - but the rule dont trigger

    Please login or register to see this code.

     

    Edited by ChristianSogaard
    P
  • Topic Author
  • Posted (edited)

    Please login or register to see this code.

     

    Edited by jgab
    Posted
    50 minutes ago, ChristianSogaard said:

    Yes - i'm using 


    function QuickApp:main()    -- EventScript version
      local rule = function(...) return self:evalScript(...) end          -- old rule function
      self:enableTriggerType({"device","global-variable","custom-event","profile"}) -- types of 

     

    It still dont trigger.

    I see the trigger come in - but the rule dont trigger

    Please login or register to see this code.

     

     

    I see the rule triggers (I had POST disabled in the GUI)- it seems that for rules like "rule([[#device{id=extractor_hood,value='$value'}" you dont see the [true]>>'RuleX in the log

    Also the 

        || value < 500 & value > 225  >> extractor_step=4; extractor_light = 1;;
        log(extractor_step..' '..extractor_light);

     

    i only see the POST for that thing (Step or light) that changed in the post and not both, that might just be the behavior, but when posting both, i would assume both to be posted?.

     

    [27.06.2021] [09:09:12] [TRACE] [QUICKAPP1256]: Posting {"type":"variable","value":0,"name":"extractor_light"} at [Timer:09:09:12]

     

    Please login or register to see this code.

     

    Posted (edited)
    11 minutes ago, jgab said:

    Please login or register to see this code.

     

    Only see rule 4 & 5 being triggered

    Please login or register to see this spoiler.

     

    Edited by ChristianSogaard
    P
  • Topic Author
  • Posted
    2 minutes ago, ChristianSogaard said:

    Only see rule 3 & 4 being triggered

    Please login or register to see this spoiler.

    Ah, because it's power and not value...

    rule("1129:power => ...

    should work. Anyway, the #device rules worked and that was what we wanted to confirm.

    • Like 1
    Posted
    1 minute ago, jgab said:

    Ah, because it's power and not value...

    rule("1129:power => ...

    should work. Anyway, the #device rules worked and that was what we wanted to confirm.

    Yes - works - [27.06.2021] [09:36:35] [TRACE] [QUICKAPP1256]: 1 - 1129 value:true

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

     

    I see the rule triggers (I had POST disabled in the GUI)- it seems that for rules like "rule([[#device{id=extractor_hood,value='$value'}" you dont see the [true]>>'RuleX in the log

     

    Ok, will have to look into that.

     

    The trigger variables are only posted if the values changes.  If you always want to trigger on it, make. a post

    Please login or register to see this code.

     

    • Like 1
    Posted
    17 minutes ago, jgab said:

     

    Ok, will have to look into that.

     

    The trigger variables are only posted if the values changes.  If you always want to trigger on it, make. a post

    Please login or register to see this code.

     

    Getting better now :-) BUT... still having an error

    in Rule:1[#device{id=extractor_hood,value='$value'} =>...]: {"msg":"Error executing instruction:'["%betw",2]'","ERR":true,"err":"./include/EventRunner.lua:1930: Bad arguments to between '...', ' ' '0'","src":"Rule:1[#device{id=extractor_hood,value='$value'} =>...]"}
     

     

    Please login or register to see this spoiler.

     

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

    Getting better now :-) BUT... still having an error

    in Rule:1[#device{id=extractor_hood,value='$value'} =>...]: {"msg":"Error executing instruction:'["%betw",2]'","ERR":true,"err":"./include/EventRunner.lua:1930: Bad arguments to between '...', ' ' '0'","src":"Rule:1[#device{id=extractor_hood,value='$value'} =>...]"}
     

     

    Please login or register to see this spoiler.

    You could also do

    log('%s %s',extractor_step,extractor_light);

    • Thanks 1
    Posted (edited)
    46 minutes ago, jgab said:

     '..' is for testing time intervals. Use '++' to concatenate strings.

    Please login or register to see this code.

     

    Hi Jan

     

    I seems that the ´;;´dont work - the two last lines only work when || value < 500 & value  line is hit

     

        || value < 500 & value > 225  >> extractor_step=4; extractor_light = 1;;
        post(#Extractor{step=extractor_step,light=extractor_light});
        log(extractor_step++' '++extractor_light);

     

     

    Edited by ChristianSogaard
    P

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