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

Just hangs.
root@raspberrypi:/home/pi# hcitool lescan
LE Scan …
E2:DC:4B:0D:AC:E6 (unknown)
E2:DC:4B:0D:AC:E6 PLAYBULB CANDLE

#!/bin/sh

if [ “$1” = “candle1” ]
then
candle=E2:DC:4B:0D:AC:E6
color_handle="0x0019"
effect_handle=“0x0017”

Can you make sure that you don’t have the MiPow App connected to the bulbs? Or anything connected for that matter. If there is any open session with another device, the scripts and php won’t work.

I did have my phone connect to it but bluetooth on my phone has been off during the test. the candle is currently on and fading in and out to random colors like default.

root@raspberrypi:/home/pi# ./find_handlers.sh E2:DC:4B:0D:AC:E6
A valid handle is required
Characteristic value/descriptor read failed: Attribute can’t be read
Characteristic value/descriptor read failed: Attribute can’t be read
Characteristic value/descriptor read failed: Invalid handle
Characteristic value/descriptor read failed: Invalid handle
Characteristic value/descriptor read failed: Invalid handle
Characteristic value/descriptor read failed: Invalid handle
Characteristic value/descriptor read failed: Invalid handle

Possible color handles found
-e -e -e
0x000A 05 00 ff ff
0x0019 00 00 00 00
0x001B 64 ef bc ce

Possible effect handles found
-e -e
0x0007 10 00 20 00 00 00 58 02
0x0017 00 00 ff 92 03 00 0a 00

I wonder if this is the problem that @jkrischt was having with a bad version of gatttool. Perhaps he can comment.

Thanks, Trying 5.21 now. I tried via apt-get but same issue.

got it working using bluez 4.101. Acording to this project there is a bug in newer bluez. https://github.com/ianrenton/playbulb-tools

I actually got it working with the latest version of Bluez. I simply just needed to purge the default install of Bluez that came down with Raspbian and re-install it again all using apt-get. Worked like a charm after I did that. Something must be wrong with gatttool that comes down with the Raspbian build. Took me a while to figure out something so simple like that!

Also, I picked up a Playbulb Comet (the light strip) and it too works perfectly! Every device other than the candle for me has used these handles:

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

Brad

Glad you got it working!

Got it working with a fresh install of jessie and apt-get install bluez.

Eric - Any way to get a wider spectrum of colors through SmartThings? I tried digging through the code and for some reason I can’t figure it out.

Thanks!

Brad

Yeah, I “adjust” the color to a close common color because I was finding the colors to be a little inaccurate. You should be able to disable that by changing:

else if (value.hex) {
       log.debug "setting color with hex"
       def rgb = value.hex.findAll(/[0-9a-fA-F]{2}/).collect { Integer.parseInt(it, 16) }
       def myred = rgb[0] >=128 ? 255 : 0
       def mygreen = rgb[1] >=128 ? 255 : 0
       def myblue = rgb[2] >=128 ? 255 : 0

to:

else if (value.hex) {
       log.debug "setting color with hex"
       def rgb = hexToRgb(getScaledColor(value.hex.substring(1)))
       def myred = rgb.r
       def mygreen = rgb.g
       def myblue = rgb.b

I don’t have time to test it, but I think it will work. @jkrischt I tested it and had to make an adjustment to the code. Let me know how it goes.

Thanks Eric! I tested it a few days ago but wanted to attempt to solve it myself before I bugged you. However, you beat me to it and your solution works perfectly.

Brad

I am new to Smartthings and coding but going to give it a shot. I would like to work on this type of project but use an Arduino rather than a raspberry Pi. Would I actually be able to do this or is that wishful thinking?

The arduino would be significantly different. The majority of this guide wouldn’t apply. You would basically have to start from scratch.

Ok, sounds fair. Thank you for the response back.

This is awesome… thanks for sharing, @erocm1231 ! I’ve got this working with Port 80 of my Pi, but I don’t seem to be able to configure any additional ports on my Raspberry Pi 2.

I’ve updated ports.conf with:
Listen 81
Listen 82
Listen 83

I’ve updated 000-default.conf with:
<VirtualHost *:80 *:81 *:82 *:83>

And I’ve restarted Apache:
systemctl restart apache2

…but I still can’t access the additional ports. For example, going to 192.168.1.10:81 (the IP address of my Pi) returns a “Page cannot be displayed” error. Port 80 works fine. Does anyone have advice for setting up the additional ports on the Raspberry Pi?

Is a firewall enabled? Try:

systemctl stop firewalld

or

systemctl stop iptables

and then see if it connects. If it does, then you will have to add some firewall rules.

Thanks Eric, I am always amazed at the amount of great applications you produce for smartthings which make the whole system more affordable for many of us. Do you foresee using an ESP32 to control these lights?

Hmmm, do you mean using the ESP32 in place of a Chip or Raspberry Pi? I would have to research how much Arduino support there is for the ESP32. It looks very interesting.