MiPow Playbulb w/ Chip (or Raspberry Pi w/Bluetooth dongle)

(Eric M) #1

I have been working on a web service and Device Handler to control the MiPow Playbulb candles with a Chip computer (or Raspberry Pi with Bluetooth Dongle). Everything seems to be working great at this point.

Chip Setup

Note: Run all commands as root or put “sudo” in front of them

Install the following packages:

apt-get install apache2 php5 libapache2-mod-php5

Copy the contents of playbulb.php into a file located in /var/www/html/

vi /var/www/html/playbulb.php

Edit the section under “#### EDIT SETTINGS HERE ####”

You will need to put the MAC address of your Playbulb’s here as well as the handle that controls the color and effect. There is a good chance, that our handles are the same, but I did create a tool to help you figure it out if not.

You can get the MAC address from your Playbulbs by running the following command (make sure your candles are turned on and that you don’t have any phone connected to them):

hcitool lescan


$candles = array(“xx:xx:xx:xx:xx:xx”, “xx:xx:xx:xx:xx:xx”, “xx:xx:xx:xx:xx:xx”);

$color_handle = “0x0019”;
$effect_handle = “0x0017”;


SmartThings Setup

Install the device handler located here:

Create a new device in the IDE and assign the newly created device handler. You can set the Device ID to whatever you want as it will get automatically set when the device type is used.

Open the device on your phone and set the IP address and the port of the Chip, and Device ID of the candle(s) you want to control. The format of the candle Device ID is simply candle[x] where x corresponds to the order of the MAC address that you put in the playbulb.php file. You can also go to http://ipaddressOfChip/playbulb.php?config=true to view the Device IDs. You can place multiple devices by comma separating them. For example, if you want to control candle 1, 2, and 3, you would put “candle1,candle2,candle3” (without quotations - notice NO spaces between as well).

At this point you should be able to control your candles (as long as they are within range of the Chip).

Additional Candles

Because of how SmartThings assigns Device IDs to LAN devices, if you want additional device types for candles, you have to add extra ports to your Apache config on the Chip. So, if you want to have one SmartThings device that controls 3 candles and then 3 individual devices that control the same candles individually, you would need 4 ports.

Add the following to /etc/apache2/ports.conf

vi /etc/apache2/ports.conf

Listen 81
Listen 82
Listen 83
Listen 84

Restart apache

systemctl restart apache2

When creating another MiPow device in SmartThings, just use an unused port. I probably could get around this by creating a “Bridge” type SmartApp, but I haven’t gotten to that point yet.

Finding Bluetooth Handles

On github download the tool that I created called find_handle.sh.

Make it executable and run it against one of your candles and it will give you some possible choices to try for the handlers.

chmod 755 find_handle.sh
./find_handlers.sh xx:xx:xx:xx:xx:xx

Raspberry Pi

To use the Pi, you will need to get a compatible Bluetooth LE dongle. You will also likely need to compile gattool.

Let me know if it gives you any problems and I will help walk you through it.

Raspberry Pi specific instructions:

wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.37.tar.gz
tar -zxf bluez-5.37.tar.gz

cd bluez-5.37
./configure --enable-library

make -j8 && sudo make install
cp attrib/gatttool /usr/local/bin/

Home Depot selling applights
Alternatives to Sylvania GardenSpots for landscape/holiday lights?
CHIP/Pi Zero W & VLC Thing/Big Talker = SONOS KILLER!
(Eric M) #2

I finally got around to making a video of the device handler in action. Perhaps I can adapt the code to work natively on the SmartThings Hub v2 when they make the Bluetooth radio available, but until then it is working great with the C.H.I.P.

Edit 3/5/2016: I have modified the device type to support multiple handles. I did this so I could support the MiPow color bulb. Not a bad bulb for less than $20!

(LJ) #3

Really nice! I will buy a few and have fun with a Pi Zero and RM so I can light them up with my dinner rule!


(Brad) #4

