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
  • Just uploaded a new feature in the EventRunner framework to help with debugging scenes.

    If you run in ZeroBrane and in the 'Project' menu chose Lua interpreter to 'Lua', which means Lua 5.1, we have access to a window library (wxWidget).

    Then we can set the '_GUI' global var in EventRunner to 'true', and the framework parses the trigger declarations in the header of scene and creates a GUI window that allows us to chose events that are posted to the scene. 

    Ex.

    Please login or register to see this code.

    when we run this a window opens that look like this:

    Please login or register to see this image.

    /monthly_2018_12/TRIGGPNG3.png.897d3b5f33a7af222e85dbb6d01a1f99.png" />

    ..and if we double-click on a trigger/event it will be posted.

    Just selecting an item allows us to edit/add/change the event by editing the 'Event:' box (edit and press 'return' and the new version will be added to the list). Events are in json formats. Selecting an event and typing 'delete' will remove the event. (in the future I will add the possibility to initialise with custom events from the code)

    A special feature is to add 'property' events with a special '_sensor' field, ex

    Please login or register to see this code.

    This will post the event, and then after 30s post a new event but with value='0'. This is really useful for simulating motion sensors that reset themselves after a specified time.

    When _GUI is set, _SPEEDTIME is disabled, meaning that the scene always run in real-time. If run in _SPEEDTIME there would never be time to click on any event...

    Btw, the 'Trigger' window seems to always start in minimized mode (in the dock), happens on Windows and Mac. I'm looking for a way to raise the window into focus when the framework starts. Fixed.

     

    Anyway,  if I get my head around the wxWidget library it should be possible to do a VD emulator too...

     

    Edited by jgab
    Link to comment
    Share on other sites

    On 11/24/2018 at 7:20 AM, jgab said:

    And then I use the

    Please login or register to see this link.

    scene to disable the alarm when family members approaches the house in the evening.

    Do you post this from iOSLocator scene to EventRunner scene? if so, can you show example?

    9 hours ago, jgab said:

    Just uploaded a new feature in the EventRunner framework to help with debugging scenes.

    If you run in ZeroBrane and in the 'Project' menu chose Lua interpreter to 'Lua', which means Lua 5.1, we have access to a window library (wxWidget).

    Then we can set the '_GUI' global var in EventRunner to 'true', and the framework parses the trigger declarations in the header of scene and creates a GUI window that allows us to chose events that are posted to the scene. 

    Great feature! Works very well :D

    Link to comment
    Share on other sites

  • Topic Author
  • 20 minutes ago, jompa68 said:

    Do you post this from iOSLocator scene to EventRunner scene? if so, can you show example?

    Great feature! Works very well :D

    Yes, I register the iOSLocator to post events to the alarm scene too (I have this 'scene' field in the hometable that tells the iOSLocator to where to send the events). There you have the same logic as you have before with detecting if anyone is home or away and then you have a rule like

    Please login or register to see this code.

    But if you already compute 'presence' home/allaway in another scene that scene could post to the alarm scene instead so you don't have to do it in two places.

    Link to comment
    Share on other sites

    1 hour ago, jgab said:

    I have this 'scene' field in the hometable that tells the iOSLocator to where to send the events

    Like this?

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 6 minutes ago, jompa68 said:

    Like this?

     

    Please login or register to see this code.

     

    Like this

    Please login or register to see this code.

    'send' is a list of who to send to

    Link to comment
    Share on other sites

  • Topic Author
  • 6 minutes ago, jompa68 said:

    how can test #presence with ZBS?

    Fake an event from iOSLocator in the scene receiving events from iOSLocator?

    Please login or register to see this code.

    You could also add it to the trigger window to manually post it.

    Edited by jgab
    Link to comment
    Share on other sites

    1 hour ago, jgab said:

    You could also add it to the trigger window to manually post it.

    Trying with this but fail with Bad event format

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 48 minutes ago, jompa68 said:

    Trying with this but fail with Bad event format

    Please login or register to see this code.

     

    Pure JSON, can’t use the # notation.

    Link to comment
    Share on other sites

  • Topic Author
  • 4 minutes ago, jompa68 said:

    After some tries it works

    Please login or register to see this code.

     

    I would have expected just

    Please login or register to see this code.

    why is it wrapped in an type:'event' ? type:'event' is usually CentralSceneEvent or AccessControlEvent stuff...

    Link to comment
    Share on other sites

    1 minute ago, jgab said:

    why is it wrapped in an type:'event' ? type:'event' is usually CentralSceneEvent or AccessControlEvent stuff...

    Well, like i said..did try many different post and that one was working and i thought it was correct.

    Link to comment
    Share on other sites

  • Topic Author
  • New version, 1.5 of EventRunner. EventRunner.lua and EventRunnerDebug.lua needs to be updated.

    Lot's of bugfixes (thanks to @jompa68, @petrkl12, @ipsofacto and others testing things out)

     

    Support to enable/disable rules & event handlers.

    Please login or register to see this code.

    Rule.eval and Event.event return a datastructure representing the rule/handler. It has 2 methods enable() and disable() that do what they say.


     Possible to group rules & event handlers in sections

    Please login or register to see this code.

    Rules will be associated with the section that Event.SECTION is set to when the rule/handler is defined (or not associated if Event.SECTION is nil)

    This is helpful as the common conditions that rules are sharing for only executing at specific days, weeks, months or other states, can be divided up into rule sections that are enabled/disabled on the common conditions instead. In the example we enable rules depending on month, but it could also be depending on some global variable.

    EventScript's enable/disable work on rules/handlers or a string. The latter enables/disable a section.

     

    Trigger window

    A pop-up window for ZeroBrane with all triggers defined in the scene header and that allows for posting of those triggers. Convenient for testing logic of rules. <

    Please login or register to see this link.

    >

     

    Initialize globals

    - _GLOBALS is available when running offline to initialize global variables. Needs to be set up outside (before) the declaration of 'main()'

    Please login or register to see this code.

     _GLOBALS={timeOfDay='Night', alarm='10:00'} will initialize the offline version of the globals to the values specified, without causing a trigger because the variable changed. There is also a Util.defineGlobals(<table>) to do the same, but possible to call within 'main()'

    Please login or register to see this code.

     

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

    Thanks for new version.

     

    I have problem with debuging - error EventRunnerDebug.lua:179: attempt to index local 'f' (a nil value) in row:  local src = f:read("*all")

     

    Maybe I have something wrong ...
     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 2 minutes ago, petrkl12 said:

    Thanks for new version.

     

    I have problem with debuging - error EventRunnerDebug.lua:179: attempt to index local 'f' (a nil value) in row:  local src = f:read("*all")

     

    Maybe I have something wrong ...
     

     

     

    you use zerobrane studio or something else?

    Link to comment
    Share on other sites

    zerobrain - sorry it looks that error is here:

    Error loading rules:E:\Development\ZeroBraneStudio\lualibs/json\decode.lua:74: bad argument #1 to 'match' (string expected, got nil)

     

    in fibaro it's OK

    Link to comment
    Share on other sites

    you are right! Thanks

    My mistake - I replace my own during copy of new version

     

    Link to comment
    Share on other sites

    @jgab

    if I run in ZeroBrain via F6 (>> Execute) then there is error:

    EventRunnerDebug.lua:179: attempt to index local 'f' (a nil value) in row:  local src = f:read("*all")

    there has to be problem with:   local short_src = debug.getinfo(3).short_src

     

    if I run in ZeroBrain via F5 (> debug)  then there is everything OK

     

    Link to comment
    Share on other sites

  • Topic Author
  • 51 minutes ago, petrkl12 said:

    @jgab

    if I run in ZeroBrain via F6 (>> Execute) then there is error:

    EventRunnerDebug.lua:179: attempt to index local 'f' (a nil value) in row:  local src = f:read("*all")

    there has to be problem with:   local short_src = debug.getinfo(3).short_src

     

    if I run in ZeroBrain via F5 (> debug)  then there is everything OK

     

    Thanks,

     it seems like debug.getinfo(level).short_src return different values depending on if one runs with debug or not. I always run debug...

    For now, run with debug. I will push a new version tomorrow with some other changes too.

    /J

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