How do I implement a virtual button?

I've spent all morning reading posts and I still don't understand how to implement a virtual button.

I added a virtual button (one button) device to HE and created a rule that is triggered by its button press. When the button is pressed, the rule causes a Broadlink IR Remote Control to simulate pushing the "power" button on a TV's remote control, i.e., it turns the TV on/off. Pressing the button from the device edit page verifies that the rule works.

The virtual button shows up on my iPhone, but when I press it, it goes to the "there is an unconfigured button..." page. I click on "Single Press" add in the Actions section and it goes to a list of all the other devices Home is "sharing" with HE. Note that the IR remote is not integrated with HomeKit so it's not in the Home device list. Bottom line is I was not able to get Home to do what I want with a virtual button.

For my second attempt, I defined a virtual momentary switch (and HE rule), and that worked, i.e., when pressed in Home, it turned the TV on/off.

Mainly because I'm a Home novice, I was unable to set Home up so that a virtual button press turned on the virtual momentary switch.

Is there a way to get the button to work without the switch? If both the button and the switch are required, how do I get the button to turn on the switch in Home?

Apple Home allows the use of buttons to control its own automations using real life devices rather than virtual. You define the button via automations and press the device instead of in the app. To do what you want, you'll need to use a virtual switch like your second attempt.

Not sure I understand what you are saying, but here's what I'm trying now that doesn't work...

I now have a virtual momentary switch ("Test Switch") and a virtual button ("Test Button") defined in HE. Both have been exported to Home via the HomeKit Integration app. I can see both devices in the expected room in the "Other" category on my iPhone.

I pressed the Test Button on the Home screen which brought up the "Unconfigured button..." screen. I scrolled down to the "ACTIONS" section and clicked "Add" for "Single Press". That brought up a list of all the devices/accessories. I selected Test Switch and clicked "Next". That brought up a screen that listed the selected accessories (only "Test Switch", which showed "Turn Off"). I clicked "Test Switch" (not the "Test This Action"). That brought up Test Switch (in the "off" position). I changed it to "On" and closed that screen. That changed the previous screen to show "Turn On" for Test Switch. I clicked "Test This Action", and I could see on the HE device edit page that Test Switch turned on for 1/2 second then turned off.

I clicked "Done", went back to the room display, and pressed Test Button on the icon on the left side. That brought me to the same page that was shown when I clicked on Test Button the first time, except that instead of showing "Unconfigured button...", it showed the button's room and name and the "...not been certified..." message (that was also shown the first time. Everything else looks the same, e.g., the "Single Press" action is defined, and the action is to turn the Test Switch on. This screen comes up every time I press Test Button, and Test Switch is never turned on.

Any ideas on what I'm doing wrong?

There is nothing you are doing wrong. The virtual button into Homekit has been wonky for a long time (Virtual Button in HomeKit Bug?). Some owners are able to get it to work, some are not. You can try the changing number of buttons trick from the previous thread to see if that works. I just created a virtual button and got to the same stage as you. Everything gets defined, but the error message of "uncertified" prevents it from doing anything.

I use virtual momentary switches in Apple Home rather than buttons and find it works well for my needs. Any reason why it has to be a button rather than a switch that auto-turns off?

1 Like

I know a virtual momentary switch works, but it doesn't "fit" well with what I want to do. The virtual button would be a good iPhone representation of the power (on/off) button on a physical IR remote control for a TV. I don't plan on implementing any additional buttons on the IR remote on the iPhone.

Because a virtual momentary switch shows states (on/off), it isn't a good representation of the remote's power button, and could lead to confusion. For example, "at rest", it will always show "off" regardless of the TV's current state.

I guess another solution would be to find a way to monitor the TV on/off state and keep a virtual (non-momentary) switch in sync with it so that the switch shows "on" when the TV is on, etc. I'm not sure how bulletproof that solution could be made, and I don't know if it is worth the effort.

Thanks for the help. :+1:

If you search the forum, you’ll find lots of folks using power monitoring smart plugs with their TVs to do exactly this. Going this route will allow you to keep things in sync even if you use the TV remote rather than the Broadlink. Owners can build automations off the power levels of the plug.

1 Like