Raspberry Pi setup and Playbulbs on the way. Ubuntu Mate worked really well for me (Raspbian was a mess). This looks awesome and can’t wait for my new toys to come in the mail :slight_smile:

Thanks for putting this together.

(Brad) #5

I finally got around to checking out my new candles with the Raspberry Pi that I setup a couple weeks ago. All looked really good on the Pi. I was able to run ‘hcitool lescan’ and get my MAC Address of the bulb. Loaded up /playbulb.php?config=true from a separate PC to see that it was setup with candle1. I also ran find_handle.sh with no issues and saw my handles should match up to your default.

I also have no issues installing the Device Handler and setting up a device in SmartThings.

However, of course, nothing happens when I try use the device I setup. I believe it is certainly trying to do something though…the second I attempt to do anything with the device I created in SmartThings the bulb is no long discoverable in my Playbulb app. As soon as I reboot my Pi, I can discover and use it again through the app. I can repeat that over and over again, so I know my Pi is connecting and attempting to do something with bulb. Also, as soon as I try to do anything with my ST device, find_handle.sh starts to fail saying device is busy. Need to reboot my Pi to use the tool again.

I make sure to disconnect the bulb from the Playbulb app before attempting to use it through ST.

I am not entirely sure where to go from here. I’d like to test out whatever I can bypassing SmartThings to see if I can the bulb to work through linux. Any ideas? I’m far from a linux expert…just enough to be dangerous.

Thanks for putting this together!


(Eric M) #6

There are a couple tools you can use to test things at the Linux level. I have created a script called playbulb.sh that is in the same repository as the other files. Make sure you make it executable and that you edit the first part of the file with your mac addresses and handle numbers. Then execute the script as follows:

./playbulb.sh candle1 red
./playbulb.sh candle1 blue
./playbulb.sh candle1 off

The command should return pretty quickly if it is working. If you get any errors let me know.

You can also via a browser go to


And it should output some json responses.

Oh, and make sure that you don’t use the MiPow app while doing all of this because it will lock the communication and block the Pi from talking to it. The SmartThings setup works so well for me that I no longer use the MiPow app at all.

Let me know how it goes!

(Brad) #7

Getting closer (I think)

Thanks to your script I manually tried running gatttool at the command line with what you were doing at the end of the script.

For Example:

gatttool -b 8A:75:4B:0D:AC:E6 --char-write -a 0x0019 -n 00ff00ff

That locked up and hung up any connection the bulb from another device (like my app on the phone). As soon as I canceled out of that it freed it up. That explains why my candles were locking up before and a reboot would fix it.

So having never used gatttool before I looked in to the app details some more. I discovered I could enter the tool in Interactive mode to try more directly.

gatttool -b 8A:75:4B:0D:AC:E6 -I

I connected to the device and entered in the handler and color that way:

[8A:75:4B:0D:AC:E6][LE]> connect
Attempting to connect to 8A:75:4B:0D:AC:E6
Connection successful
[8A:75:4B:0D:AC:E6][LE]> char-write-cmd 0x0019 00ff00ff

That worked like a charm! I could do anything I wanted with the device in that interactive mode. So it seems the gatttool command line you are using does not work on my system. Going to try to dig a little more in to it over the next few days, but I’m getting closer. I assume the php script just runs the same gatttool command as at the end of the playbulb.sh script? If I can get the command line working, it should be a simple update to the php script.

At this point, I’m thinking it has to be the fact I’m using a Pi with Ubuntu Mate rather than Raspian.

Thanks again for working on this!


(Eric M) #8

I remember reading a long time ago about some versions of gatttool being broken in the way you are seeing. Did you use the version of bluez that I posted in my first post? Version 5.37? If you can get gatttool working properly, everything else should fall into place.

(Brad) #9


I found multiple other people who had this same problem using Ubuntu Mate with a Raspberry Pi. Downgrading to an older version of Bluez seemed to work for them. However, since I am far from an expert in the Linux world, I could not get it to install correctly

