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

Get the ID/name/label of the button clicked (virtual device)


Question

Posted

Is there a way to determine the button that was clicked from Lua code.

For example, having a button labelled "MyButton"

Please login or register to see this code.

Can this be done?

7 answers to this question

Recommended Posts

  • 0
Posted

Have not seen this function yet. If you found it, please share it with us here as well.

Thanks!

  • 0
Posted

Cant see why you cant do it by setting a variable when its clicked then. 'Checking ' that variable. Not entirely sure how to code without sitting at my laptop but thats how Id do it. Ie Lets say you want button 1 to be identified, in the lua for that button set variable "local button" == 1; as part of whatever you do. Do the same for each other button. Make a global which is populated by result and then check it in the main loop with more LUA and youll know whjch ones been clicked!

HTH

Dave

Please login or register to see this image.

/emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

  • 0
  • Inquirer
  • Posted

    That won't work for me.

    I'm trying to create virtual devices with the least hassle possible. So I have 4 preset buttons, and to prevent having to make specific code for each button, I want to programmatically determine the button that was clicked.

    This way I can use the exact same code for each button (in your scenario, I would have to modify each piece of lua code by setting a variable to a specific identifier)

    Consider a scenario; having 100 HC2's with the same virtual device. Now I find a bug and have to update all of them. So I want to have the least amount of manual interactions to prevent errors and support calls.

    • 0
    Posted

    Fair enough, I see your predicsment but my LUA knowledge doesnt stretch that far (nor my Fibaro knowledge to be honest!) Im afraid.

    I would hope there may be the equivalent of an onbuttonpressed state or some such but youd have to read the docs/ask Fibaro on that one....unless someone else knows.

    Be interested to know if u find an answer:)

    Sorry, Dave

    [ Added: 2014-07-03, 16:59 ]

    I know this doesn't specifically help you but I rememberd that when 'one' clicks on a button the icon can change from an unpressed state to a pressed state. If HC2 can read that happening then you must be able to capture that somehow and code for it being pressed.

    • 0
    Posted

    Dave's idea sounds good.

    Either on the global part and the icon changing part.

    But sad to say it doesn't work for tieske.

    • 0
  • Inquirer
  • Posted

    I like that idea. @Dave ; any pointers to where I can find more information on this?

    • 0
    Posted

    You could use the codes below to find the icon id.

    Please login or register to see this code.

    Your scene will run to check if the icons have changed. Perhaps to add the id into a global variable and compare the current icon id to the new icon id to see if it has changed?

    But all the steps here are very long winded.

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