ZoneMR / homebridge-gpio-blinds

Control blinds via remote Up/Stop/Down switches connected to a raspberry pi GPIO
ISC License
2 stars 1 forks source link

Relay duration control? #3

Open webpablo opened 6 years ago

webpablo commented 6 years ago

I plan to use this but need the control to run through a relay and need to have a set length of time for each "button press" Does the open and stop command "hold down" the button for the duration of the opening/closing event or does it just "press it" for a second or less?

migabc commented 6 years ago

You don't have to use a relay for this project. I'm using this setup for several Velux and it works quite well.

The RPI powers the remote control (3.3V) and set's the button to low (GND) when the button is pressed. The button is pressed for a very short time (333ms - see code) - just as you would if you would do it manually on the remote.

Note: The wires are connected to the GPIO interface of a Raspberry Pi. To simulate a button press, the GPIO pin of the RPi is configured as OUTPUT and set to "low" and then the button is released immediately after by setting the GPIO pin to high impedance state (thus reconfigured as INPUT) - see code.

Note: You can open the Velux to a specific percentage by telling Siri to "open the Shutter/Blind/window to whatever percentage you want (that will send an "Open" and then seconds later a "Stop")

For example if you ask Siri to open the Velux half way (50%), that will instruct Homekit to run this code by pressing the "Open" button (very short press - 330ms) and then "motion_time divided by 2" milliseconds later it will press the "Stop" button (again very short press - 330ms)

{ "accessory": "GPIO-Blinds", "name": "Bedroom Blinds", "up_pin": 22, "down_pin": 16, "stop_pin": 18, "motion_time": 13000, Estimated in ms to fully open/close <<<<<<<< "motion_lag": 750 Typical lag before blinds start moving }