Door Opens → LED Strip Changes Color for 5 Seconds
45sA quick visual demo of a practical smart home feature instantly shows viewers a cool project they'll want to try.
▶ Play Clip"Delivers exactly what the title promises: a complete, tested guide with clear steps."
This video is a practical guide to making a smart home alert you when a door opens by changing the color of an LED strip. It walks through the entire OpenHAB 2 configuration, from SSH access and item identification to writing rules that temporarily change the LED color and then restore the previous state. The tutorial is aimed at users who already have a door sensor and LED strip controlled by OpenHAB.
The video demonstrates how to make a smart home alert you when a door opens, using an LED strip that changes color for 5 seconds before returning to its previous state.
When the door opens, the LED strip changes color for 5 seconds, then reverts to whatever state it was in before (a specific color or off).
You need a computer with SSH (Windows or Mac), a fully set up LED strip control, and a fully set up door sensor. Links to guides and parts are in the description.
Use PuTTY on Windows or Terminal on Mac to SSH into the Pi running OpenHAB.
Open /etc/openhab2/items/home.items, scroll to the LED strip controls, and note the item names of the color items (e.g., MKLEDStripControl1Color and MKLEDStripControl2Color).
In /etc/openhab2/rules/home.rules, import java.util.Map, create temp variables to hold current states, and insert code to store the state before sending a new color command.
Use createTimer(now.plusSeconds(5)) [| restoreStates(hsbValueTemp1) ] to restore the LED strip to its previous state after 5 seconds. Change the 5 to adjust the alert duration.
The side door triggers a blue alert on one strip, while the front door triggers red on two strips, confirming the rules work correctly.
By storing the current LED state and using a timed restore, you can create a non-intrusive visual door-open alert that works seamlessly with your existing OpenHAB smart home setup. The guide delivers a complete, practical solution for anyone with the required hardware.
What command opens the OpenHAB items file?
sudo nano /etc/openhab2/items/home.items
02:29
What import statement is needed for using Map variables in OpenHAB rules?
import java.util.Map
03:09
Which function stores the current state of an LED strip before changing it?
storeStates(itemName)
03:52
Which function restores an LED strip to its previous state after a timer?
restoreStates(hsbValueTemp1)
04:51
How do you make the alert color last longer or shorter than 5 seconds?
Change the number 5 in createTimer(now.plusSeconds(5)) to the desired number of seconds.
04:51
What website can you use to find HSV color values for the LED alert color?
colorizer.org
04:38
What SSH clients does the video recommend for Windows and Mac?
PuTTY for Windows and Terminal for Mac.
02:12
What file contains the definitions of your OpenHAB items?
/etc/openhab2/items/home.items
02:29
Which two LED strip item names are used in the example?
MKLEDStripControl1Color and MKLEDStripControl2Color
02:45
What does the command sendCommand(MKLEDStripControl1Color, "360,100,100") do?
It sends HSV color values (360,100,100) to the specified LED strip to trigger the alert.
04:23
Practical use case
Establishes a real scenario (being surprised by someone entering) that motivates the LED strip notification system.
SSH as the gateway
Shows a simple, platform-agnostic way to configure the system using PuTTY or Terminal.
02:12Storing state before change
The storeStates function is crucial for restoring the LED strip to its previous color or state.
03:52Timed restoration
Using createTimer with restoreStates is a clean pattern for temporary visual alerts.
04:51Live demo success
Both door sensors trigger the expected color changes, proving the rules work in practice.
05:20[00:00] Hey guys Matt here from MKSmartHouse.com and in this video I am going to show you how to make your smart home alert you when a door opens.
[00:14] As you may recall in my first video on this channel I demonstrated that when I opened Well, since then I have made some changes. What happens now is that when I open the door the LED strip changes to a color and then
[00:31] after 5 seconds changes back to the previous state the LED strip was in. The previous state of the LED strip could either be a color or off. Im sitting at my desk with noise canceling headphones on working as fast as I can, to
[00:46] Then out of nowhere I hear “What you up to?” What happened was someone entered the house and snuck up on me.
[00:58] So, I am still at my desk working hard and then someone opens the door down stairs. The LED strip behind my monitors turns red and stays like that for 5 seconds and then
[01:11] Now I expect this person and will not be surprised. Since we have established a practical scenario let me show you how to set it up.
[01:24] A computer running either mac or windows, I will not be making a seperate guide for each because we are just going to be using it for ssh. 2. A fully setup LED strip control which I have a complete guide for on my channel.
[01:40] A fully setup door sensor, I have a guide for this as well. The links to all the parts and guides mentioned are in the video description. Speaking of links in the description, follow @mksmarthouse on twitter, instagram and snapchat
[01:54] because those are the place where I give sneak peaks on when videos are releasing and also 1. The first thing we have to is ssh into the pi so on windows use putty and mac use terminal.
[02:12] 2. Next we are going to choose which LED strip or strips to send the alert to. To find that out we are going to look at the items file so type in sudo nano /etc/openhab2/items/home.items
[02:29] In the file scroll down to your LED Strip controls and choose which led strip or strips you want to use, they will be the color item type. I am going to be using both MKLEDStripControl1Color and MKLEDStripControl2Color.
[02:45] For some of the rules I am going to use 1 LED strip and some I will use 2. Once you figured out which ones you are going to use write them down and press control x.
[02:57] Next we are going to modify the rules file so type in sudo nano /etc/openhab2/rules/home.rules
[03:09] The first thing we have to do is import the map variable types so type in import java.util.Map The second thing we have to do is create variables to hold the current states of the LED strips
[03:24] so underneath the import statement type in var map hsbValueTemp1 = null make the same amount of variables as you do LED strips, since I have 2 I am going to make 2 variables.
[03:38] If you remember in the door sensor software videos we made rules for the door sensor that when the security system switch is on then it will send a notification to your phone. Well we are going to be putting a small piece of code before the check for the security
[03:52] hsbValueTemp1 = storeStates(MKLEDStripControl1Color) sendCommand(MKLEDStripControl1Color, "360,100,100") before the if statement and press enter. If you named your LED strip differently than mine in the items file then cange everywhere
[04:06] you see MKLEDStripControl1Color with the item name of your LED strip. Let me explain what this does, first it initializes the temp value with the current state of the Then it sends a command to the LED strip with the new color to alert with, I have set mine
[04:23] If you want to change the color then go to colorizer.org and in the HSV / HSB section 11. Once you chose a color, replace the 3 numbers in your rules file with the numbers colorizer
[04:38] 12. Finally after 5 seconds the rules puts the LED strip back to its previous state. If you wanted to make the alert color time shorter or longer then change the 5 to a number
[04:51] On this next door sensor I want both led strips to get the alert so I am going to is type createTimer(now.plusSeconds(5)) [| restoreStates (hsbValueTemp1) As you can see to add another LED strip to the rule, I simply added another variable
[05:06] initialization, send command with the color and then a send command with its previous That is it in the rules file, press control x then y and enter. Let’s test it out!
[05:20] First I am going to test out the side door as you can see when I open the side door the LED strip turns blue for 5 seconds and goes back to the previous color. Next up is the front door and when I open it, both the LED strip behind my monitors
[05:34] turns red as well as the LED strip that is supposed to be behind my cubes but I have Finally, that concludes this complete guide to getting alerts through the LED strip. In the description you will find links to all the parts and devices used in the video
[05:48] as well as a link to mksmarthouse.com/shop where I have a wide range of smart home kits that you can put together such as blinds, led strips, sprinkler system and door sensors.
[06:00] section below or head over to mksmarthouse.com/forum. Good Bye!
⚡ Saved you 0h 06m reading this? Transcribe any YouTube video for free — no signup needed.