Pages

Monday, May 15, 2017

Automated blinds with Home Assistant, MQTT and NodeMCU

I came across this post on the Home Assistant community forums and decided to give it a try:
https://community.home-assistant.io/t/esp8266-window-blinds-mqtt/14863

I made some updates to the original code by jjhtpc, adding OTA updates. The new code will also retain your previous position when turning off and turning on the blinds if you want it. https://github.com/romahony/mqtt_blinds

Since I have a 3d printer I decided to sketch a quick coupler for the blinds. It can be found on Thingiverse here http://www.thingiverse.com/thing:2320388

The blinds I used are from Home Depot and come in a wide variety of sizes.

Connect the red wire to the Vin pin and the black wire to the GND pin next to it. The white wire is connected to D3.

Parts list:
Cut-to-Width blinds from Home Depot
Futaba S3003 servo
White micro USB Cable (no longer used, replaced with longer cable for direct power)
16.5ft white USB cable
NodeMCU Module
5000mAh Solar Power Bank

Remove blind gears.


With the servo mount still on the servo would sit off-center.


Cut off servo mount.


The servo should now sit dead center to the shaft.


Print and attach the adapter to the servo. 


Cut off the ends of the screws.


Feed the USB cable through the hole left by the gears that were removed.


Attach the NodeMCU inside the blind channel with double sided tape.


Connect the USB cable and install the blinds.







8 comments:

  1. This is a great example.
    I got this working in my setup but i have a few questions.
    My blinds only go closed or almost 90 degrees open.
    I would like to have them opening a little more. What value should i change, or can't is be done.

    Other thing is that i would like to change the operation because at one blind i can mount t left and on another it needs to be on the right side. so it should operate mirrored from the other.

    In home assist there is an "cover" command to use for tilt but i cant seem to get that working right. it does operate the blinds but there is no state. Plus in the app the tilt function does not show up.

    I hope you can point me in the right direction,
    Thanks, Arnold

    ReplyDelete
    Replies
    1. Hi Arnold, sorry for the delay.

      There is a variable in the code for this:
      int max_angle = 133;
      Change 133 to 90. Come to think of it I should have added the variable min_angle... I will add that actually as that will fix the second issue you are having. I will respond again once the new version is up.

      Delete
    2. Hi Arnold, I have made an update to the code at https://github.com/romahony/mqtt_blinds/blob/master/mqtt_blinds.ino

      In my code I have:
      int open_angle = 0;
      int closed_angle = 133;

      In your case you would reverse the values:
      int open_angle = 90;
      int closed_angle = 0;

      I didn't have time to test it so please let me know if that works for you.

      Delete
    3. Thank you for your updated code, i am able to adjust the angle but i can not seem to get the servo to work in reverse when i switch values for the open and closed angle.

      Delete
    4. Hi Arnold, looks like there needed to be more work to get this working in reverse. I have added a new version of the ino file. I renamed the existing ino to mqtt_blinds_reverse.ino since technically that was reversed anyway. The file named mqtt_blinds.ino is now customized for your reversed blinds, if that makes sense. Hopefully that works for you now.

      Delete
    5. Ryan, Thank you very much for your code, and your help to make it work like is does now.

      It is really perfect and i like it works right now.

      I am still learning the code, I see and understand what you changed.

      You also use HA for your blinds, have you tried the "cover" function?
      I did, and it does work, only thing is that in the app, no slider comes up for the tilt.

      Delete
  2. I really like the way you state the information related to automated blinds. Keep posting. Thanks !!!

    ReplyDelete