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

    Great,

    I was thinking to generalize the devicemap file to not only be for the hometable but a file with all predefined globals. Then bank holidays could be stored there too. Maybe also support an automatic way to download all globals from the HC2 to that file

    • Like 2
  • Topic Author
  • Posted (edited)

    New version 1.8 pushed to GitHub. EventRunner.lua, EventRunnerDebug.lua, globals.data

     

    - Change introduce that will break old way of handling hometable/globals when running offline.

    'globals.data' replaces 'devicemap.data' that was used to store the hometable global when running offline.

    globals.data as the name implies, stores all offline globals, including your hometable global.

    As setup you need to call _System.readGlobalsFromFile() in the beginning of main() to setup all globals for offline use (if called on the HC2,  _System.readGlobalsFromFile() does nothing)

    It will as default read in the globals stored in the file the variable '_GLOBALS_FILE' is set to, default 'globals.data'. Feel free to set it to other names to use different globals setups.

    _System.readGlobalsFromFile() can optionally take a filename Ex. _System.readGlobalsFromFile('my_globals.data') to read from some other file.

     

    _System.copyGlobalsFromHC2() will  copy globals from the HC2 to into the ZBS running scene. You need to have setup HC2 credential for the access to succeed.
    _System.writeGlobalsToFile(), will write globals "loaded" in the ZBS eventrunner scene to file 'globals.data' (can optionally take a file name too)

     

    To always get a copy of the HC2 globals to your offline scene when it starts, do

     

    _System.copyGlobalsFromHC2() instead of _System.readGlobalsFromFile()

     

    However, that may be a bit wasteful and to save a version of the HC2 globals to file on the ZBS, do

    Please login or register to see this code.

    once in the beginning of main() and replace with _System.readGlobalsFromFile()

     

    If you have an elaborate hometable that only exists on file on the ZBS you need to convert it as the format is different from the new format.
    You could do something like this to read in the old hometable and write a new globals file

    Please login or register to see this code.

     

    - Node-red support see

    Please login or register to see this link.

     

    - More useful Event listener server.

    If global 'NodeRed' or '_PORTLISTENER' is set to true an Event listener will be started on ZBS port 6872. The Node-red uses this to post events back to ZBS (on the HC2 Node-red does a proper startScene with the event as argument).

    However, we can post events from other clients too, including the HC2(!)

    Please login or register to see this code.

    This scene will encode every sourcetrigger (except 'other' and 'autostart') and send it to ZBS, where it will be reposted. And of course only triggers that are declared in the scene header...

     

    This means that we can forward "live" trigger on the HC2 to our offline scene on the ZBS. In principle we could run all scenes offline :-)

    It can be useful when some debugging scenarios, and I use it to forward live key events (CentralSceneEvents) into my offline scenes when debugging. 

    Edited by jgab
    • Like 1
    • Thanks 1
    Posted

    Testing this now but it does not send to node-red from ZBS

    Please login or register to see this code.

    Have this setup in scene

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    28 minutes ago, jompa68 said:

    Testing this now but it does not send to node-red from ZBS

    Please login or register to see this code.

    Have this setup in scene

    Please login or register to see this code.

     

    Ah, you use the variable ‘NodeRed’ both as address in remote call and set as boolean. 

    Posted (edited)

    ah, ofcourse. Looking and looking for mistake but did not see that :oops:

    Edited by jompa68
    Posted
    17 hours ago, jgab said:

    As setup you need to call _System.readGlobalsFromFile() in the beginning of main() to setup all globals for offline use (if called on the HC2,  _System.readGlobalsFromFile() does nothing)

    Gives error in HC2

    Please login or register to see this code.

     

  • Topic Author
  • Posted

    Have you downloaded the latest version of EventRunnerDebug.lua?

    Is this on the hc2? 

    Posted
    2 minutes ago, jgab said:

    Is this on the hc2? 

    Yes this is on HC2

    how can i get this to work? rnd and variable together

    Please login or register to see this code.

     

  • Topic Author
  • Posted (edited)
    7 hours ago, jompa68 said:

    Yes this is on HC2

    how can i get this to work? rnd and variable together

    Please login or register to see this code.

     

    OK, _System.readGlobalsFromFile()  was a bug from me. I pushed a new version that have null version of the functions when running on the HC2.

     

    The rnd should work. It will always run with random intervals from 5 to 55 minutes, however it will only carry out the action when homeStatus is equal to "away" and it's between 16:00 and  00:15.

    Doesn't it work for you?.

     

    Edited by jgab
    Posted

    It works now, typo mistake.

    Posted

    how do i set code to see witch light that are triggered? What i come up with is that it show all my lights that i declared.

     

    Please login or register to see this code.

     

  • Topic Author
  • Posted (edited)
    9 minutes ago, jompa68 said:

    how do i set code to see witch light that are triggered? What i come up with is that it show all my lights that i declared.

     

    Please login or register to see this code.

     

    Please login or register to see this code.

     

    Edited by jgab
    Posted

    Thanks Jan

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

    Please login or register to see this code.

     

    Actually you can get the (hometable) name instead just the device number (if you have made a Util.reverseMapDef in the beginning). That should probably be a built-in function for EvenScript in the next version.

    Please login or register to see this code.

     

    Edited by jgab
    Posted

    is this the correct way to have a delay between pressButton in a VD?

    Please login or register to see this code.

     

  • Topic Author
  • Posted
    39 minutes ago, jompa68 said:

    is this the correct way to have a delay between pressButton in a VD?

    Please login or register to see this code.

     

     

    The functions is wait()

    Please login or register to see this code.

    Do you need the last wait?

    Posted
    1 minute ago, jgab said:

    Do you need the last wait?

    haha no, should be first :-D

    Posted (edited)

    @jgab what is wrong with this?

    Please login or register to see this code.

    Please login or register to see this code.

    Perhaps i should mention that it is Sonos plugin that i try to toggle

    Edited by jompa68
  • Topic Author
  • Posted (edited)
    19 minutes ago, jompa68 said:

    @jgab what is wrong with this?

    Please login or register to see this code.

    Perhaps i should mention that it is Sonos plugin that i try to toggle

    So, 599, 596, and 597 are IDs of VDs? 

    :toggle is just to turn on/off lights/sockets or things that react on fibaro:call(id,'"turnOn") and fibaro:call(id,'"turnOff")

    Is it a button on the IDs you want to press?

    Ex. if it is button 1 that toggles play/pause.

    Please login or register to see this code.

    So you have recorded sounds of you moving around in the house to scare burglars?

    Edited by jgab
    Posted

    When you setup Sonos plugin in HC2 the players will be like normal on/off devices, so it is possible with LUA to use 

    Please login or register to see this code.

    but i think in your code you check for fibaro:getValue first, and that is not possible with this players from plugin.

    Can i use a VD instead? But that have different buttons for play/stop

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