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

What are custom events and how to use them?


Seraphim

Question

Hello Community,

 

Well, for Sur I read the Fibaro definition of a custom event but I can't imagine what they are good for? Could someone explain this functionality to me?

How do I use a custom event in a scene and/or a QA?

 

Regards

Andreas

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

trigger scenes based on event!

 

in condition :

Please login or register to see this code.

From QA or scene: 

 

Please login or register to see this code.

also check swagger for API ;)

Link to comment
Share on other sites

  • 0
Guest kallecux

Hi @Krikroff, which body has to be published in your example?

 

{type=custom-event}?

{type="custom-event"}?

 

I got 501- Error: Not Implemented

 

Greetings

Karl Heinz 

 

Link to comment
Share on other sites

  • 0
1 hour ago, kallecux said:

Hi @Krikroff, which body has to be published in your example?

 

{type=custom-event}?

{type="custom-event"}?

 

I got 501- Error: Not Implemented

 

Greetings

Karl Heinz 

 

You need to define the event before you can "emit" it. Under the Settings->General->Events panel...

Link to comment
Share on other sites

  • 0
Guest kallecux

Thanks for your answer. This was a follow-up question to create an event from outside (nodered) and react in ER4. 

Edited by kallecux
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Thanks for the explanations. But wouldn't a binary switch a bit more comfortable (e.g. to see the state, if it is emited or not)?

    Link to comment
    Share on other sites

    • 0
    On 3/17/2020 at 7:01 PM, Seraphim said:

    Thanks for the explanations. But wouldn't a binary switch a bit more comfortable (e.g. to see the state, if it is emited or not)?

    Well, a binary switch needs to be 'off' before it will generate an 'on' trigger again. (Custom)events you can send the same multiple times and your scene will react on them.

    In another way, your events are stateless, whereas your binary switches are stateful. Both have their uses.

     

    I would have preferred that the person that dreamed up CustomEvents would have allowed them to carry 'values' (ie. events have a type and they carry a value - which is how normal event system in the real world work) - a value that could be matched against in conditions. Technically you can code the value into the name/type but it's ugly and creates an unnecessary explosion of customevent definitions. There is a userDescription part but we can't match against that. Secondly, we can only emit CustomEvents we have defined prior - which also prevents userDescription to be used as a value field as the "emitters" may overwrite each other's userDescription (if they share the same CustomEvent definition) before the consumers of the events can read them.

    (it's kind of wacky that you get a trigger when a custom event is emitted but only the name part, you have to fetch the userDescription by fetching the definition api.get("/customEvents/<name>") - which kind of make the events stateful, at least if you try to use the userDescription field to carry a value)

    So, the way customEvents are implemented now they are semantically equivalent to globaVariables which is an missed opportunity IMHO...

     

    so a 

    Please login or register to see this code.

    that resulted in a internal event (refreshState)

    Please login or register to see this code.

    and a sourceTrigger of type

    Please login or register to see this code.

    would be *very* nice

    and in scenes one could match against the name  (and optionally the value).

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

    • 0
    46 minutes ago, jgab said:

    I would have preferred that the person that dreamed up CustomEvents would have allowed them to carry 'values'

    Oh my, Jan are you thinking instead of Fibaro team? So glad you're able to find workaround where Fibaro "failed", or just didn't mature yet :-D

     

    • Like 1
    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
    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...