chebe: (Candles)
The Ikea Trådfri lights look very interesting. While not cheap, they are much more affordable than other wireless 'smart' lighting. They don't do RGB colours (yet), but you can control the colour temperature; ordinary neutral soft yellow, a warm orange, or a bright white. You can also dim the lights, and of course, turn them on and off. They don't do too much, but what they do they do well, and there don't appear to be any major security holes. But most interestingly, they use ZigBee, and seem to be built on top of a lot of open source stuff. Which means, there are already tools to play with them.

First thing you're going to need to do is get some Trådfri lights. They do have a starter kit, but I wanted the smaller E14 bulbs so I built my own (for not much extra). You'll need the Gateway hub, a control device (remote control definitely works, I don't know about using the dimming set, or motion sensor instead), at least one bulb, and have a lamp/socket to put it in.



Supplies; gateway, remote control, two E14 bulbs, and two lamp shades
Photo by chebegeek



The Gateway has a companion app to set everything up. You pair the app (your phone) to the Gateway, then you pair the Remote Control to the Gateway. Then you add the bulbs (pairing through the Remote Control) one by one. The app lets you arrange the bulbs into separate groups, or lump them all into one if you prefer. Once all that is done, it's time to build your own control interface.

Mostly I followed this excellent tutorial from the lovely Pimoroni crew.

sudo apt-get install build-essential autoconf automake libtool
(Or on Fedora;
sudo dnf install build autoconf automake libtool)

git clone --recursive https://github.com/obgm/libcoap.git
cd libcoap
git checkout dtls
git submodule update --init --recursive
./autogen.sh
./configure --disable-documentation --disable-shared
make
sudo make install


You're going to need the Gateway IP address. You can log into the router, or scan the network. The Pimoroni tutorial found their's at 192.168.0.10. I found mine at 192.168.0.20, so it probably jumps in steps of 10 until it finds an empty slot.
There is a Security Code on the base of your Gateway, you'll need to make a note of it.

The endpoint protocol is coaps:// and the port is :5684, followed by 15001 to control bulbs individually, or 15004 to control as a group.

A good way to start is by sending info requests to both endpoints;
coap-client -m get -u "Client_identity" -k "your_security_code" "coaps://192.168.0.20:5684/15001"
You'll get back an array of devices;
[65536,65537,65538]
It's a bit predictable. The first number is your remote control, the next two are bulbs, in the order you paired them.

coap-client -m get -u "Client_identity" -k "your_security_code" "coaps://192.168.0.20:5684/15004"
Also gives you back an array, but with the group ids, which seem much less predictable. (You can also find the group ids in the app.)

You can append the ids to the requests to get more information about each. Helpfully, there is an English description (i.e. "TRADFRI remote control", "TRADFRI bulb...", etc) returned in each.

The bulbs have a field "3311" with detailed state information. You can set parts of this to control the lights with -m put commands, e.g.;
coap-client -m put -u "Client_identity" -k "your_security_code" -e '{ "3311": [{ "5850": 0 }] }' "coaps://192.168.0.20:5684/15001/65537"
"5850" controls on/off and takes 0 or 1.
"5851" controls brightness, and takes values between 0 and 255.
"5709" and "5710" seem to work together to control the colour temperature. Valid values can be found by using the Remote Control, and then querying the state. The three main ones seem to be;
-e '{ "3311": [{ "5709":24933, "5710":24691 }] }' for bright white,
-e '{ "3311": [{ "5709":33137, "5710":27211 }] }' for warm orange,
-e '{ "3311": [{ "5709":30138, "5710":26909 }] }' for neutral yellow.


But this is all from the terminal. There is a nice python wrapper (with come convenience calls) if you want to start calling it from python, which is helpful if you want to start using python libraries for interfacing with hardware on your Raspberry Pi Zero W. But you'll find all of that in the tutorial.

There's also so much beautiful info in the thread that started all this. Have fun!



Ikea Trådfri lights controlled from Raspberry Pi Zero W
Photo by chebegeek

chebe: (StepIntoTheLight)
This is the Raven USB stick. It is a network evaluation tool for ZigBee networks. You can use it with the killerbee framework/toolkit to passively listen in on network traffic.



Which is great, until you want to use some of the more active features of the toolkit. The toolkit comes with an active firmware, but first you have to load it onto the Raven.

Another good use for a Dragon )
Page generated 2017-Oct-18, Wednesday 07:18 am
Powered by Dreamwidth Studios