So I decided to restart all over since I learned a few things. I went back to Raspbian and this time I did not manually install Bluez-5.37. When I would do that, it would require me to load up 7 or 8 other missing packages (like glib) and that would hose Raspbian for some reason. Instead, this time I just used this command to load it up automatically:

sudo apt-get install bluetooth blueman bluez python-gobject python-gobject-2
(would I really only have needed bluez?)

This did the trick for me. gatttool worked instantly when the install was done. Loaded up the rest of the scripts and it works perfectly in ST.

Thanks Eric! I’m loving this right now.

Now I hope to add on to this project a little bit. I have Mopidy working on a couple Orange Pis I picked up which I atached to speakers. I picked up a Playbulb Color with the built-in speaker. It looks like I should be able to attch to the speaker with Mopidy’s bluetooth extension and then control the light at the same time in ST. Create a nightlight for my kids and get rid of those 20th century CD players in their rooms :slight_smile:


(Brad) #10

Tested out my Playbulb Sphere as well. Works perfectly with these settings:

Color Handle = "0x001B"
Effect Handle = “0x0019”


(Antony Pugh) #11


I need a Pi now.

I have a few candles now. Wife loves them.

Any chance you can create one that works with the garden pucks?

Hopefully ST Bluetooth is sorted soon. But this is a great way to work around it for now.

(Eric M) #12

Great work! Glad you got things figured out. The Playbulb Sphere looks awesome. I might have to pick one up.

(Eric M) #13

It is most likely as easy as changing the Color Handle and Effect Handle. I bet it would be a piece of cake to figure out.

(Erica) #14


I recently purchased the Mipow Playbulb X and wanted to know how to connect it to SmartThings. I would really appreciate any assistance.

(Brad) #15

I successfully built out an Orange Pi PC with Eric’s code plus installed Mopidy (with Musicbox) to stream Spotify and music from my local PC. It works awesome on a Playbulb Color with the built in speaker. The speaker and light are two different bluetooth channels, so its no problem streaming music and setting the light at the same time! Perfect for my kids room as a nightlight + streaming nap time music.

Anyone with boards outside of a Raspberry Pi (like my Orange Pi PC), the new armbian Linux distro works fantastic. Bluez is already pre-installed and works out of the box with Eric’s setup. A little work if you need to compile wifi drivers, but instuctions are right on their site.

Also, Best Buy has Playbulb Candles and Light Strips on sale right now. Only $29.99 for the light strip which is $79 on Mipow’s website. I am guessing it works perfectly with this setup as well. Going to get one and try it out…a little cheaper then Philips Hue or Osram Lightify light strips :slight_smile:

Thanks again Eric for putting this together!

(Eric M) #16

Awesome! I actually sold my expensive ($50) a piece LIFX bulbs (because they would sometimes lose connection with my access point) and replaced them with ($15) Mipow color bulbs, and they have been rock solid. It has been a great setup for me as well.

(Michael) #17

raspberry pi: What are the commands to pair? I can scan and see the playbulb but do not know how to pair via CLI.

(Eric M) #18

You don’t need to pair it. If lescan is seeing, then that should be good enough.

(Michael) #19

Thanks. I am getting the following errors in the apache error.log. Ideas? No change to the playbulb lamp.

