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

Guys I noticed also some strange things.

Its or me or the update. I can understand that if I work on the scene an error is my mistake. I am only working on one scene

Suddenly some devices are with error now in other scenesAfter  @FrankT. remark I was restoring back

I am back on 4.54 to be stable again.

For example error >>could not find it copied it in a similar scene error gone!!

Link to comment
Share on other sites

  • Topic Author
  • 12 hours ago, FrankT said:

    @jgab may be it's the heat giving me headache but my scene for blinds does not receive answer from NodeRed anymore. Now I have tested this 

     

      rule("remote(_myNodeRed,#echo{data='test'})")
      rule("#response{data='$d'} => log('Got back:%s',d.data)")
      rule([[remote(_myNodeRed,#wetter{})]])
      rule([[#wetter => moln=env.event.data.clouds;  log('moln= %s',moln)]])

     

    Works ok in ZBS but when running on HC2 there is nothing:

     

    [DEBUG] 16:26:20: NodeRed - EventRunner v2.0 B65
    [DEBUG] 16:26:20: Fibaro software version: 4.550
    [DEBUG] 16:26:20: HC2 uptime: 52 hours
    [DEBUG] 16:26:20: Sunrise 04:54, Sunset 21:36
    [DEBUG] 16:26:20: Hue system inited (experimental)
    [DEBUG] 16:26:20:
    [DEBUG] 16:26:20: Loading rules
    [DEBUG] 16:26:20: Rule:1:#response{data='$d'} => log('Got back:%s',d.data)
    [DEBUG] 16:26:20: Rule:2:#wetter => moln=env.event.data.clouds; log('moln= %s',moln)
    [DEBUG] 16:26:20:
    [DEBUG] 16:26:20: Scene running

     

    Node Red debug shows:

     

    2019-07-25 16:26:21node: Outgoing payloadecho : msg.payload : Object
    object
    args: array[2]
    0: "%7B%22type%22:%22response%22,%22data%22:%7B%22data%22:%22test%22,%22type%22:%22echo%22,%22_from%22:397%7D%7D"
    1: "%%ER%%"
    2019-07-25 16:26:22node: Outgoing eventecho : msg.payload : Object
    object
    type: "response"
    data: object
    data: "test"
    type: "echo"
    _from: 397
    2019-07-25 16:26:23node: Incoming event1echo : msg.payload : Object
    { data: "test", type: "echo", _from: 397 }
    2019-07-25 16:26:24node: Incoming event1wetter : msg.payload : Object
    { type: "wetter", _from: 397 }

     

    Could it be Fibaros new software 4.550?

     

     

    I'm running 4.550 and it's working for me - just tested 'echo'.

    Because it's working on ZBS, could it be that your HC2 has changed IP address? Or have you changed name/password?

    Have you checked the HC2 node in the node-red flow? Mine look like below.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • 7 hours ago, Sjakie said:

    Guys I noticed also some strange things.

    Its or me or the update. I can understand that if I work on the scene an error is my mistake. I am only working on one scene

    Suddenly some devices are with error now in other scenesAfter  @FrankT. remark I was restoring back

    I am back on 4.54 to be stable again.

    For example error >>could not find it copied it in a similar scene error gone!!

     

    So it's worked fine for me with 4.550 (knock on wood) but you guys are all running much more advanced ER scenes than I do these days... ;)

    In any case, I do keep an eye on if the Lua environment seems to change between releases, and fortunately Fibaro is very slow to make changes to

    the basic Lua framework. Much more likely then that devices start to act up in various ways. More likely then ER's logic starting to fail due to a new release.

    On my todo list is to build up a more extensive test set of rules (a test scene) to run on the HC2 to verify the logic. Now I only run some on the ZBS.

    Link to comment
    Share on other sites

    Hello Jan,

    IOS locator did not work for me in 4.55

    Since update I did not see the disarm by IPhone.

    This morning I was pleasant surprised to see in debug "disarmed by IPhone" I will keep track of it.

    Link to comment
    Share on other sites

    Checked IP, name/password in HC2 node - all ok. Rebooted PI running NR, influx and Grafana. Rebooted HC2. Rebooted PC running ZBS, Firefox. Working now, really mysterious.

    Link to comment
    Share on other sites

  • Topic Author
  • During my "vacation" I have enjoyed myself with a rewrite of EventRunner. I have not released it yet and I will probably need some

    parallel release model so you can continue with the old version. Because even if I'm trying to test everything I may have introduced new bugs....

    A release like EventRunner3.lua will appear next week (It's version 3) and I will announce it and hope some of you will try it out.

     

    Main changes

    - Restructured the code so it is more modular

    - Re-written the parser and compiler for EventScript

    - New runtime for EventScript "code" based on a home-made coroutine implementation. 

     

    Most of old EventScript rules will work as is, but there are a few changes.

    - 'for' ... 'repeat', has changed to 'trueFor' ... 'again'.

    Please login or register to see this code.

    needs to be changed to  

    Please login or register to see this code.

     

    - :armed will return true/false and be set with true/false.

    Please login or register to see this code.

     needs to be changed to  

    Please login or register to see this code.

     

    There are some new EventScript functions and commands:

    -- dusk and dawn, works like sunset/sunrise.

    Please login or register to see this code.

    -- if-then-elseif-end. (|| >> still exist)

    Please login or register to see this code.

     

    - while-do end, and repeat-until

    Please login or register to see this code.

    - for-do

    Please login or register to see this code.

     

    - Rule local variables. In the past, all ER variables where shared between all rules. Variables not declared local are shared as before.

    Please login or register to see this code.

      will print 60 and then print 30. All rules have an implicit begin-end (local block) around them. 

      for-do, while-do, repeat-until, and if-then-else have local blocks so iteration variables and local declaration stay in scope like "normal" programming languages.

     

    - Lua "object oriented" function calls supported.

    Please login or register to see this code.

      <name>:<name>(...) is assumed to be a object oriented function call. <name>:<name> is a property call like before

     

    - New function 'pack' that captures multiple return values

    Please login or register to see this code.

     

    The new runtime for EventScript code allows for future interesting extension. Already now, making async functions synchronous is very easy.

    Please login or register to see this code.

    So, the Lua function 'foo' that gets called from the EventScript returns {['<cont>'],fun}. The runtime will then call the fun with a continuation (thanks to the coroutine implementation) that 'foo' will call with the result when finished (here after 5 seconds), and the runtime will continue executing from that point with the value returned (which is here given to 'log' and printed)

    The advantage with this is that we can functions calling handlers in other scenes without having to post an event and wait for the returned event. We can hide that now in something that looks like a synchronous function call... more to come on that topic :-) 

     

    Hopefully some improvements on error handling making it a bit easier to understand what have gone wrong when an error occurs.

    Lots of small bugs where detected and corrected - some that impact the HC2 emulator too so it will also have a new release.

    • Like 1
    Link to comment
    Share on other sites

    Hello Jan,

     

    Thanks for your effort and looking forward to go with the new flow.

    Link to comment
    Share on other sites

    Good morning Jan,

    I am a bit lost. See this message for the first time. Later on it is executed, see debug in yellow!!

    Now I also get the next error>>this cases the light is not switched off.

     

    Please login or register to see this attachment.

    Please login or register to see this attachment.

     

     Rule.eval("for(00:05, woonkamer.televisie:power < 15) => log('TV off, power is now %s',woonkamer.televisie:power); woonkamer.televisie:off; log('TV uit indien hij 5 min op standbye staat')").start()

     

    Disregard the other error message>> I am playing with it (hue rechts was marked with --)

     

    Please advice

     

    Link to comment
    Share on other sites

  • Topic Author
  • 42 minutes ago, Sjakie said:

    Good morning Jan,

    I am a bit lost. See this message for the first time. Later on it is executed, see debug in yellow!!

    Please login or register to see this attachment.

     Rule.eval("for(00:05, woonkamer.televisie:power < 15) => log('TV off, power is now %s',woonkamer.televisie:power); woonkamer.televisie:off; log('TV uit indien hij 5 min op standbye staat')").start()

    Please advice

     

    Yes, it's indeed strange. Actually, it doesn't seem like it's the "televisie" rule that is the problem. The error message complains about doing <deviceID>:on where <deviceID> is nil. I don't understand why it points at the "televisie" rule that doesn't have any :on command (only :off)...  Do you have any rule nearby that does <deviceID>:on ?

    Link to comment
    Share on other sites

  • Topic Author
  • Ok, I have uploaded EventRunner3.lua to GitHub. It can exist in parallell with the old version and will auto-update only v3 version.

    There are some changes to make old rules run.

    • "for - repeat", need to be changed to "trueFor - again"
    • <deviceID>:armed returns true/false instead of '0'/'1'. And is set to true/false to arm and disarm
    • A bit changed Node-red flow. All events from node-red arrives as {type='NODERED', value=<event>}. To be compatible in the old EventRunner just add
      Rule.eval("#NODERED{value='$val'} => post(val)"). In EventRunner3 that is the default behaviour. However, we need the 'NODERED* wrapper to catch synchronous nodered calls (see below).

    New node-red flow

    Please login or register to see this spoiler.

     

    New stuff:

    • dawn/dusk. Like sunrise/sunset but the time it actually gets light and when it actually gets dark. It Stockholm it's now almost an hour difference.

      Please login or register to see this code.

       

    • function nodered(<event>[,<req>,<node>]). Sends event to node-red. Uses local _defaultNodeRed as node but can be provided as third argument <node>. If <req> is false or excluded it just sends a standard asynchronous event to node-red as with 'remote' in the past. With <req> set to true it will return the resulting event synchronously...

      Please login or register to see this code.

      #echo returns {type='response', data={test='Hello'}}. With <req> set to true nodered(...) will return that event. And we access the test field with .data.test. This means that we hide the asynchronous nature of communicating with node-red and make it look like calling regular functions that returns values.
      Only set <req> to true if the nodered flow returns an event, otherwise you will get a timeout error.

    • if-then-else-elseif-end. if-then-else is a statement and can only be used on the right-hand side of rules.

    • repeat <statements> until <test>. Statement and can only be used on the right-hand side of rules.

    • while <test> do <statements> end. Statement and can only be used on the right-hand side of rules.

    • local variables in rules. Temporary variables only active when rule executes.

    • capture of multiple values from lua functions returning multiple values using function pack().
       

      Please login or register to see this code.

    • Calling of  "object oriented" lua functions using ':'. Mostly useful for calling fibaro functions (see previous example).
    • Auto conversion of values from fibaro globals. 
      If a fibaro global is set to the strings "true"/"false"/"True"/"False"/"TRUE"/"FALSE" it will automatically be converted to a boolean when accessed. If it contains a time string ex. "10:00" it will be converted to number of seconds. Otherwise it will return just the string.

      Please login or register to see this code.

    • Oh, and please update to the latest HC2.lua if trying it out on ZBS. You may need to regenerate the HC2.data file. (complaining about 'settings/network' missing)

     

    Things to do.

    • provide a synchronous httprequest function similar to nodered (like it works in VDs)
    • improve error messages
    • more test-cases

     

    Edited by jgab
    • Like 1
    Link to comment
    Share on other sites

  • Topic Author
  • 35 minutes ago, jompa68 said:

    @jgab you have an working example of and puslish rule?

    Please login or register to see this code.

     

    I need more info on what you want to achieve. 

    You publish the virtual sensor from one scene and subscribe to it from another scene. What else would you like it to do?

    Link to comment
    Share on other sites

    2 minutes ago, jgab said:

    I need more info on what you want to achieve. 

    You publish the virtual sensor from one scene and subscribe to it from another scene. What else would you like it to do?

    Yes, pub/sub to turn on/off devices

    or is it better just the normal way?

    got an error now in ZBS on first publish rule 

    Edited by jompa68
    Link to comment
    Share on other sites

  • Topic Author
  • 2 minutes ago, jompa68 said:

    Yes, pub/sub to turn on/off devices

    or is it better just the normal way?

     So it's not a "real" fibaro device? A fake device (Event._registerID) ? A wrapper for some node-red accessed device?

    Edited by jgab
    Link to comment
    Share on other sites

    Hello Jan,

    I will try!

    IOSLocator

    I came home at 11:55 No post

    Please login or register to see this attachment.

    If I change something in the scene and save it will post.

    Please login or register to see this attachment.

    Please advice,

     

    Link to comment
    Share on other sites

  • Topic Author
  • Just now, jompa68 said:

    No, a real device

    But I guess you can just call <deviceID>:off from the subscribing scene then? or fibaro:call(<device>,"turnOff"). or?

    If you i the subscribing scene do

    rule("#VirtualSensor{deviceID='$deviceID',value='$value'} => post($property{deviceID=deviceID,value=value,propertyName='value'})")

    you should be able to do

    rule("pirSensor.hallNere:breached => log('Sensor breached')")

    Link to comment
    Share on other sites

    2 minutes ago, jgab said:

    But I guess you can just call <deviceID>:off from the subscribing scene then? or fibaro:call(<device>,"turnOff"). or?

    If you i the subscribing scene do

    rule("#VirtualSensor{deviceID='$deviceID',value='$value'} => post($property{deviceID=deviceID,value=value,propertyName='value'})")

    you should be able to do

    rule("pirSensor.hallNere:breached => log('Sensor breached')")

    try to explain better, sorry for lack of info.
    This is the error i get in ZBS, only started with my first V3 scene (publish scene)

    Please login or register to see this code.

     

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