I have recently purchased 4 Veho Kasa Bluetooth lights. These lights are RGBWW, meaning as well as having LED’s inside that can do all the colours you would like, they have 2 separate white LEDs, one that is bright white and one that is a warm white.
Out of the box, these bulbs are controlled by an application on your Android or Apple phone over Bluetooth. This gives you the tools to turn them on, off, change colour and brightness.
However, if you have an Amazon Alexa device at home, you may want to be able to control these with your voice, but unfortunately, Veho has not made them compatible (Alexa can’t control Bluetooth devices out of the box, you would need some sort of hub).
Bring in the Pi
Knowing that I wanted to be able to control these with my Alexa device, I set to work looking for solutions. After about 30 minutes of searching the web with Google* I found what I was looking for, some python libraries.
This would allow me to set my Raspberry Pi 3B up as a HUB and let me control my lights with my voice.
What do you need?
- Raspberry Pi with Bluetooth (So a Raspberry Pi 3, 3B + or a Pi 2 with a Bluetooth adaptor)
- HA Bridge Software: https://github.com/bwssytems/ha-bridge
- 1 or more Veho Kasa lights: http://www.veho-us.com/main/shop_detail.aspx?article=430
- Python TikTeck Library: https://github.com/mjg59/python-tikteck
- Android Phone
- This is required as Bluetooth devices pair with a Password and you will need your Android device to sniff the password.
- PC, Mac or Linux machine to read Android logs
Get Started
The first thing you will need to do is to set up your lights and pair them to your Android phone using the official VEHO Kasa application (https://play.google.com/store/apps/details?id=com.skytone.KasaBLE&hl=en_GB). You need to do this first as you will need to grab hold of your Android Logs to sniff the Pairing Password for use later.
Once you have paired up and your lights are working, you will need to turn on Developer Mode on your Android device.
With developer mode on, you will also need to install Android Debug Bridge (ADB) on your PC/Mac or Linux machine.
Get the connection string
You’ve made it this far, so this should be easy (famous last words).
You can do this is many ways, but the way I did it was on a Windows 10 PC with ADB installed and Notepad++.
You can see the following Tutorial on using LogCat: https://forum.xda-developers.com/showthread.php?t=1726238
The important thing is to ensure that the string you need is inside the log. You can do this by ensuring logging is on and opening the Veho Application and turning the lights on and off a few times.
The important string will look something like
E LedoBleSDK: login =skName=======[Smart Light]=======skPw==[password]
Where [password] will be a three digit code
Adding in Alexa
So now you have the password, you need to put this to use.
For this we will use HA Bridge, this excellent tool will mimic a Philips Hue Hub in code on a Raspberry Pi
I am going to assume that for this tutorial, you already have a Raspberry Pi running, with Bluetooth and using the latest version of Raspbian. If your not, visit the Raspberry Pi site and get set up.
Using HA Bridge
I’m not going to cover this here as it may change. Follow the instructions on the HA Bridge Github Repository: https://github.com/bwssytems/ha-bridge and come back when it is running.
You can download this onto your Pi with the following code
import sys, getopt
import tikteck
def connecttoBulb(b):
bulb = tikteck.tikteck(b, "Smart Light", "[PASSWORD]")
bulb.connect()
return bulb
def main(argv):
cmd = ''
value = ''
zone = ''
try:
opts, args = getopt.getopt(argv, "hc:v:z:r:g:b:", ["cmd=", "value=", "zone=", "red=", "green=", "blue="])
except getopt.GetoptError:
print("Usage: python veho.py -c <command> -v <value> -z <zone>")
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print("Usage: python veho.py -c <command> -v <value> -z <zone>")
sys.exit()
elif opt in ("-c", "--cmd"):
cmd = arg
elif opt in ("-v", "--value"):
value = arg
elif opt in ("-z", "--zone"):
try:
zone = int(arg)
except ValueError:
sys.exit(2)
elif opt in ("-r", "--red"):
red = arg
elif opt in ("-g", "--green"):
green = arg
elif opt in ("-b", "--blue"):
blue = arg
if zone == 1:
bulb = connecttoBulb("[MAC1]")
elif zone == 2:
bulb = connecttoBulb("[MAC2]")
elif zone == 3:
bulb = connecttoBulb("[MAC3]")
elif zone == 4:
bulb = connecttoBulb("[MAC4]")
if cmd == 'on' and value == "white":
bulb.set_state(0xff, 0xff, 0xff, 0xff)
elif cmd == 'off':
bulb.set_state(0x0, 0x0, 0x0, 0x0)
elif cmd == 'dim':
value = int(value)
bulb.set_state(255,255,255,value)
elif cmd == 'colour':
bulb.set_state(int(red), int(green), int(blue), 255)
if __name__ == "__main__":
main(sys.argv[1:])
You can download this code directly from Github using the following command on your Raspberry Pi.
WGET https://gist.githubusercontent.com/vwillcox/e2ab3e89914dc74ed917a486ccdc80a3/raw/4d2c95e66685db6d282cd00d94767d6b317e9822/veho.py
You will need to edit line 7 to copy in the password you found earlier.
Getting HA Bridge setup
Take a look at the image below, you can see I have setup all four sections (On Items, Dim Items, Off Items and Color Items). This will enable me to turn the lights on, off and change their brighness.
It’s worth noting at this stage, that although I have seup the color sections, this does not work with Alexa currently. It’s there for future proofing.
If you wanted to set the colour, you would need to setup a new Device and in the “On Items” specify some code to predefine a colour.
One you have filled in HA Bridge click Update Bridge Device.
Finally
Now you need to ensure Alexa finds your device, so speak the command “Alexa descover devices” and wait (if you have set your hot word to something other than Alexa, use your hotword).
If Alexa does not find it, refer to the HA Bridge website for help and advice.
If you have trouble with Alexa controlling the device after correct discovery you can talk to me on Twitter.