[Sat Apr 23 17:40:08.662697 2016] [:error] [pid 2209] [client] PHP Notice: Undefined index: config in /var/www/html/playbulb.php on line 17
[Sat Apr 23 17:40:08.663327 2016] [:error] [pid 2209] [client] PHP Notice: Undefined index: refresh in /var/www/html/playbulb.php on line 18
[Sat Apr 23 17:40:08.664044 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant off - assumed ‘off’ in /var/www/html/playbulb.php on line 84
[Sat Apr 23 17:40:08.664367 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant red - assumed ‘red’ in /var/www/html/playbulb.php on line 88
[Sat Apr 23 17:40:08.664617 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant green - assumed ‘green’ in /var/www/html/playbulb.php on line 92
[Sat Apr 23 17:40:08.664932 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant blue - assumed ‘blue’ in /var/www/html/playbulb.php on line 96
[Sat Apr 23 17:40:08.665183 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant white - assumed ‘white’ in /var/www/html/playbulb.php on line 100
[Sat Apr 23 17:40:08.665415 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant yellow - assumed ‘yellow’ in /var/www/html/playbulb.php on line 104
[Sat Apr 23 17:40:08.665637 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant magenta - assumed ‘magenta’ in /var/www/html/playbulb.php on line 108
[Sat Apr 23 17:40:08.665883 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant cyan - assumed ‘cyan’ in /var/www/html/playbulb.php on line 112
[Sat Apr 23 17:40:08.666111 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant flashred - assumed ‘flashred’ in /var/www/html/playbulb.php on line 116
[Sat Apr 23 17:40:08.666346 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant flashgreen - assumed ‘flashgreen’ in /var/www/html/playbulb.php on line 120
[Sat Apr 23 17:40:08.666576 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant flashblue - assumed ‘flashblue’ in /var/www/html/playbulb.php on line 124
[Sat Apr 23 17:40:08.666801 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant flashwhite - assumed ‘flashwhite’ in /var/www/html/playbulb.php on line 128
[Sat Apr 23 17:40:08.667023 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant flashyellow - assumed ‘flashyellow’ in /var/www/html/playbulb.php on line 132
[Sat Apr 23 17:40:08.667255 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant flashmagenta - assumed ‘flashmagenta’ in /var/www/html/playbulb.php on line 136
[Sat Apr 23 17:40:08.667482 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant flashcyan - assumed ‘flashcyan’ in /var/www/html/playbulb.php on line 140
[Sat Apr 23 17:40:08.667707 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant fadered - assumed ‘fadered’ in /var/www/html/playbulb.php on line 144
[Sat Apr 23 17:40:08.667899 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant fadegreen - assumed ‘fadegreen’ in /var/www/html/playbulb.php on line 148
[Sat Apr 23 17:40:08.668175 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant fadeblue - assumed ‘fadeblue’ in /var/www/html/playbulb.php on line 152
[Sat Apr 23 17:40:08.668359 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant fadewhite - assumed ‘fadewhite’ in /var/www/html/playbulb.php on line 156
[Sat Apr 23 17:40:08.668546 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant fadeyellow - assumed ‘fadeyellow’ in /var/www/html/playbulb.php on line 160
[Sat Apr 23 17:40:08.668729 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant fademagenta - assumed ‘fademagenta’ in /var/www/html/playbulb.php on line 164
[Sat Apr 23 17:40:08.668914 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant fadecyan - assumed ‘fadecyan’ in /var/www/html/playbulb.php on line 168
[Sat Apr 23 17:40:08.669097 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant faderainbow - assumed ‘faderainbow’ in /var/www/html/playbulb.php on line 172
[Sat Apr 23 17:40:08.669282 2016] [:error] [pid 2209] [client] PHP Notice: Use of undefined constant flashrainbow - assumed ‘flashrainbow’ in /var/www/html/playbulb.php on line 176
[Sat Apr 23 17:40:08.669485 2016] [:error] [pid 2209] [client] PHP Notice: Undefined variable: effect_handle in /var/www/html/playbulb.php on line 188

(Eric M) #20

Those are actually warnings for my “relaxed” method of php programming and shouldn’t affect the functionality of the app. Can you try the command line tool that I created (in github) to see if that works first? I think the PHP is working correctly, but maybe the bulbs/candles aren’t getting the command.

You have to configure the beginning of the script with the MAC addresses of your devices, and then the syntax is:

./playbulb.sh candle1 red
./playbulb.sh candle1 blue