Adding buttons to a device causes the buttons to display on the device status page, and when a button is pressed, ButtonPress or ButtonPressEx is called in your plug-in.
To add buttons to devices call the HS interface function:
hs.DeviceButtonAdd(device as string, ref as string, name as string)
The parameters to this function are:
device = the device reference like "A1" or "[1" or whatever device code you assigned to devices that your plug-in created.
ref = the name of your plug-in. This is the same string that you return for the .name property. This is used by HomeSeer so it knows who owns the button.
name = the name string you want displayed on the button
You can also assign buttons when you create devices. Simply add the buttons to the .buttons property of the device.
The following example adds 2 buttons to the device "[1":
dv.buttons = IFACE_NAME & Chr(2) & "Arm" & Chr(1) & IFACE_NAME & Chr(2) & "Disarm"
The hs.DeviceButtonAdd() function can also be used to execute a script function when a button is pressed. Set the "ref" parameter to a script file and function. To execute the function "speak" in the script "speak_script.txt" and assign this to the device "z1" and label the button "Speak Now" use:
hs.DeviceButtonAdd "z1","speak_script.txt(""speak"",""hello"")","Speak Now"
To remove a button from a device call:
hs.DeviceButtonRemove DEVICE,NAME
The button with the given housecode/unitcode and name label will be removed.