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

Events fired from a "Button"


Question

Posted

Hello!   Now i got stuck again on a really simple task....   

 

I have a Fibaro button and want it to trigger a scene, and in the scene I want to turn ligts on or off depending on if it was 1 or two clicks on the button.

I stared with the following...

--[[
%% events
22 CentralSceneEvent
–]]

fibaro:debug('White button trigger')  -- No problem here, the event is fired

local trigger = fibaro:getSourceTrigger()

fibaro:debug('Type= '..trigger['type']) -- yes the type is 'event' as it should be

if trigger['type'] == 'event' then
  -- How can I detect if its one or two click?

end   
 

You can see in my code what I'm missing! 

I'w been googling all evening but cant find this basic information. Is there some Total manual covering all the fibaro LUA language or are there separate manuals for all devices?

In the Fibaro "Button" manual there is nothing  mentioned about what events that can be triggered....

 

Please help, Mikael

 

 

 

8 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Posted

    Please help! I thought this was really easy!?   I just want the source of the triggering  event!?

     

    Best regards, Mikael

     

    • 0
    Posted

    Hi @Lenfors,

     

    You can use this code to detect how many times button is pressed and execute some code:

    Please login or register to see this code.

     

    • 0
    Posted
    24 minutes ago, Sankotronic said:

    Hi @Lenfors,

     

    You can use this code to detect how many times button is pressed and execute some code:

    Please login or register to see this code.

     

    Shouldn't this be auto included in the HC when you add a button? I mean this is essential to use it the way it is intended to.

    Fibaro should add frequently used code with their products you can select when building scenes....

     

     

    Jim

    • 0
    Posted
    51 minutes ago, jimicr said:

    Shouldn't this be auto included in the HC when you add a button? I mean this is essential to use it the way it is intended to.

    Fibaro should add frequently used code with their products you can select when building scenes....

     

     

    Jim

     

    Hi @jimicr,

     

    complaints should be addressed to Fibar group. For me, simple thank you is enough :) 

    • 0
    Posted

    Hahaha, yeah thanks :)

     

    Fibaro are you listening?

    • 0
  • Inquirer
  • Posted

    Thank you :-)

     

    Just the information I needed!

     

    Is there some documentation where this kind of information can be found? I found information about fibaro:getSourceTrigger() but nothing about ["event"] and ["data"]....

     

    Best regards, Mikael

     

    • 0
    Posted

    A useful trick is to dump out the information in the source trigger, eg:

    Please login or register to see this code.

    If I press the button twice then I get:

     

    {"event":{"data":{"icon":{"source":"HC","path":"fibaro\/icons\/com.fibaro.FGPB101\/com.fibaro.FGPB101-1Pressed2.png"},"deviceId":292,"keyAttribute":"Pressed2","keyId":1},"type":"CentralSceneEvent"},"type":"event"}

     

    Reformatted this is:

    Please login or register to see this code.

     

    Therefore, the following code:

    Please login or register to see this code.

    will give me:

    Please login or register to see this code.

    Dave

     

    • 0
    Posted

    Thanks a lot. Works great

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