How to make garage door control - only one button but two directions?

Hi,
i want to know how i can make a control for my garage door opener. It is controlled with only one button.

Press button - door opens - press button - door stops - press button - door changes direction - and so on…

But i want to press a button: “close garage door” - and the door should close even if i don´t know the state right now.

So what is the best way to do this? Buy a few reed-contacts and make one for door open and one for door close? So if i press “close door” button and next contact reached is open door, i would have to write a rule, which closes door after that automatically?

And how can i implement an ultrasonic sensor to get the % state of the opened garage door? Anybody made this already?

Hello,

I did it with just one sensor for state “close” since this is the usual state 99% of the day at my home.
For the button I take a push-button like at the remote control with no extra rules.
The icon changes to red if the garage is open. Normal close case is grey.

But what is, if the garage door is half opened and last direction was down (close) before stopping?

Then you press the button and the door goes up (opened) and it will never get closed until you press the button a second time.

So i want to press one button only fore one time, no matter what actual state the door has. It should always get closed automatically.

And i can close my door with wireless remotes too, so if i press a button on the wireless remote, openhab will not recognize the new state without any reed-contacts.

You can use a second sensor and a rule that checks both sensors.
If open after press, press again. This is what I do manually. :slightly_smiling:
Or in my case I could use a timer. If garage is still open 20 seconds after press, press again.

If I understand your question correctly you want two buttons to control your garage door. One to trigger it and one to close it no matter what.

If you have a single reed sensor that tells you when the door is CLOSED you can do the following:

rule "Garage "
when
    Switch CloseGarageDoor received command
then
    Garage.sendCommand(ON)
    Thread::sleep(15000) // sleep long enough for the garage to go from fully opened to fully closed plus a little buffer
    if(GarageSensor.state != CLOSED) Garage.sendCommand(ON)
end

Here.

In my previous setup to OH had a plugin that handled what I think you are asking for. I was determined to create it in OH. I wrote a pair of rules to handle what I think you are talking about.

My setup has a number item that is 0 or 1 but on the sitemap shows as closed or open via mappings. The item will highlight the current state of closed or open. You can still push either direction. The rule will actually verify against the door sensor that the current state is correct. If not it will send a command to push the door opener button (standard one button chamberlain opener that I have a relay connected via my DSC PGM outputs).

Once the rule pushes a garage button, it will wait for a few seconds and then check the status and update the state of the Number on the sitemap. That way you have real feedback of success/failure.

I have a second rule that monitors the door sensor separately. This will update the number item if the garage door is opened manually via button in the garage or a car etc.

It’s mostly standard. The unique piece is a local variable for “lockout” The point of the lockout is to keep the two rules from interfering with each other. I spent a good afternoon trying to think up the smoothest logic. I’m sure there are other/better methods but it has been reliable for several months now.

Hopefully it is relevant to your question.

ITEMS:

Number	NUM_garageDoor
Contact Garage_garage_Door_GENERAL_STATUS "garage's Garage Door" <garagedoor> (DSCAlarmZones, Garage) {dscalarm="stuff"}

SITEMAP:
Switch item=NUM_garageDoor       label="garage's Door Status"     icon="garagedoor" mappings=[0="Closed", 1="Open"]

RULES:

var Number garageGarageLockout = 0
var Timer garageGarageTimer //timer for garage's garage door


rule "garage Door toggle"
	when
		Item NUM_garageDoor received command
	then
		logInfo("garage Door toggle", "Rule Triggered")
		if (garageGarageLockout==0) {
			if (receivedCommand==0) {//close door
				if (Garage_garage_Door_GENERAL_STATUS.state == OPEN) {
					//close door
					garageGarageLockout = 1
					sendDSCAlarmCommand() //toggle pgm
					logInfo("garage Door Toggle", "Door closing")
				} else {
					logInfo("garage Door Toggle", "Door already closed")
				}
			} else if (receivedCommand==1) { //open door
				if (Garage_garage_Door_GENERAL_STATUS.state == CLOSED) {
					//open door
					garageGarageLockout = 1
					sendDSCAlarmCommand()
					logInfo("garage Door Toggle", "Door opening")
				} else {
					logInfo("garage Door Toggle", "Door already open")
				}
			}
			if(garageGarageTimer!=null) {
			        garageGarageTimer.cancel() //cancel timer if it is already running
	        }
	        logInfo("garage Door toggle", "Starting Timer")
			garageGarageTimer = createTimer(now.plusSeconds(18)) [| //give door 18 seconds to close
				if ((Garage_garage_Door_GENERAL_STATUS.state == OPEN) && (NUM_garageDoor.state == 0)) {
					logWarn("garage Door toggle", "Door failed to close or was overridden")
					postUpdate(NUM_garageDoor, 1)
				} else if ((Garage_garage_Door_GENERAL_STATUS.state == CLOSED) && (NUM_garageDoor.state == 1)) {
					logWarn("garage Door toggle", "Door failed to open or was overridden")
					postUpdate(NUM_garageDoor, 0)
				} else logInfo("garage Door Toggle", "Timer ended, all is well")
				garageGarageLockout = 0
			]
		} else logInfo("garage Door toggle", "garageGarageLocout!=0")
