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


  • 0

Realtime events/triggers with REST API


Question

Posted

Hi to all, i'm studying Fibaro REST API 

Please login or register to see this link.

but i find only information about calls and fetch info. Seem only one-directional interface.

 

For example, the Motion Detection sensor. How i can obtain in realtime the event trigger?

I need to fetch every seconds the device info to detect it?

 

In some other REST API of other kind of service, for example, it's possible to subscribe an event by providing a callback URL, and system will call it when an event occur.

 

I'm missing something? Thanks for any advice.

 

Clodo

9 answers to this question

Recommended Posts

  • 0
Posted

+1

  • 0
  • Inquirer
  • Posted

    Please login or register to see this link.

    , at least, have an API that list every changes in zwave network occured from a timestamp param. 

    Exists something like that in Fibaro, or i need to fetch a lots of data and device every seconds?

    • 0
    Posted

    I use a scene on the HC2 and it calls the api of the Raspberry (for example scene triggered by "motion"). I'm pretty sure this is the only workaround. I've never seen or heard anything regarding "callback" on HC2.

    • 0
    Posted

    As far as I can see there is way to poll the HC2 events, which is used by the build-in Event panel.

     

    Get last event update number:

    Please login or register to see this code.

    Returns some thing like:

    Please login or register to see this code.

     

    The event update number will keep increasing. Note that on event update can contain multiple events etc, which can be collected like this:

    Please login or register to see this code.

    It will return json arrays for logs, events and changes. 

    This way you can iterate back in HC2 history

     

    • 0
    Posted

    @snitkjaer wellcome to the forum! I see you have resurected a topic from 2015 but that is OK ;-)

     

    Yes, indeed, you can "poll" the event log. I have no idea how "expensive" that is. I use it to collect data for off-line analysis only.

    • 0
    Posted

    @petergebruers Thanks :-) I know it's an old topic but I came in from Google thus I thought others might as well.

     

    I doubt it would be to expensive if we just poll say every 300 - 1000 ms, which should be "real time" enough for most uses.

     

    Anyway seems there is also a way to get just old events in case that is needed:

    Please login or register to see this code.

    I'm writing a small program to periodically collect and store the events in a DB for analysis 

    • Like 1
    • 1
    Posted (edited)
    11 minutes ago, snitkjaer said:

    I'm writing a small program to periodically collect and store the events in a DB for analysis 

     

    In that case, I suggest you use IDs to synchronize your data (url like "?from=<ID>"). Because timestamps are not unique and have limited resolution (seconds). So to avoid duplicates and ordering problems, I would always use the event ID. It is guaranteed to increment.

     

    You might be interested in these two topics:

     

    Does this help? In that case, you can show your appreciation by "liking" this post... If it not, please tell me how I can improve my answer...

     

    Edited by petergebruers
    fixed filter by ID
    • Like 1
    • 0
    Posted

    Have fun with Home Automation!

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

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