Esp8266 Window Blinds MQTT

First of all a big thank you to those I borrowed code from:
@bruhautomation and the pubsub client from nick oleary

I had started to use my current setup that included particle photons, but there has been a lot of instability on the IDE and in the firmware for those devices lately and it was causing me more headache than it was worth. so I sunk $45 in six new esp8266 and solved all my problems.

The code is located here:

Things you will need:
A esp8266 I was using a NodeMCU chip from amazon
A servo (preferably analog) I use futaba S3003
A servo shaft coupler with set pin 3F/H25T Spline Servo to 1/4" Shaft Coupler (Set Screw) - ServoCity
Standard horizontal slat window blinds (plantation style will work too)
DIY mentality :wink:


  1. Create your device in your configuration.yaml (an example is on github)
  2. Load the code to the esp8266 using arduino ide
  3. Wire up your esp with the servo. (I set the com pin to D4 in the code)
  4. Put on your DIY hat finally and with your wife’s permission dissect and determine a way to hook this up to your window blinds (this often requires a bolt cutter)

Here is a video of the blinds in action:

things to note…
you will have to remove the manual pull string. I know, but don’t worry you won’t use it anymore… you will use the google home or amazon echo to open all of your blinds. Besides the whole point of home automation is to automate. Set this thing up with a light sensor and 4 hours before sunset close or partially close those blinds… keep tracking the sun every hour and continue to close them a little more until about 10 minutes before sunset and then open them up and enjoy that beautiful sunset.

also your action rod in the blinds might have to be cut down to fit the servo. use a bolt cutter and cut the end opposite where you will attach the servo.


I’ve been following Bruh’s progress somewhat. I’ll be first implementing this on my vertical blinds. Thanks for the code!

Here are some pics of the servos attached to the blind action rod. Even with a breadboard the esp sits nicely in the blind tray.

Also I ran a usb cable in the wall that runs down to a receptacle box. That box just has a usb port and then I run a wire from that to an receptacle in wall that has usb power. These wires are hidden by the couch so you essentially see no wires. Keep the WAF high!! (just don’t cut the holes in the wall right after your wife had the couches cleaned)


Not a problem. Let me know any feedback. I always follow KISS. I keep my code as simple and clean as possible, but if you have any recommendations feel free to post here or to pull from the branch on github.

@jjhtpc I’m trying out an esp8266 with a servo for blind control and I can see the esp8266 connecting to my wifi access point. It is failing to connect to my mqtt server, which is mosquitto running on my HASS system. I have mosquitto configured to use TLS on port 8883 and updated the port in the sketch file I uploaded to the esp8266. Does your code work with mqtt/TLS?

Here’s the error I’m getting:
Attempting MQTT connection…failed, rc=-4 try again in 5 seconds

Thanks for any help, I’m a newbie with the esp8266. This is a really cool solution if I can get mine working.

Switched back to port 1883 since it’s on my internal network and it works like magic. I now have a working light in HASS that controls the server through the esp8266. Love this stuff. Now for actually mounting it in some blinds :slight_smile:

That’s what I was going to recommend. I don’t use TLS so I can’t speak to it.

Works like a champ using port 1883. Thanks so much for posting your project and code, it was really helpful in getting this working. I’ve never done anything Arduino before, I bought a NodeMCU ESP8266 for the blinds. Now I’m looking for other things I can use them with.

Looks like I was working on my project at the same time you were

I submitted a pull request that got put into 44.2 so now the MQTT Cover can have tilt operation. I’ve got a pull-cord switch that allows someone local control of the tilt of the blinds. I’m still waiting on some pulleys from China so I can test the up/down.

It appears so. Yes this is a cut-over to home assistant from smartthings and using particle photons:

I have had some form of window blinds operating for over two years. I love the idea of the pull cord, but after I started using these I ended up setting up a fibaro light sensor and I use that to adjust the blinds(I rarely have to do anything to them). I read your write up and my windows face the west as well. We have a large bay of six windows and really laziness drove me to automate the windows. I was tired of pulling the cords.

If you are interested in using lux value I segment phases by hour before sunset and use the lux value to set the blinds to different positions based on the how many hours before sunset.

You could change your blinds to be covers now if you wanted. Your scripts would look a little more sane :slight_smile:

I’m planning on integrating a luminance sensor eventually but I wanted to get the up/down stuff sorted first.

I was planning on using a temp sensor inside the room and the set point of the thermostat to determine if the blinds should close or open depending on if I’m trying to keep it cool inside vs warming. I’m still working on the python code to intercept the readings from my thermostat (Carrier Infinity Touch) and haven’t gotten that integrated into Home Assistant yet.

1 Like

Hello I got my blinds working a few days ago and works great,
I’m using them with Alexa,
Is there a way to say open and close with Alexa, Instead of turn on and turn off

No that is a backend API problem for Amazon. Interestingly enough I think close will work, but open will not. I use on, off or dim to x%. Open and close used to work until​ about 1 year ago.

I cant seem to get my Esp8266 to interact with home assistant. Could you post your actual code. Thank You

You can set up haaska. It cleans up lots of commands with Alexa

1 Like

@quadmasta Thanks, I already have had haaska setup, I can as a few days ago say open or close blinds and they work, not sure if it was the Alexa update or HS 0.49.0 update.

@quadmasta Did you ever get your blinds to raise up? I have Vertical Blinds they open and close traveling across the window all the way open or all the way close, works great,
But I would like to have them open 50% or adjustable,
They travel across (more rotations with the servo) instead of tilting


@Dee I haven’t found the right pulleys and I haven’t been able to make suitable ones.

I updated one of the cover platforms to enable setting position on the open/close. I think it was MQTT. What platform are you using?

@quadmasta I am using MQTT to a esp8266 nodemcu to open and close the blinds, and its working good, I have tried 3 times to get a cover platform to work but, it fails, and crashes HA every time. so I just stopped trying. I know I must have something in the config wrong just haven’t taken the time to find it.

Hop on Discord sometime and I’ll see if I can help you with it