Virtual Button - help needed to understand

I have created a virtual button but do not understand the significance of the various fields in the device creation form or what values are expected there. I've checked the documentation and Googled, but all I can find are questions or help for people who have already set one up successfully and having trouble using it with a rule or dashboard. So basically I need instructions for creating a virtual button. It may be that it's not a button I want for my purposes at all, but I don't want to make that decision based merely on my ignorance and confusion with buttons :slight_smile: (NB never had any trouble creating or understanding virtual switches)

Are you speaking of this 'form'?

That is the device page. It shows you what the virtual device can do. You can 'Double Tap', ' Hold', 'Push', and 'Release' each of the virtual buttons. The 'Number of physical buttons' field is how many buttons the virtual device has (SmartThings button is a single button, but I have a button controller that has 8 buttons on one unit. They make lots of button devices)

If you entered '3' into the 'Push' field and clicked it, you would effectively send the signal that button #3 on the virtual button device was pushed. That would show up in your logs and could have rules/actions done because of it. Same goes for the other fields, nothing is required, it is there to allow you to preform actions.

With that said, other than testing I'm not sure you would use it that way. Most would use rules or something to simulate button presses, and subsequent actions. This is just my guess, as I don't think I have ever used a virtual button (I'm sure someone has and will post an example). More common is a virtual switch.

If you would like help or guidance on setting up a rule, I'd recommend letting us know what it is you are trying to do. It's likely someone here has done something similar already, or can help provide different approaches to the situation. There is generally multiple ways to get the same end result.

For a fairly simple use case you could also use a virtual switch with a timeout to switch it off. I would think a virtual button would be most useful where you are representing an existing physical button, either to simulate the same options or to integrate with a driver / app of some sort.

So it's just a numeric value of my choice (I guess most people would number them 1-4) so as to test the value in a rule? Ok I have just gone and tried that, but am now a bit puzzled that when I use Save Preference or Save Device on that form it clears those fields. Pushing the button virtually on my Hubitat dashboard then gives me "java.lang.NumberFormatException: For input string: "null" (push)" on the logs. Does this only work at initial creation time? I had gone in to edit the virtual button I had already previously saved, is that wrong?

The proposed function was to operate a rule that clears (deletes) a local custom log file. I could have easily had a virtual switch do the job, with the rule resetting to Off upon completion, but I thought why have an unnecessary line of code and a stored state when a one-off signal is all that is really needed. Of course, given that buttons are not displayed by Google home etc, I might end up wishing I had simply used a switch, but I really do want to know how to do this before rejecting it lol

You can configure the timeout in the setup of the switch... I'll get a screenshot...

1 Like

Thanks, though it still doesn't stop me wanting to know why I am having so much button trouble :wink:

Fair point... I'll see what I can help with in the other points you raise. I at least thought the values of the buttons may have been fixed to buttons 1-5, but could be wrong...

I've tried setting those button values in Edge and Chrome browsers but same result - they get wiped when I save. And I've tried doing it with a new button at creation time - same result. I wonder if I've found a bug?

I see now you can set the number of buttons. When you say the values are cleared, are you talking about the values under the different options to push, hold, etc? The value under these are just used when initiating those commands by clicking the push or hold option on the device setup screen, if that makes sense. When you click save preferences, it is simply refreshing the page and clearing the values last used in these commands.

I'll take a look at what may be happening on your dashboard...

When you setup the button tile on the dashboard you need to nominate the button number on the right hand side of the tile setup.

1 Like

Oh hold on - where do I set button number on the virtual device itself?

1 Like

Yes, the device page is just giving you the ability to initiate certain actions (commands) which you would typically only use in testing or setting up things like rules if it is more convenient than setting up a dashboard tile, particularly if you don't intend to set one up (not your situation in this case).

Glad to help out...

1 Like

Sorry I edited my post. How do I know what number the button is in order to specify it in the tile setup?

I edited my earlier post as well, took another screenshot of the tile setup, the text box at the bottom right of the dialog shows I have setup my tile for button 1.

Oh, my earlier comment on the device setup was me realising you can nominate the number of buttons... Sorry if that caused any confusion

1 Like

So does that mean your tile if tapped will send the "Double Tap" signal, which is the first in the row? Oh! The number of the button if you had said there was more than one included in that device. So if I have only one button specified then I have to put '1' in there

I'll have to check, I think it's a push...

Yes, it logged a push

1 Like

Yep I think I am sorted now! It's falling into place. Many many thanks for all your time! Um not sure which of your posts to mark as the solution now!

1 Like

All good, happy you got what you needed, that's the main thing..

1 Like

Now I am beginning to see the advantage of a switch over a button. With a switch with an auto-off after a couple of seconds you can see it change state briefly and at least get the impression it's doing something. The virtual button gives no feedback :smiley:

1 Like