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
  • Ok, strange world of regexps.. change the pattern to "[Ss]et%s*(%w+)%s*to%s*(.*)$" -- it not match the space and will also allow digits in the variable name.

    Link to comment
    Share on other sites

    42 minutes ago, jgab said:

    Ok, strange world of regexps.. change the pattern to "[Ss]et%s*(%w+)%s*to%s*(.*)$" -- it not match the space and will also allow digits in the variable name.

    That did the job. Thanks.

     

     

    Please login or register to see this image.

    /monthly_2019_02/image.png.0f27883e08f4451a47631b9423d809c8.png" alt="image.png.0f27883e08f4451a47631b9423d809c8.png" />

    Edited by jompa68
    Link to comment
    Share on other sites

    Also possible to use cmd:device:off or cmd:device:on from Telegram thanks to @jgab

     

    Please login or register to see this image.

    /monthly_2019_02/image.png.6720bb33c82bb7f0430892c2652921e8.png" alt="image.png.6720bb33c82bb7f0430892c2652921e8.png" />

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, jompa68 said:

    Also possible to use cmd:device:off or cmd:device:on from Telegram thanks to @jgab

     

    Please login or register to see this link.

     

     

    The Telegram integration gives a lot of freedom to come up with your own command structure. The Fibaro Facebook and Alexa/Google Home integrations are quite limited in what type of commands can be sent and how it should be parsed. Also the possibility to have interesting responses back from commands. Like a "status" command that responds with if someone is at home and what lights are on and if the door is locked etc. Who needs the new app? :-) 

    Btw, there is a node-red-chatbot that also integrates with Telegram but also FB and most other message services - a little more involved to setup with certificates and ssl tunnels but it should in principle be possible to use the same scene to handle those - only change the node-red setup.

    Link to comment
    Share on other sites

    @jgab playing with my alarm setup and i need some help to solve a post command.

    Scenario:
    house is fullArmed, door opens, have 20 seconds to turn off alarm, but runAlarm still triggers after 20 seconds even that i have done a post(disarm)

     

    Please login or register to see this code.

    Possible to stop a post?

    Edited by jompa68
    Link to comment
    Share on other sites

  • Topic Author
  • 48 minutes ago, jompa68 said:

    @jgab playing with my alarm setup and i need some help to solve a post command.

    Scenario:
    house is fullArmed, door opens, have 20 seconds to turn off alarm, but runAlarm still triggers after 20 seconds even that i have done a post(disarm)

     

    Please login or register to see this code.

    Possible to stop a post?

     

    Yes,  'post' or 'Event.post' returns a reference that 'cancel' or 'Event.cancel' can be called on. If the ref is nil it is ignored. cancel also return nil so it is useful to do 'ref=cancel(ref)' to also set the ref to nil. If it is expired it is also ignored, but it can be good to set the ref to nil in the #runAlarm rule too.

    Post is implemented as a 'setTimeout' and cancel as a 'clearTimeout'.

    Edited by jgab
    Link to comment
    Share on other sites

    Thanks for your reply, will test this tonight.
    Testing all the scenarios with the alarm setup so i do not miss anything and it is perfect to do this in ZBS.

    Link to comment
    Share on other sites

    On 2/18/2019 at 7:45 AM, jgab said:

     

    The Telegram integration gives a lot of freedom to come up with your own command structure. The Fibaro Facebook and Alexa/Google Home integrations are quite limited in what type of commands can be sent and how it should be parsed. Also the possibility to have interesting responses back from commands. Like a "status" command that responds with if someone is at home and what lights are on and if the door is locked etc. Who needs the new app? :-) 

    Btw, there is a node-red-chatbot that also integrates with Telegram but also FB and most other message services - a little more involved to setup with certificates and ssl tunnels but it should in principle be possible to use the same scene to handle those - only change the node-red setup.

    Will try to setup a new button applet in Telegram. then i can use that as widget in phone and my watch :D

    Link to comment
    Share on other sites

  • Topic Author
  • 1 minute ago, jompa68 said:

    Will try to setup a new button applet in Telegram. then i can use that as widget in phone and my watch :D

     

    1 minute ago, jompa68 said:

    Will try to setup a new button applet in Telegram. then i can use that as widget in phone and my watch :D

    Maybe it’s possible to auto translate a VD to a telegram message. Labels and buttons are easy - can telegram show sliders?

    Link to comment
    Share on other sites

    Hi guys,

    I am trying to follow what you are doing but to be honnest I am lost a bit.

    I made the scene and when I run it the next error shows up.

    The only thing I changed are a few valus at the top

    What to do?

    Please login or register to see this image.

    /monthly_2019_02/image.png.c1c025ae15a1c181979e0d44231546eb.png" alt="image.png.c1c025ae15a1c181979e0d44231546eb.png" />

    Link to comment
    Share on other sites

  • Topic Author
  • 9 hours ago, Sjakie said:

    Hi guys,

    I am trying to follow what you are doing but to be honnest I am lost a bit.

    I made the scene and when I run it the next error shows up.

    The only thing I changed are a few valus at the top

    What to do?

    Welcome!,

    the version of the scene you have (v1.14fix7) is the experimental (beta beta) version we used when we did changes to the synchronisation mechanism. I think it should work but I recommend to download the latest from the GitHub. Link <

    Please login or register to see this link.

    >

    The error you get is an attempt to call 'dofile' to include some example rules to test out. However, that only works when running offline.

    If you want to try something simple only on the HC2, comment out the 'dofile' and include rule below in the main() function - should work on the experimental v1.14fix7 too.

    The single example rule will log a message every 5 sec in the console, not very exciting but a start, and a confirmation that it works.

    Please login or register to see this code.

    If you want to experiment with adding some time scheduling rules to turn on/off stuff look at <this post>. If you want to try to write some trigger rules that reacts on motion sensors or buttons look at <this post>.

     

    However, and I can't recommend this enough, do setup an environment to code and run the scenes offline. There are instructions <here>. There are so many advantages, including running scenes faster than realtime, setting breakpoints, simulating triggers, and a much faster development cycle. Most of us here do all our development offline. A good environment for developing Lua that is free is ZeroBrane studio. All the links are in the linked post. It will literally save you hours of work.

     

    This is not a ready made scene for a specific purpose, but a platform that almost anything can be done on. There is a million features and if we discover something that can't be done we try to add it. As such I guess it is a bit of learning curve and there are some 650 posts to catch up on :-) 

    However, there are links in the intro post that try to describe the various aspects and I promise I will add a  better intro example in that post too.

     

    Make the above example run on the HC2 and if you can't figure out the next steps, give me examples of stuff you would like to do and will figure out together how to write rules to get you going. Happy to help out.

    /J

    Edited by jgab
    Link to comment
    Share on other sites

    @jgab , the Supervisor-scene crashed after I deleted the EventAlarm399-scene. It might a not allowed to delete a scene watched by Supervisor?

    /F

     

    Please login or register to see this image.

    /monthly_2019_02/Supervisor.jpg.3e189313d78cfdcb5dda992a2f7ab71e.jpg" alt="Supervisor.jpg.3e189313d78cfdcb5dda992a2f7ab71e.jpg" />

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, FrankT said:

    @jgab , the Supervisor-scene crashed after I deleted the EventAlarm399-scene. It might a not allowed to delete a scene watched by Supervisor?

    /F

     

    Please login or register to see this link.

    No, this is a bug - didn't anticipate that the scene could be removed (only stopped/disabled). For now just restart the supervisor, I will release a new supervisor today or tomorrow with a fix and some other improvements too.

    Thanks /J

    Link to comment
    Share on other sites

  • Topic Author
  • New version pushed, v1.15,fix2

    EventRunner.lua

    EventRunnerDebug.lua

    Supervisor.lua

    iOSLocator.lua

     

    Besides some minor bug fixes, there is now a publish/subscribe mechanism included in the ER framework.

    Please login or register to see this code.

    There are also eventScript versions

    Please login or register to see this code.

     

    With a robust publish/subscribe mechanism (still to be proven :-) ) it is much easier to start to treat scenes as "services" and create a flexible way to connect scenes and make them communicate.

    Scenes don't need to know each other's names or IDs, just subscribe to an event pattern and get events from all scenes that publish something that match this pattern. Scenes can be stopped and restarted and they will rediscovered and they will re-subscribe on their events. There is no buffering of events, i.e. if a scene is stopped it will miss the events being published during that time. However, there are  "static published events", see below.

    The pub/sub mechanism is not depending on the supervisor - but is a p2p discovery mechanism builtin to all ER scenes. In fact, the supervisor leverage this to discover new scenes immediately  instead of having to rescan all scenes every 5 minutes as it did in the past.

    Because pub/sub is done directly between scenes and not via a broker (or the Supervisor in our case) it is as efficient as a fibaro:startScene or ER's postRemote. The only performance issue is that when a message is published it is filtered on what events are currently subscribed to by other scenes. Because there is no need to declare the intent on what events the scene will publish (Event.publish sends the event). If there was a method for that we could pre-filter the subscriptions on what we actually publish and make it slightly more efficient. However, without that need this model is more flexible. It may become an optional optimization in the future if we see a need for that.

     

    Event subscribed to can contain constraints

    Please login or register to see this code.

    to only subscribe to test events with a value bigger than 41.

     

     

    There is a new version of the IOSLocator scene also. It is backwards compatible but now also supports pub/sub.

    To get events from the iOSLocator:

    Please login or register to see this code.

     

    There are a lot of interesting features that can be built on top of this. An idea is to include a "startup service" in the supervisor. Scenes subscribe on a {type='start'} event and start doing their stuff when they get the start event from the Supervisor. With that principle, the supervisor can decide in what order and with what timing each scenes should startup, e.g. in case of a reboot.

     

    Oh, there is one more feature. There is a kind of a "static" publish mechanism.

    Please login or register to see this code.

    A static published event will always be resent to new scenes that subscribe, even if the event was published in the past (a bit inspired by MQTT)

    It can be used to give initial values to new subscribers.

    There is no unsubscribe method at the moment - if we need it, it is easy to implement.

     

    I hope there are no bugs and when I have tested it a bit more I will bump the version to 1.16

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

  • Topic Author
  • Cleaning up the code a bit, v1.15fix4 of EventRunner.lua

     

    ..and a new feature

    Please login or register to see this code.

    The <id> must be bigger than 10000.

    The Hue support leverage this function to provide support for fibaro:call(<hueID>,'turnOn') and other call options, and to support fibaro:get(<hueID>,<property>).

    The fibaro functions 'call' and 'get' will call the functions registered with Event._registerID, or if not registered will call the original version of the fibaro functions.

    This is now used for supporting Hue devices but can easily be used to come up with other kind of "virtual" devices.

    The advantage is that if we support these call/get fibaro functions for our virtual device it will automatically work in EventScript rules.

     

    Assume we would like to make support for a Sonos device.

    -We run the Sonos functionality from a node-red server. We have to send the node-red a 'sonosstatus' message for it to send back the sonos status to us. We do that in our loop() function.

    -When we get a sonos status back we check if volume, track etc have changed and in that case post an (trigger) event; {type='property', deviceID=10050, value=<value>, propertyName=<name>}. This allows other rules to setup event handlers to react to sonos changes

    -We register 10050 as our sonos deviceID and provide a 'call' function and a 'get' function. Here we have to be a bit smart as we would like a value of 0 to be 'stopped' or 'paused' or if it is playing the value should be the volume. If the 'off' value returns 0, we automatically get support for 'toggle' as it is implemented as; if id:value>0 then fibaro:call(id,'turnOff') else fibaro:call(id,'turnOn')

     

    A Sonos device may not be the best example. We can always control a sonos VD by pressing buttons. However, this allows us to easily make trigger rules and add new "properties"

    We could easily extend this to allow for setting 'track' and we could make rules that trigger if Nickleback has been playing too long...

    Please login or register to see this code.

    This is a rather easy way to integrate external devices to look like "first-class citizens' in the fibaro device universe... :-) 

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

  • Topic Author
  • 8 minutes ago, jompa68 said:

    do you remember to implement this also :)

     

    Please login or register to see this code.

     

    Yes, it's default for iOSLocator and in main() for EvenetRunner.lua this is now an option

    Please login or register to see this code.

    This is for @jompa68 and me that have started to store our configuration data in a scene. Still works with fibaro globals.

     

    Link to comment
    Share on other sites

    Please login or register to see this code.

    json.decode missing

    4 hours ago, jgab said:

    Sonos functionality from a node-red server

    this one or another,? "node-red-contrib-better-sonos"

     

     

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