end


rule "Update garage Garage Door State"
	when
		Item Garage_garage_Door_GENERAL_STATUS changed
	then
		if (garageGarageLockout==0) {
			if ((Garage_garage_Door_GENERAL_STATUS.state == OPEN) && (NUM_garageDoor.state == 0)) {
					logInfo("Update garage Garage Door State", "Door has opened")
					postUpdate(NUM_garageDoor, 1)
			} else if ((Garage_garage_Door_GENERAL_STATUS.state == CLOSED) && (NUM_garageDoor.state == 1)) {
					logInfo("Update garage Garage Door State", "Door has closed")
					postUpdate(NUM_garageDoor, 0)
			} else logInfo("Update garage Garage Door State", "Nothing changed")
		}
end
2 Likes

Reworking my garage door opener rules is my next refactoring exercise. I think I’ll borrow from this. Thanks for posting!

I’m looking at doing the same thing with a Raspberry Pi. I’m thinking about adding a rotary encoder to the setup that’s connected to the chain on the opener. That way I’ll be able to tell which direction the door is moving (or if it’s moving at all). If I can keep track of the the counts from the encoder reliably enough I should be able to keep tabs on the actual position of the door as well even when the door is not fully open or fully closed. I’d also be using magnetic switches to keep track of when the door is fully open or fully closed. I’ll probably just start with the two switches for the time being though. I’ll add the rotary encoder later when I’ve had more time to do some experimentation.

Absolutely, hope it helps!

The idea was to create an “item” with the logic behind it. That way you could send open or close to the item in other rules without worrying about state etc.

Interesting idea. I can’t say as that I have ever needed that much info but I could see knowing exact position/direction as being valuable in certain situations.

One concern being that if the encoder gets confused due to restarts or power loss or something, the system could do some whacky things.

Just spitballing… there must be some form of laser based distance measuring sensor you could get. Then you could put a little unobtrusive flag on the trolly. Keep tabs on the distance the trolly is from the motor unit and viola, location and direction and no calibration needed.

I’ve a link to an ultrasonic range finder approach above.

True, I didn’t click it but thought those were a little ‘wide’ for a long(er) distance. I was thinking very unobtrusive like a .25" x .25" square or something that a laser can point right at. I was thinking more like a laser ruler.

Admittedly I’m not up on how accurate ultrasonic units are.

I’ve not used them myself but have bought a couple. They are smaller than they look and from what I’ve read seem to be accurate to at 2cm to 3m. A standard garage door is 2.1m tall so if you mount it on or close to the door opener it has plenty of range. And at $2-$3 a sensor (plus Arduino or Raspberry Pi) way cheaper than a laser.

From what I’ve seen the Garadget uses a laser, but only to determine open/closed status. According to the Garadget kickstarter video the laser and a reflective sticker are placed in such a way that it wouldn’t work for range finding.

Which is why, at least at first, I’d only used the encoder to determine the relative motion of the door - opening, closing, or stationary. That would make it quicker to determine that the door was moving in the wrong direction relative to the state that the user wants the door to be in.

I’d have to do a lot more experimentation to figure out the logic for using the encoder to track the absolute position of the door.

I was also going to add a camera to the Raspberry Pi pointed at the door as another way of remotely checking the state of the door.

yeah, the leasers would likely be more expensive and less common of components. The type of laser you mention would be standard make/break type. laser bounces off reflector and is seen by eye. They used to have them on shop doors. Garage doors often have them split with one on each side now as a safety beam. Those definitely wouldn’t do what you need.

I still maintain, try the magnetic contact only first and see if it gives you the info you need. I personally have had no issues with just knowing open/closed. But, sometimes it’s the fun of the project and you get neat info when you are done…

32 hours left on the Garadget Kickstarter campaign!. :wink:

What´s the great benefit of a garadget if i already have an openhab server running?

With openhab i only need 1 channel of an actor and at least one magnetic reed-contact to check if the door is closed (or better a second one to check if door is fully opened).

So building it with openhab is a way more cheaper than garadget.

(And greatest benefit: I don´t need the cloud to control my garage door…)

I think, garadget is a super gadget for people who don´t already use an openhab server and only want to control the garage door from away.

Well, there’s a nice new binding for Garadget that works out of the box!

If you add up all the parts to build your own, versus buying a single gadget with free shipping and no sales tax/VAT, it may not be the case that building your own is cheaper.

It’s a matter of preference, I suppose. If you had two garage doors on different networks, you would have to figure out how to control both of them. But if you would rather build your own, configure routers and/or VPN, install reed switches, write sketches, etc., then Garadget would not be adding much value for you. For others, it solves a number of issues they their skills and interest might not be well matched to.

Please don´t think i want to say something bad about the garadget. I think it´s a very good thing and not to expensive.

But for me its not the best thing, because i already use most of the things you described with my openhab already - So not much work to include another reed-contact and write some line of code. But if i would install and configure an openhab server from scratch, for only control the garage door, then you are right, it´s to much work for this. In this case i also would prefer to buy this garadget.

1 Like