Hi all.
I’m one of the lucky ones to have received this long-awaited Kickstarter product finally after years of waiting.
I’ve been experimenting with BLE control and thought I’d write up a tutorial for anyone else who receives theirs and wants to control via OH.
Requirements:
Lightpack 2 from Woodenshark
BLE capacity from OH host or from a Raspberry pi - I’m using a Pi Zero W as I have OH on a Synology NAS
SSH access to host (and Rpi if using)
Notes:
I found the BLE on the Lightpack pretty short-range. I had to install a Rpi basically right next to it to get consistent access.
1. If using a Rpi for BLE, you need to get ssh access from your OH installation to the Pi. Best to do so with a key installation on the Pi. This tutorial is pretty good if you don’t already have this setup.
2. Create a bash file on the Pi.
I called mine lightpack.sh.
#!/bin/sh
sudo hciconfig hci0 down
sudo hciconfig hci0 up
if [ $1 = 1 ]
then
gatttool -b MAC-Lightpack --char-write-req --handle=0x001c --value=30
elif [ $1 = 2 ]
then
gatttool -b MAC-Lightpack --char-write-req --handle=0x001c --value=31
elif [ $1 = 3 ]
then
gatttool -b MAC-Lightpack --char-write-req --handle=0x001c --value=32
fi
Switch out MAC-Lightpack for the MAC address of the lightpack, obviously.
You can create elif rules for any combination of the Lightpack settings below. I’ve set a sitemap switch to send numbers to the shell script for each mood setting, for example.
3. Create your thing, items and sitemap entries.
thing:
Thing exec:command:Lightpack "Lightpack" [ command="ssh user@ip-oh bash lightpack.sh %2$s", interval=0, autorun=true ]
Switch out user@ip-oh for the username@ip-address of your RPi.
item:
String Lightpack_Command "Lightpack" { channel="exec:command:Lightpack:input", autoupdate="false" }
sitemap:
Switch item=Lightpack_Command label="Lightpack" mappings=[1="Power", 2="Media", 3="Mood"]
and/or
Switch item=Lightpack_Command_Moods label="Lightpack Moods" mappings=[11="Birch", 12="Fireplace", 13="Starry", 14="Cafe", 15="Aurora", 16="White"]
Of course, you might want to change brightness, input or mood settings. The BLE characteristics are as listed below:
Power Off:
--handle=0x001c --value=30
Media mode:
--handle=0x001c --value=31
Mood mode:
--handle=0x001c --value=32
Inputs:
Input 1:
--handle=0x0018 --value=31
Input 2:
--handle=0x0018 --value=32
Input 3:
--handle=0x0018 --value=33
Input 4:
--handle=0x0018 --value=34
Brightness:
0%
--handle=0x0010 --value=2D32
25%
--handle=0x0010 --value=2D31
50%
--handle=0x0010 --value=30
75%
--handle=0x0010 --value=31
100%
--handle=0x0010 --value=32
Mood lighting:
Birch Grove:
--handle=0x000c --value=62697263685F67726F7665
Fireplace:
--handle=0x000c --value=66697265706C616365
Starry Night:
--handle=0x000c --value=7374617272795F6E69676874
Cafe:
--handle=0x000c --value=63616665
Aurora Borealis:
--handle=0x000c --value=6175726F72615F626F7265616C6973
Still Light White:
--handle=0x000c --value=7374696C6C5F6C696768745F7768697465
More info at this gist. I hope this will be useful to someone else!