Our new Plugable PS-BTAPS1 is perfect for many different home automation projects, however, we understand that our Android and iOS apps may not fit the bill for every project, and we wanted to provide a way for hobbyists and programmers to develop custom applications that are able to interact with the device. We have for you today some instructions and sample code on how to trigger the device’s on and off functionality from a custom application. More information on how to perform more advanced functions, such as using the built-in timer, will be forthcoming at a later date.
The PS-BTAPS1 uses Bluetooth’s very simple Serial Port Profile for communication. All that is required to talk to the device is an open RFCOMM connection and then the right payload to be sent to trigger the device’s desired functionality.
There are two different payloads necessary for turning the device’s switch on and off:
0xCCAA03010101 will tell the BT-APS1 to flick its internal switch to ON.
0xCCAA03010100 will tell it to do the opposite, and switch to OFF.
To make this somewhat simpler to understand, we are providing a sample application written in Python 2.7. The code for the application can be found below:
All that is required to run the application is Python 2.7 and the PyBluez module, which can be downloaded here.
This sample application has a simple command line interface for making your PS-BTAPS1 switch on or off.
python btaps.py 00:00:00:00:00:00 on
python btaps.py 00:00:00:00:00:00 off
Replace 00:00:00:00:00:00 with your PS-BTAPS1’s Bluetooth Address. You can easily find your device’s Bluetooth Address like so:
Go to Control Panel -> Devices and Printers -> Right Click on your paired Plugable PS-BTAPS1(It should be listed as “Plugable”) -> Properties -> Bluetooth Tab -> Unique Identifier
Open a terminal and run:
This code has been tested under Fedora 21 and Windows 8.1. It should run on older versions of Windows and Linux without issues. Unfortunately, this sample code will not work under OS X due to lack of support in PyBluez. Mac OS X applications should still be possible using OS X native Bluetooth APIs.
More information on programming the Plugable PS-BTAPS1 should follow early in the new year. We can’t wait to see what cool and interesting projects are developed by the community!