Control: LED Strip Notifications
LED Strip Notifications:
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.
As you may recall in my first video on this channel I demonstrated that when I opened the door the LED strip changed color. 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 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.
Let me give you a scenario. Im sitting at my desk with noise canceling headphones on working as fast as I can, to get the next MK-SmartHouse video finished. Then out of nowhere I hear “What you up to?” I jump and almost get a heart attack. What happened was someone entered the house and snuck up on me. This scary situation could be avoided, and let me explain how. 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 it goes back to the previous state. Now I expect this person and will not be surprised. The best part is you can setup this alert system for any rule. Since we have established a practical scenario let me show you how to set it up.
The items needed to complete this guide are the following: 1. 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. 3. 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 because those are the place where I give sneak peaks on when videos are releasing and also where I ask for your input on topics and future videos.
1. The first thing we have to is ssh into the pi so on windows use putty and mac use terminal.
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 and press enter.
3. 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.
4. 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.
5. Next we are going to modify the rules file so type in sudo nano /etc/openhab2/rules/home.rules and press enter.
5.5. The first thing we have to do is import the map variable types so type in import java.util.Map and press enter.
6. The second thing we have to do is create variables to hold the current states of the LED strips 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.
7. 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 system switch. So type in
hsbValueTemp1 = storeStates(MKLEDStripControl1Color)
before the if statement and press enter.
8. If you named your LED strip differently than mine in the items file then cange everywhere you see MKLEDStripControl1Color with the item name of your LED strip.
9. Let me explain what this does, first it initializes the temp value with the current state of the LED strip. Then it sends a command to the LED strip with the new color to alert with, I have set mine to red.
10. If you want to change the color then go to colorizer.org and in the HSV / HSB section play around with the sliders to the color you want.
11. Once you chose a color, replace the 3 numbers in your rules file with the numbers colorizer provided you in the right column.
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 you would like.
13. On this next door sensor I want both led strips to get the alert so I am going to is type in
hsbValueTemp1 = storeStates(MKLEDStripControl1Color)
hsbValueTemp2 = storeStates(MKLEDStripControl2Color)
And press enter.
14. As you can see to add another LED strip to the rule, I simply added another variable initialization, send command with the color and then a send command with its previous state.
15. That is it in the rules file, press control x then y and enter.
Awesome we are now done with the software! Let’s test it out!
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 turns red as well as the LED strip that is supposed to be behind my cubes but I have not done it yet.
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 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. Alright thank you for watching and If you have any questions leave them in the comments section below or head over to mksmarthouse.com/forum. Good Bye!