Below are just a few examples of how you can push a Virtual Button. In each example, you must replace ACCESS_CODE with the code you received via email after you enabled and linked the skill to your Patreon account.

All of the examples below press Virtual Button 01 and they assume you've set up an Alexa Routine to react to Virtual Button 01 being pressed (otherwise, well, nothing will happen!). To change it to another button, just change the virtualButton number. The legal range for the virtualButton number is 1 through 99. How many of those buttons you can use depends on your membership tier. Virtual Button 01 is free, but access to the other buttons requires a membership.


Browser URL

https://api.virtualbuttons.com/v1?virtualButton=1&accessCode=ACCESS_CODE 

 

IFTTT

When creating an Applet (https://ifttt.com/create)...

  • Choose an "if" service to trigger your Virtual Button and then choose Virtual Buttons as the "that" service (enter "Virtual Buttons" in the search box to find it).
  • Select the Virtual Buttons service and agree to connect to it by selecting the Connect button.
  • When the Patreon login window appears, log in and then select Allow to let IFTTT know who you are.
  • Choose the "Push a Virtual Button" action that appears (it's the only action available), choose which of your buttons you want to press from the drop-down menu, and select Create Action.
  •  Finalize the deal by pressing the Finish button.

Note that with IFTTT, you don't have to use or remember your access code -- IFTTT remembers it for you!
 

curl

curl https://api.virtualbuttons.com/v1 -H "Content-Type: application/json" -d '{"virtualButton":1,"accessCode":"ACCESS_CODE"}'

 

Windows PowerShell

Invoke-RestMethod https://api.virtualbuttons.com/v1 -Method POST -Body '{"virtualButton":1,"accessCode":"ACCESS_CODE"}'


Python

import json

import requests

body = json.dumps({

  "virtualButton": 1,

  "accessCode": "ACCESS_CODE"

})

requests.post(url = "https://api.virtualbuttons.com/v1", data = body)


Node.js

var https = require("https");

var body = JSON.stringify({

  "virtualButton": 1,

  "accessCode": "ACCESS_CODE"

});

https.request({

  hostname: "api.virtualbuttons.com",

  path: "/v1",

  method: "POST",

  headers: {

      "Content-Type": "application/json",

      "Content-Length": Buffer.byteLength(body)

  }

}).end(body);


Tasker (Android App)

Tasker's Net -> HTTP Request action works great with Virtual Buttons.

  1. Launch Tasker, go to the Tasks tab and tap the plus sign to create a new task. Give your task a name such as  virtualbuttons  and tap the check mark to accept.
  2. Tap the plus sign to add an Action, choose Net and then choose HTTP Request
  3. Fill in the URL field with the same sample URL sent to you in the Virtual Buttons Access Code email (this URL is also found in the Browser URL section above -- just  sure to replace ACCESS_CODE with your personal access code string).
  4. Tap the "back" button and then click the play button at the bottom of the screen to test this new HTTP Request Action.
  5.  If all is good, tap the "back" button again and then select the check mark to save your task. 

 

HomeSeer HS3 VB Script

The following script, saved with a .vb extension, works with HomeSeer HS3.  Just pass your button number (likely a 1) in the "Run a Script or Script Command" Parameters field.


Sub Main(ByVal vbutton As String)

  dim accessCode = "ACCESS_CODE"

  dim host = "https://api.virtualbuttons.com"

  dim path = "/v1?virtualButton="+vbutton+"&accessCode="+accessCode  

  dim result = hs.GetURL(host, path, True, 443)

  hs.WriteLog("msg", result)

End Sub


If you get  a "The request was aborted: Could not create SSL/TLS secure channel" error when running the above script, try adding this line just below the Sub Main line:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
 


Home Assistant

 Add this to Home Assistant's configuration.yaml file:


# Virtual Buttons API call

rest_command:

  press_virtual_button:

    url: https://api.virtualbuttons.com/v1?accessCode=ACCESS_CODE 

    method: POST

    verify_ssl: true

    content_type:  'application/json'

    payload: '{"virtualButton":{{virtualButton}}}'


Then restart the server (Configuration->Server Controls->RESTART) so it can digest the new changes. Now, to test out your new Virtual Buttons server:

  • Go to Home Assistant's Developer Tools->Services screen
  • Select "rest_command.press_virtual_button" from the Service menu
  • Enter this in the Service Data field (to press button 1):
    {"virtualButton": 1}
  • Select the CALL SERVICE button


Flic Smart Buttons

Check out this great blog post on how to use Virtual Buttons with physical Flic Smart Buttons:

https://okko.eu/flic-button-to-alexa-routine-1560e3844457 


ESP8266

See example sketch file at https://github.com/Thomptronics/ESP8266-Virtual-Buttons   

 


REMEMBER to replace ACCESS_CODE with your access code string in all of the above examples.


Questions, comments, compliments? Please email us at [email protected]