FREE Shipping on orders over $49 USA $99 INTERNATIONAL

Control: Blinds Control MQTT OpenHAB ESP8266 Software

Blinds Control MQTT OpenHAB ESP8266


What is going on people of the smart house society, Matt here from and in this video I’m going to show you MK-BlindsControl firmware version 2 and how to set it up. You don’t want to skip this video, this is a major update.
Over the past few weeks I wrote new firmware for all of my MK-SmartHouse devices and the next few videos are going to be covering firmware for each device. This is not a small update. Not only is there now full support for Home Assistant but there is two way communication, setup through your mobile phone, MQTT Authentication support, a status portal and much more. I even have a feature that makes the blinds slower and quieter because some of you were complaining that is to loud for you. In this video I am going to cover how to connect the device to openhab but if you would like to connect it to home assistant I will leave the home assistant item config in the bottom of the description. I will make a complete video on it in the future. Stick around for this whole video because at some point I am going to announce a special message regarding the devices. Also, as you are watching write down what you think is new in this update and post it in the comments section, I’m curious if someone can list every single change. I will not be making two separate videos using Mac and Windows because the process is really similar the only difference is that on mac you use Terminal to ssh and on Windows you use putty.
Those of you that don’t know the blinds control is a device I created that like the name suggests can control your blinds through Alexa, Google, OpenHAB, Home Assistant and MQTT. Let me give you a demo Alexa set MK Blinds to close and If I open the openhab app I can open, close set it to half or even use the slider and set it to a custom number. It makes life really easy because every day they automatically open and close, one less thing I have to do. I also have a version where you can control 3 blinds from 1 control box!
Starting today all kits and assembled devices will come with firmware already flashed on the device. So if you buy a diy kit all you have to do is solder the components because the esp8266 will already be flashed and if you buy an assembled kit then it is ready to go just plug it in. 
To celebrate this achievement you can use the coupon code “v2” and get 10% off your entire order. So, you will be getting a device whether it be a kit or assembled that already has the firmware flashed and 10% off! If that’s not a deal I don’t know what is. I also don’t know when I am going to end this coupon so don’t wait head over to now or after the video is over! Any purchases made on the store directly help out the channel and allow me to make more devices and videos. There are a couple devices I want to make but I can’t due to funds so if you ever wanted to support me now is a very good time and I thank you in advance.
If your device has no firmware on it or the web updater on your device does not work, then there are some hardware things that we need besides a computer. We are going to need an arduino of some kind preferably a UNO or a MEGA equivalent with its usb cable of course and male to male dupont jumper cables. Don’t worry we won't be using the arduino IDE. The links to all the devices, 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. I have also post things that only a true smart home enthusiast would appreciate.
At this point, if you have a preflashed device then you can skip to the time on the screen now.  
First we have to download the firmware from my website so go to the Links+Downloads page enter your email and press download file, I require an email so that way if I make a new firmware I will send you an email letting you know there is a new one available, then click on the link to go to the download and press the green download button. 
If you have version 1 firmware then simply go to that devices hostname.local/firmware or its ipaddress/firmware, it will ask you for your username and password this is the username and password you typed in the arduino IDE when you first flashed the device. This is the firmware update page. Click choose file, it will open up the file browser so navigate to your downloads folder and click on the MK-BlindsControl V2 Bin file and press the open button. Once it is loaded in the page click update. You should see the percents in the bottom left and after it is done it will say update successful! Rebooting.. Your device is now running V2. You can skip to the time on the screen now.
If you have no firmware on your device or want to reflash the device then you need to download PyFlasher. PyFlasher is the software we are going to use to install the firmware onto the esp8266 instead of using the arduino IDE. First we need to go to the links page and click on the link under PyFlasher to go to its latest release github page and find the latest one. At the time of recording the latest version is 3.0. If you have a mac then click on the dmg file and if you are on windows click on the exe file. It should download to your computer. Then go to your downloads folder and double click on it. Go through the installation process of the software. Once it is installed open it, if you are on mac go to launchpad and click on it. If on windows go to taskbar and search for it. This software may look a little intimidating but it is really easy. But first we need to connect the esp8266 to the computer. The first thing we are going to do is grab the arduino and put a jumper cable from RES to GND. Then grab the Blinds Control and connect all the pins to their corresponding spots so, TX to TX, RX to RX, GND to GND, and 5V to 5V. Before we continue, check to make sure the 2 pin jumper is above PGM. Now plug the usb cable from the arduino into the computer. Click on the serial port drop down and remember what devices are listed. Then click on the refresh button next to the drop down. Click on the drop down and the device that wasn't previously on the list. If your device didn’t show up then you probably have a chinese arduino and need the CH341 Driver I will leave a link to the driver on my website it is really easy to install. Anyway next we need to choose the firmware we want to flash so click the browse button in the file browser that pops up navigate to your downloads folder and click on the MK-BlindsControlV2 bin file and click open. The next section in the software is baud rate, choose 115200. After that is Flash mode, choose Dual I/O. Lastly is erase flash, make sure that is set to yes. Great the only thing left to do is press Flash NodeMCU. You should see a bunch of red text on the screen, don’t worry about it. Just wait till it says Done. Great! Disconnect the arduino from the computer, then unplug the dupont wires in between the arduino and the device. After, take the 2 pin jumper and move it over so it is above RUN. Finally plug the device into the wall.
If you are a smart home enthusiast like me and want to show that you are an Elite Member of the smart home community then check out If you want to support my channel then check out the link in the description and grab yourself a premium quality hoodie, shirt or hat.
Now it is time to setup the device. Plug the device in and make sure there is power going to it. Next grab a mobile device and go to wi-fi. You should see MK-BlindsControl and some numbers. Tap on that wifi network. It will bring up the device configuration portal. If it does not bring up the portal then go to your web browser on your phone and type in There are 4 buttons, the first button is the one we want to press but I’m going to go over the other buttons first. The second button is the same thing as the first one except it does not scan for wifi network you would manually type in your SSID and Password. You would press this one if you have a hidden wifi network. The next button is info and it just shows you some information about your device. The last button just does a power cycle on the device and restarts it. But, let’s tap on the Configure WIFI button. This page contains everything you need to connect the device. The first section is where you connect to wifi so from the list select your wifi network and type in its password. The next section is the Hostname / MQTT ID and this is where you name the device I am going to call mine MK-BlindsControl1 you can call yours the same thing if you want. Remember what you name it as this is how we are going to access the device’s status page. The section after that is MQTT. In the first field type in your MQTT or openhab server’s ip address. The next field is the port which unless you use a different port you do not need to touch. In the MQTT topic field type in the topic you want the device to listen to commands to I am going to type in the same topic I did in the previous software version and you can use the same topic as well MK-SmartHouse/utilities/MK-BlindsControl1 this actually brings up a good point. If you have multiple blinds control then all you have to do is make sure they have a different hostname and mqtt topic. What I do is just increment the last number of both. The next fields in the MQTT section are regarding authentication, if you are following along with how I do things on my channel then do not worry about it and just leave it at false. But, in my last software version there were some people that had authentication on their MQTT servers in that case change the FALSE to TRUE and enter your username and password. I would like to give a shout out to Coffehedake on the MK-SmartHouse forum for figuring out how to do authentication using my previous firmware. Thank you! Web Updater is the next section and what web update does is create a webserver on the device so we can see the status of the device as well as update the firmware in the future. In the first 2 fields create a username and password to access the web server. Make sure you remember them. The field after that is the path to update the firmware, you can change it if you like I am going to keep it at /firmware. I will show you how to access all of this later. The final section is brand new to V2 and that is the option to make the blinds move slowly and quietly. What that means is if you set this to true the blinds will move slow to whatever position you want but it will be a little bit quieter than the previous firmware. Here is a demo of it set to FALSE as you can see the blinds move fast, I personally like this one. Here is a demo of it set to TRUE, the blinds move slow but is quieter. This is entirely your preference. Alright, that is it now press the save button. The device will now restart and boot using the settings you gave it. If the device restarts and shows its wifi network again that could mean you either typed in the wrong wifi password or you missed a field. If the device does not show up in your wifi network list that means it successfully connected to wifi. 
This step is optional and not required but, to confirm that it flashed correctly and is working you can fire up MQTT.fx, connect to the server and in the subscribe section type in # and press subscribe. If you do not have MQTT.fx then check out my Home Automation Server Setup Guide link is in the description. Then click on the publish tab. In the topic bar type in the subscribeTopic that we wrote in the blinds control device code that we flashed. Next in the message box type in any number 0 - 100 and press publish. If the servo motor moves then that is very good. Now go to the subscribe tab you should see two messages the first message is the command you sent and the second one is the current position of the servo after it executed the command. This means that now the device give feedback after they execute commands.
Now the device is complete and just needs to be added to OpenHAB. So ssh into your pi or whatever your server may be. If you are on mac use terminal and on windows use putty. The first thing we are going to do is create the Blinds Control item. So type in sudo nano /etc/openhab2/items/home.items and press enter, you may need to type in admin password. Then type in the comment //Blinds Controls then underneath that we are going to create the Blinds Control item. So type in Dimmer MKBlindsControl1 "MK Blinds [%s]" <rollershutter> [ "Lighting" ] {mqtt=">[broker:MK-SmartHouse/utilities/MK-BlindsControl1:command:*:default],<[broker:MK-SmartHouse/utilities/MK-BlindsControl1/state:state:default]", autoupdate="false"}
And press enter. 
Now open up your web browser and type in http://HOSTNAME.local I am going to type in http://mk-blindscontrol1.local it will ask you for a username and password. Type in the username and password you typed into the web updater section when you set up the device. You will now see all the settings of the device. I will go over this later in the video so don’t close the tab. But, we need the MQTT command topic so copy it. Now go back to the ssh window and if you have a different MQTT topic delete the topic in between the two colans and paste in your MQTT topic. Do the same thing for the status topic copy from the webpage and paste it in between the 2 colans. 
Now let me go over the item we created. It will allow us to control the Blinds Control. But let me go a little bit more in detail, the first part is Dimmer and since this device is a Blinds Control we need to control the position of the servo motor with numbers. The next part is the item name and I just used its hostname without the dash. After that is the label text and it is what shows up in the interface and how it is formatted with the name. Next to that is the icon name which is what picture shows up in the interface. After that is the item tag and what this does is allow this item to be used with home kit, amazon echo, and google home like you saw in the demo video. If you do not have either of those setup then you can check out my videos covering those topics. Then, we have the mqtt path to the device in there is the subscribeTopic we just pasted in. After that we have something new and that is the input status topic and what this does is openhab listens on this topic and uses this to change the status of the item in openhab. Let me explain with this new part if the device is unpluged and you keep sending it commands from openhab then the openhab item will not change because it is not recieving a response from the device. The next part in the item line is autoupdate false and that simply means the response from the blinds control will control the status. I have two blinds controls so I will paste it in again and change the item name, label text as well as the mqtt path to match that device’s subscribe topic. Thats it for the items file. Now press control x then y and enter. Next up is the sitemap file so we can control the device. Type in sudo nano /etc/openhab2/sitemaps/home.sitemap and press enter. It will bring up the sitemap. If you are following along with my series then we have many different frames in our sitemap. I am going to put the device in the frame called MK-Room. So go to the frame and type in:
Switch item=MKBlindsControl1 mappings=[0="Open", 56="Half", 100="Close"]
           Slider item=MKBlindsControl1
 and press enter, what we did is import the item into the sitemap so we can control it from the user interface. The controls it has is you can either press one of the three buttons, or use the slider. Again, since I have two I will also put the text in the JK-Room frame and change the numbers. Now press control x then y and enter. Before we go any further let's confirm that everything works so go to your web user interface and then Basic UI. You should see the Blinds Control item. If you press the buttons and move the slider you should see the servo move. Great! Now that we know the Blinds Control works let's make it automatically open and close at the times we set. In terminal type in sudo nano /etc/openhab2/rules/home.rules and press enter. At the bottom of the file type in 
