andrewshilliday / garage-door-controller

Software to monitor and control garage doors via a raspberry pi
MIT License
326 stars 127 forks source link

automatic door closure after 10:30PM if a door is open for more than 30 minutes #110

Open Gilles94500 opened 5 years ago

Gilles94500 commented 5 years ago

We went home late last nigth and we forgot to close the gate. My mobile phone is on mute between 10PM and 8AM, so I have not been alerted and the gate has been left opened all the night.

Would be it possible to add an automatic doors closure if the time is greater than 10:30PM and a door has been opened for more than 30 minutes? And send a specific mail to know that it has happened.

It could be customizable using the json config file. Something like: "use_autom":true "autom_start":2230 "autom_duration":30

Gilles

rapi3 commented 5 years ago

you can add on /etc/crontab a simple bash or python script that will close/open the garage at any time you want...

!/bin/sh

Exports pin to userspace, change pin nr, sleep ...

echo "11" > /sys/class/gpio/export

Sets pin 11 as an output

echo "out" > /sys/class/gpio/gpio11/direction

Sets pin 11 to low

echo "0" > /sys/class/gpio/gpio11/value sleep 1

Sets pin 11 to high

echo "1" > /sys/class/gpio/gpio11/value

UnExports pin from userspace

echo "11" > /sys/class/gpio/unexport exit

python script: import time import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(11, GPIO.OUT) GPIO.output(11, False) time.sleep(1) GPIO.output(11, True)

zbowman commented 5 years ago

If you already have your garage publicly accessible, this script might work for you. I'm using Pushbullet for notifications and had to use a few sleep commands. The pi doesn't respond fast enough if you ask for the status of each door one right after another but works ok with these delays.

`import requests import time from pushbullet import Pushbullet

pb = Pushbullet('')

right = requests.get('http:///st?id=right') time.sleep(2) left = requests.get('http:///st?id=left')

if right.text == 'open': pushright = pb.push_note("Garage Info", "Right Closing") closeright = requests.get('http:///clk?id=right') time.sleep(4) elif left.text == 'open': pushleft = pb.push_note("Garage Info", "Left Closing") closeleft = requests.get('http:///clk?id=left') time.sleep(15)

rightcheckup = requests.get('http:///st?id=right') time.sleep(2) leftcheckup = requests.get('http:///st?id=left')

if rightcheckup.text == 'open': pushright = pb.push_note("Garage Info", "Right Closing") closeright = requests.get('http:///clk?id=right') time.sleep(15) elif leftcheckup.text == 'open': pushleft = pb.push_note("Garage Info", "Left Closing") closeleft = requests.get('http:///clk?id=left') time.sleep(15)

rightfinal = requests.get('http:///st?id=right') time.sleep(2) leftfinal = requests.get('http:///st?id=left')

if rightfinal.text == 'open': pushright = pb.push_note("Garage Info", "Right Door STUCK") time.sleep(8) elif leftfinal.text == 'open': pushleft = pb.push_note("Garage Info", "Left Door STUCK") closeleft = requests.get('http:///clk?id=left')

if (rightfinal.text == 'closed' and leftfinal.text == 'closed'): pushfinal = pb.push_note("Garage Info", "Both doors closed.")

`

I know my code is ugly, but it works.

Gilles94500 commented 5 years ago

Thanks; very nice scripts. I don't know the Pushbullet pushbullet feature. I will give it a try. To be honest I am a little bit scary to be locked out in some cases. It is why I wanted to add this test (time and duration) .

Pack3tL0ss commented 5 years ago

I forked and modified this project a 2-3 years ago to add something along these lines. Slightly different, but adding a time of day bit wouldn't be difficult.

What I designed it to do:

Gilles94500 commented 5 years ago

Thanks for your help. Don’t worry. I am about to add some code to do the automatic closure. I also have modified the code to associate the garden lights along with a light detector, so not easy to share with the community.

I was thinking to use a free gpio that I could set to true or false to enable/disable the automatic closure.

Work in progress. I am not python expert :).

Gilles

From: Pack3tL0ss [mailto:notifications@github.com] Sent: mercredi 10 avril 2019 09:58 To: andrewshilliday/garage-door-controller garage-door-controller@noreply.github.com Cc: Gilles94500 gilles.sapene@laposte.net; Author author@noreply.github.com Subject: Re: [andrewshilliday/garage-door-controller] automatic door closure after 10:30PM if a door is open for more than 30 minutes (#110)

I forked and modified this project a 2-3 years ago to add something along these lines. Slightly different, but adding a time of day bit wouldn't be difficult.

What I designed it to do:

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/andrewshilliday/garage-door-controller/issues/110#issuecomment-481580950 , or mute the thread https://github.com/notifications/unsubscribe-auth/AQHIgXm2yto2rZwHeoJBzXGLITFAkHNlks5vfZmegaJpZM4cPmmw . https://github.com/notifications/beacon/AQHIgXPblyU5jGAY0vsj59zs-hdJ_buVks5vfZmegaJpZM4cPmmw.gif

andrewshilliday commented 4 years ago

Hi all, I’m a bit late to the party on this issue, but just to throw in my own two cents. I had considered adding a capability like that when I was originally writing the code but decided against it for the simple reason that the idea of garage doors opening and shutting on their own without any human involvement leaves me apprehensive.

Safety issues aside, there is a security aspect to consider. If for some reason your sensor should fail (loose wire, bad contact, etc.) the controller will think the door is open when it’s in fact close. When 10:30 comes around, it will try to close it and instead will wind up opening the garage.

I would suggest that a notification system would serve you better.