Home automation with Tasker
In this post I’m going to be taking a look at the Xiaomi Yeelight Colour I ordered from AliExpress, and how I started experimenting with basic home automation for my room through Tasker.
The model of Yeelight I bought supports 24 bit colour reproduction (your standard [255, 255, 255] RGB values), controllable from the Yeelight app. The app represents one of my biggest issues with the Yeelight, and all IoT devices like it, which is their security risk. When you tell the Yeelight to turn on using the app, the command is sent to the light via one of three user-selectable servers: mainland China, Singapore and the US. This introduces some considerable latency when waking the light from its ‘OFF’ mode, as the request must go from my home network in London, around to the other side of the world to be processed in a server, and then sent back to my light once more.
Now, why is this inherently insecure? Well, aside from the possibility that someone could gain access to Yeelight users’ lights connected via one of these servers, there is the issue of Xiaomi themselves, as Chinese companies are notorious for taking liberties when it comes to users’ privacy. For potential attackers, having access to a device that may or may not have up-to-date security patches allows for an easy gateway into a private network. The issue of IoT device security has had massive ramifications in the past, with the Mirai attack on Dyn in 2016 utilising unprotected devices in the largest DDoS attack (Distributed Denial of Service) ever.
I obviously don’t want my light bulb to be part of a massive botnet in the future, so I’m working towards the stage at which I can block my bulb from the internet and have it run permanently through LAN commands.
I approached this experimental stage of my room automation with only two devices in mind: the light and my PC. The best solution to control them that I could think of was to use my phone. To control the bulb, I have the Yeelight app, and for the PC, I went with Unified Remote. In order to access these apps without human intervention, I used Tasker -- one of those apps that highlights Android’s capabilities as a mobile OS. I was then able to use Yeelight and Unified Remote’s Tasker plugins to carry out scripts I programmed.
One of the scripts I set up is triggered by the system’s alarm firing, which prompts the phone to turn on WiFi, then waits for it to connect before turning on the light with the ‘Sunrise’ preset, making the light slowly transition from a dim red up to a bright white over a 15 minute period. 2 minutes after the alarm goes off, the phone increases the system volume, reads out the current date using Google’s TTS engine (I plan on adding weather in the future), before muting itself again.
In everyday use, however, you also need to be able to turn on and off the lights without setting an alarm. To do this, I needed a trigger that could be easily accessed by Tasker, and at a low cost.
I decided to complete this with NFC tags, which I also bought from AliExpress, working in conjunction with this Tasker plugin. Using these, I created two profiles: one to switch on the light and the PC, and the other to switch them both off. The ‘on’ tag I placed underneath my mousemat, as that is where I often put my phone at my desk. When the phone senses that particular NFC tag, it sends a WOL packet to the PC, waking it, before sending the command to turn on the light. Finally, it turns off the phone display using the System Lock command. I really like the placement as it is completely concealed, but still works flawlessly as the mousemat contains no RF-blocking material.
On my door frame, I placed another tag, which switches off the light and PC in the same way as the first tag works, just in reverse.
After enjoying messing around with this setup, I have much more ambitious plans already underway to fully automate the room, removing as much manual interaction on my part as I can, whilst self-hosting the full system to ensure it is always running even in the event of an internet outage.
To keep up-to-date on this and future projects, join the mailing list by pressing the “Subscribe” button at the top of the page.
The model of Yeelight I bought supports 24 bit colour reproduction (your standard [255, 255, 255] RGB values), controllable from the Yeelight app. The app represents one of my biggest issues with the Yeelight, and all IoT devices like it, which is their security risk. When you tell the Yeelight to turn on using the app, the command is sent to the light via one of three user-selectable servers: mainland China, Singapore and the US. This introduces some considerable latency when waking the light from its ‘OFF’ mode, as the request must go from my home network in London, around to the other side of the world to be processed in a server, and then sent back to my light once more.
![]() |
| The Yeelight |
Now, why is this inherently insecure? Well, aside from the possibility that someone could gain access to Yeelight users’ lights connected via one of these servers, there is the issue of Xiaomi themselves, as Chinese companies are notorious for taking liberties when it comes to users’ privacy. For potential attackers, having access to a device that may or may not have up-to-date security patches allows for an easy gateway into a private network. The issue of IoT device security has had massive ramifications in the past, with the Mirai attack on Dyn in 2016 utilising unprotected devices in the largest DDoS attack (Distributed Denial of Service) ever.
I obviously don’t want my light bulb to be part of a massive botnet in the future, so I’m working towards the stage at which I can block my bulb from the internet and have it run permanently through LAN commands.
I approached this experimental stage of my room automation with only two devices in mind: the light and my PC. The best solution to control them that I could think of was to use my phone. To control the bulb, I have the Yeelight app, and for the PC, I went with Unified Remote. In order to access these apps without human intervention, I used Tasker -- one of those apps that highlights Android’s capabilities as a mobile OS. I was then able to use Yeelight and Unified Remote’s Tasker plugins to carry out scripts I programmed.
One of the scripts I set up is triggered by the system’s alarm firing, which prompts the phone to turn on WiFi, then waits for it to connect before turning on the light with the ‘Sunrise’ preset, making the light slowly transition from a dim red up to a bright white over a 15 minute period. 2 minutes after the alarm goes off, the phone increases the system volume, reads out the current date using Google’s TTS engine (I plan on adding weather in the future), before muting itself again.
![]() |
| My Tasker "WakeUp" profile |
In everyday use, however, you also need to be able to turn on and off the lights without setting an alarm. To do this, I needed a trigger that could be easily accessed by Tasker, and at a low cost.
I decided to complete this with NFC tags, which I also bought from AliExpress, working in conjunction with this Tasker plugin. Using these, I created two profiles: one to switch on the light and the PC, and the other to switch them both off. The ‘on’ tag I placed underneath my mousemat, as that is where I often put my phone at my desk. When the phone senses that particular NFC tag, it sends a WOL packet to the PC, waking it, before sending the command to turn on the light. Finally, it turns off the phone display using the System Lock command. I really like the placement as it is completely concealed, but still works flawlessly as the mousemat contains no RF-blocking material.
![]() |
| NFC tag antenna lines |
On my door frame, I placed another tag, which switches off the light and PC in the same way as the first tag works, just in reverse.
After enjoying messing around with this setup, I have much more ambitious plans already underway to fully automate the room, removing as much manual interaction on my part as I can, whilst self-hosting the full system to ensure it is always running even in the event of an internet outage.
To keep up-to-date on this and future projects, join the mailing list by pressing the “Subscribe” button at the top of the page.



Comments
Post a Comment