Every morning and evening I found myself opening and closing the curtains in the front of my house. This sort of manual repetition just won’t fly!
I automated the curtains with a Raspberry Pi Zero W, a couple of stepper motors, and some timing belt. I setup Home Assistant to publish commands over MQTT and persist the curtains’ state.
My curtain controller is alive!! In addition to responding to voice commands, it automatically opens the curtains in the morning at sunrise and closes them at sunset.
The Raspberry Pi Zero (as seen in my last post) is in between the windows hidden behind my record player. Wires carrying signal and power snake up the sides of the windows. They connect to two stepper motors which drive belts that run parallel to the curtain rods.
The sunset and sunrise event triggers come from @homeassistant. It publishes them on an MQTT topic to which the Pi subscribes. I’m just beginning to scratch the surface of this awesome open-source home automation framework!
When a “sun above horizon” event occurs it checks the curtains’ state (as received on the “curtains_state” MQTT topic).
- If the state is “open” it doesn’t do anything.
- If they’re closed it publishes a message through MQTT on a “curtains_command” topic.
The Raspberry Pi is subscribed to the “curtains_command” through a Python script being run as a service.
- When it sees an “open” message published on the “curtains_command” topic, it publishes a persistent “opening” message through MQTT on a “curtains_state” topic.
- Then the Raspberry Pi starts begins stepping the motors until it reaches its limit.
- Finally, it publishes an persistent “open” message on the “curtains_state” topic.
Home Assistant has a “sensor” subscribed to the “curtains_state” topic and publishing a “persistent” message means that even if Home Assistant loses track of the state, as soon as it resubscribes to the “curtains_state” topic it receives the most recent message.
A stepper motor drives a toothed timing belt that spans the length of the window and the curtains are attached to the belts.
- handles subscriptions and message publications
- private, not accessible from the internet
- subscribes to “curtains_command” messages
- python script service
- publishes persistent “curtain_state” messages
- timing belt
- attaching curtains
Google Home / IFTTT / Particle
- setup IFTTT applet with Google Home phrase trigger
- Particle function as action with an ingredient
- function fires a “curtains_bridge” message with the command
- MQTT sensor based on “curtains_state” topic
- triggers (sun events, “curtains_bridge” topic)
- condition “curtains_state” sensor
- publishes “curtains_command” messages