//Set Blinds to half At 7 am
rule "Blinds half"
 Time cron "0 0 7 1/1 * ? *"
      sendCommand(MKBlindsControl1, 56)
//Set Blinds to close At 6 pm
rule "Blinds close"
 Time cron "0 0 18 1/1 * ? *"
      sendCommand(MKBlindsControl1, 100)
Let me explain what this does, the first rule sets the blinds to half everyday at 7 am the second rule closes the blinds everyday at 6 pm. If you want to change the times for the rules go watch my sprinkler system software video where I show you how to change cron expressions. Since I have two blinds I will also add those blinds to each rule. Now press control x then y and enter. That is it! The software is complete, now all we have to do is install the device in its final place which you can watch in the final installation video. But, before we close out this video I would like to show you guys more about the webpage on the device so go back to your web browser. So on this page like I mentioned before you can see all of your settings. But copy the link next to update firmware and paste it into the url bar. If in the future I release an new software this is where you would go to install it. One last thing I want to do is show you how to reset the settings on the devices. First unplug the device and plug it back in, then quickly move the jumper from RUN to PGM and wait 10 seconds, then put the jumper back to RUN and unplug the device and plug it back in. If you go back to wifi on your phone you should see the device. That concludes this complete guide to Blinds Control Software V2. In the description you will find links to all the parts and devices used in the video as well as a link to where I have a wide range of smart home kits that you can put together. Alright, if you found this video helpful click that like button and if you are a smart home enthusiast you belong on this channel so hit that subscribe button. If you have any questions leave them in the comments section below or join the community over at Good bye!