Yeelight and Hyperion basic API and front-end

By mattie, Fri 10 February 2017, in category Code

ambilight, api, hyperion, IoT, lightpack, python, raspberrypi, rpi, yeelight

Over the last week I've been looking into creating a basic web-service to easily interact with my lights around my flat. Currently, I have two Yeelights and a LightPack, which is located on the back of my TV.

Stuff tied into this

Cool things it can do RIGHT NOW

Cool things I'm thinking about doing with it


I'm running a SimpleHTTP server in Python to handle all GET requests. The requests check to see, firstly, if the device exists and if so, what effect to run on it. As an example: http://localhost:5000/device/effect. I thought this would make it easy to simply craft a HTTP GET rather than posting JSON to it. Also means I can use Tasker without having to use the Send/Except plugin, which is fine and also great, but takes a bit to setup. Not that I'm lazy or anything. It also means I can use IFTTT's Maker to easily hit the AIR QUOTES API AIR QUOTES

You can view my source on github. It was written over a few days and strongly requires a re-factor.

Setting up Tasker

This can be a repetative process, but you can also copy the tasks you edit. AutoVoice is completely optional of course, and only if you're a giant nerd and want to tell OK Google to do stuff. Also excuse the ridiculously sized images.

Creating a task is fairly simple. You just need to use HTTP Get to push commands off to the Python webapi

So, my profile for my Snapchat notification is this: SnapeChatte in Tasker. To do this..

Breaking it down...

Adding a HTTP Get request | Editing the Task

My "OK Google Dim Lights" profile is as follows:

AutoVoice in Tasker

The configuration for the above event looks like this: AutoVoice in Tasker Event


Yes, you can ping your light globes now; what a future we live in.

It took me a while to workout how to enable the TCP JSON service on these lights. Turns out you need to download the Developer Mode application, then enable developer mode on each light globe. Xiaomi have also included a very comprehensive API documentation. But I'm being super lazy and using the python-yeelight package because it does pretty much everything I want it to do.


It was a pretty fun project. I think I'll need to upgrade my Raspberry Pi if I'm going to be adding text-to-speech. It's already processing video through to Hyperion! Also, please don't DDoS my lightbulbs. Thank you kindly.