Garage door Trigger

Hi All

I have a garage door onener that is Triggered by a Relay that changes state for 1 second when triggered by a switch via Apple Home:

Switch GarageDoorSW "Garage Door SW" <garagedoor> [ "Switchable" ] {channel="mqtt:topic:Garage_Door:Garage_Door_SW" ,expire="1s,command=OFF",autoupdate="true" }

I also Have a reed switch that feed back the position of the garage door:

Contact GarageDoorCContact "Door Closed Contact [%s]" <garagedoor> {channel="mqtt:topic:Garage_Door:G_Door_C_Contact"}

So have two items showing up in apple home. The problem is the Garage door switch turns off after the 1 second via the "expire=“1s”

My question is can i make a dummy switch via a rule of somsort so the Garage Door switch visible in apple home shows the state of the garage door?

I hope you understand that all.

Thanks

First, I’d recommend if possible moving the turning off of the relay to the device instead of implementing it in OH using Expire. I have the exact same configuration for my garage door openers and if something happens with that OFF message (network hickup, something crashed, etc) the relay gets stuck ON and the door becomes uncontrollable.

As to your answer, I think it’s probably no, at least not without a whole lot of extra work. Questions you need to answer. What type of Item would this be? It can’t be a contact because you can’t send commands to Contact Items. If it’s a Switch, does ON mean the door is open? So you would send a command OFF to close the door and ON command to open the door. But what if the door is stopped half way while it is closing? Sending OFF will cause it to open more, not close the rest of the way. Perhaps you could use a String Item but you then need to come up with how to send the commands to achieve the desired result in a way that makes sense.

The big problem is the sensor and the button are two fundamentally different things and represent two fundamentally different concepts. That’s why they are modeled using two different Items. They are two separate things.

1 Like

This is a fundamental problem surrounding automation integration of multiple devices with set constraints to be able to achieve greatness.

First we need to define the system and the constraints.

  • Garage door opener only accepts toggle input which can mean different things and doesn’t report on off or direction.
  • We don’t want to shut the door while something is blocking it like toy or people.
  • It can’t be left open letting people into house.
  • Many more constraints.

What physical equipment do you have and what software is on the relay device?
What local legislation or by law is in place for the operation of automated doors?

What conditions do you want to protect from?
eg Loss in network, loss of power or burglars.

How will you control it?
Only from apple home or a mixture of technologies like remote and button on the wall


Ok now to answer the question you asked?

You have 1 control toggle on the door and one reed sensor to detect 1 position. If you just want homekit to display what you have last told it to do you can use a dummy item and toggle in a rule the real item. It will only show the assumed state that you sent it from that switch.

//OFF is Closed
Switch GarageDoorSW_dummy "Garage Door Open" <garagedoor> [ "Switchable" ] 


Switch GarageDoorSW "Garage Door SW" <garagedoor> {channel="mqtt:topic:Garage_Door:Garage_Door_SW" ,expire="1s,command=OFF",autoupdate="true" }

Then you need a rule to handle the switching

rule "Toggle Garage door"
when
    Item GarageDoorSW_dummy  received command
then
    GarageDoorSW.sendCommand(ON) //Open or close the garage door its your guess
end

The I guess you know when the garage door is closed if you use the remote so you can update your dummy item like this

rule "Garage door closed"
when
    Item GarageDoorCContact  received command Closed
then
    GarageDoorSW.postUpdate(OFF) // postUpdate so we shoulden't trigger the toggle rule and open the dam door.
end

Please check the operation of the safety on your door. Most doors should stop and open if blocked.

Would I set mine up like this? Probably not I would add an open contact and a photoeye to check if their was anything in path of door shutting.

Hi Jay,

homekit has a dedicated accessory type called GarageDoorOpener with attribute CurrentDoorState. that attribute can have status “OPEN, OPENING, CLOSED, CLOSING, STOPPED”

here is how i implemented this with dummy switches and rules. Garagedoor opener in Homekit

2 Likes

Hello guys.
First I want to say thank you for all this posts. With the help of community I managed to realize so much in these couple of month when i discovered openhab.
So I’m a noob, in coding but until now i managed to adapt much based on the answers from this forum.

I need some help with my gate rules. I post here, cause the topic is similar and I don’t want to open another one in the same time on the same topic.

I have the gates which are controlled by RF remotes and also there is a sonoff basic switch which can be controlled from openhab.

I used this example from Christofer to show the state and to control them. But somehow it doesn’t work. I think that it is because i didn’t adapted the mqtt v2 items correct . (How to set up a controlled garage door?)

The gates are opening but the state of the gates are not showing at all. And because of this also the rules are not working correct.

things:

Bridge mqtt:broker:46425acf [ host="192.168.1.130", secure=false, username="", password="" , clientID="" ]
{
Thing topic sonoffb1 "Sonoff Basic 1" @ "Gate" {
    Channels:
        Type string : reachable "Reachable"            [ stateTopic="tele/sonoffb1/LWT" ]
        Type switch : power     "Power"                [ stateTopic="stat/sonoffb1/POWER", commandTopic="cmnd/sonoffb1/POWER" ]
        Type switch : gateopened   "Gate open"         [ stateTopic="stat/sonoffb1/SENSOR/POW1"]
        Type switch : gateclosed   "Gate closed"       [ stateTopic="stat/sonoffb1/SENSOR/POW2"]
        Type number : rssi      "WiFi Signal Strength" [ stateTopic="tele/sonoffb1/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        Type string : ssid      "WiFi Name"            [ stateTopic="tele/sonoffb1/STATUS11", transformationPattern="JSONPATH:$StatusSTS.Wifi.SSId"]
        Type string : ip        "IP Address"           [ stateTopic="tele/sonoffb1/INFO2", transformationPattern="JSONPATH:$.IPAddress"]
        Type string : hostname  "Hostname"             [ stateTopic="tele/sonoffb1/STATUS5", transformationPattern="JSONPATH:$.StatusNET.Hostname"]
    }

items:

Group  Sonoff_B1           "Sonoff Basic 1"                    (Sonoff_B1) 
String Sonoff_B1_Reachable "Reachable: [%s]"                   (Sonoff_B1) { channel="mqtt:topic:46425acf:sonoffb1:reachable" }
Switch Sonoff_B1_Power     "Power"                             (Sonoff_B1) ["Switchable"] { channel="mqtt:topic:46425acf:sonoffb1:power" }
Number Sonoff_B1_RSSI      "WiFi Signal Strength [%d %%]"      (Sonoff_B1) { channel="mqtt:topic:46425acf:sonoffb1:rssi" }
Number Sonoff_B1_SSID      "WiFi Network"                      (Sonoff_B1) { channel="mqtt:topic:46425acf:sonoffb1:ssid" }
String Sonoff_B1_IP        "IP Address"                       (Sonoff_B1) { channel="mqtt:topic:46425acf:sonoffb1:ip" }
String Sonoff_B1_Hostname  "Hostname"                       (Sonoff_B1) { channel="mqtt:topic:46425acf:sonoffb1:hostname" }
Switch GateClosed														{ channel="mqtt:topic:46425acf:sonoffb1:gateclosed" }
Switch GateOpened														{ channel="mqtt:topic:46425acf:sonoffb1:gateopened" }
Switch GateAuto "Garage Door auto close 9PM-5AM"

rules

var Timer gateTimer 
var Timer gateOpenTimer

rule "Initialize Gate items"
when
	System started
then
	GateClosed.postUpdate(ON)
	GateOpened.postUpdate(OFF)
end

rule "Garage Door Open"
when
	Item Gate received command UP
then
if (gateTimer !== null)
	{
	gateTimer.cancel
	gateTimer = null
	}
	
	if (GateOpened.state != ON)
		{
		
		Sonoff_B1_Power.sendCommand(ON)
			gateTimer = createTimer(now.plusSeconds(25)) [|
			if (GateOpened.state != ON && GateClosed.state == ON)
				{
				Sonoff_B1_Power.sendCommand(ON)
			    }
			]
		}
end
//********************************************************************
rule "Garage Door Close"
when
	Item Gate received command DOWN
then
if (gateOpenTimer !== null)
	{
	gateOpenTimer.cancel
	gateOpenTimer = null
	}
if (gateTimer !== null)
	{
	gateTimer.cancel
	gateTimer = null
	}
	if (GateClosed.state != ON)
		{
		Sonoff_B1_Power.sendCommand(ON)
			gateTimer = createTimer(now.plusSeconds(25)) [|
			if (GateClosed.state != ON && GateOpened.state == ON)
				{
				Sonoff_B1_Power.sendCommand(ON)
			    }
			]
		}
end
//********************************************************************
rule "Garage Door Stop"
when
	Item Gate received command STOP
then
if (gateTimer !== null)
	{
	gateTimer.cancel
	gateTimer = null
	}
	if (GateClosed.state != ON && GateOpened.state != ON)
		{
		Sonoff_B1_Power.sendCommand(ON)
		}
end
//********************************************************************
rule "Garage Door State"
when 
	Item GateClosed received update	or
	Item GateOpened received update
then
Thread.sleep(500)
	if (GateClosed.state == ON && GateOpened.state == OFF)
		{
		Gate.postUpdate(DOWN)
		GateState.postUpdate("Closed")
		if (gateOpenTimer !== null)
	        	{
      			gateOpenTimer.cancel
        		gateOpenTimer = null
        		}
		}
	if (GateOpened.state == ON && GateClosed.state == OFF)
		{
		Gate.postUpdate(UP)
		GateState.postUpdate("Open")
		}
	if (GateClosed.state == OFF && GateOpened.state == OFF)
		{
		Gate.postUpdate(50)
		GateState.postUpdate("Ajar")
		}
end
//********************************************************************
rule "Garage Door Button Timer"
when
	Item Sonoff_B1_Power received command ON
then
	createTimer(now.plusSeconds(1)) [|
	Sonoff_B1_Power.sendCommand(OFF)
	]
end
//********************************************************************
rule "Garage Door Auto Close"
when 
	Time cron "0 0/6 21-5 1/1 * ? *"
then
if (GateAuto.state == ON)
	{
	if (GateClosed.state != ON)
		{
		sendBroadcastNotification("Garage door will shut in 5 minutes")
		gateOpenTimer=createTimer(now.plusMinutes(5)) [|
		sendBroadcastNotification("Garage door has closed automatically")
		Gate.sendCommand(DOWN)
		]
		}
	}
end
//********************************************************************
rule "Garage Door Auto Close Switch "
when 
	Item GateAuto received command OFF
then
	if (gateOpenTimer !== null)
	{
	gateOpenTimer.cancel
	gateOpenTimer = null
	}
end
//********************************************************************
rule "Garage Door Opening"
when 
	Item GateClosed changed from ON to OFF
then
	sendBroadcastNotification("Garage Door has opened!")
end
//********************************************************************
rule "Garage Door Closing"
when 
	Item GateOpened changed from ON to OFF
then
Thread::sleep(500)
	if (GateOpened.state != ON)
	{
	sendBroadcastNotification("Garage Door is Closing!")
	}	
end

Can somebody help me and show me what I’m doing wrong?
Many thanks in advance

Hi,

Thanks for the pointers, Can i ask what you use to trigger your door to open/close, for example, i use a relay to trigger mine that has a timer on it as my opener only needs a momentry trigger.

Cheers

hi Jay
i use Homematic IP, Garage door button, HmIP-WGC. the way of working is the same, it just sends a short trigger to the garage door. garage door switches between following states: “open”->“stop”->“close”->“stop”. so, pretty stupid device for nowadays

My garagedoor opener use a puls to open/close.
I have a relay inserted in the chain. So when I push a button (or ask Google). It will trigger the relay, which will shortcircut the contact of the relay, letting the puls to the garagedoor opener. And it will start to move. My garagedoor opener does not have a state in return. (its an Marantech 252.2 comfort).

The issue is.
I do not know which way it actually moves. If last trigger was closing, then the door will be opening, and vice versa. But if there fore some reason is beeing send two pulses, then the door will start moving and stop somewhere in between.

Now, what I have done to somehow have a sligt overview of this. I have placed a wireless contact at the bottom and another one at the top of the door. (actual the contact switches are placed on the operator rail, cause the contact sensors are magnetic, and can be mounted without screews, glue etc. And then the magnet itself is placed at the Door link). See picture:

(picture is sligthly different as I only use two contacts).

This tells me wheter the door is fully closed or fully open. And if none of this is true, it tells me, the door position is somewhere in between (meaing, the door is open or “on the move”).

In OH I have a rule, (with great help from Rich), where I can tell, if the door three states, (fully open, fully closed or “on the move”). Its works great.

Here is the rule:

// Rule for status notification (light) of the GaragePort

rule "Garageport moving"
when
      Item  GaragePortBottomSensor_item changed or
      Item  GaragePortTopSensor_item changed
then
       logInfo("Debug", "garageportbottom sensor is " + GaragePortBottomSensor_item + " garageportTop sensor is " + GaragePortTopSensor_item)

    // default to the door is NOT moving
    var moving = false
    var lightState = OFF

    // If either sensor is OPEN then the door IS moving
    if(GaragePortBottomSensor_item.state.toString == "OPEN" && GaragePortTopSensor_item.state.toString == "OPEN") {
        moving = true
        lightState = ON
            sendPushoverMessage(pushoverBuilder("Garageporten er i bevægelse!").withSound("none"))
    }

    // Figure out if the door is fully open or fully closed or on the move
    var message = "on the move"
    if(GaragePortBottomSensor_item.state.toString == "CLOSED")	{ 
	message = "fully closed"
	  GaragePortBottomLight.sendCommand(ON) 	
            sendPushoverMessage(pushoverBuilder("Garageporten er helt lukket!").withSound("none"))
   }

 else 

  {	
	GaragePortBottomLight.sendCommand(OFF) 
   }

    if(GaragePortTopSensor_item.state.toString == "CLOSED")	{ 
	message = "fully open"
	  GaragePortTopLight.sendCommand(ON) 
            sendPushoverMessage(pushoverBuilder("Garageporten er helt åben!").withSound("none"))
   }
 else 
	{	
	GaragePortTopLight.sendCommand(OFF)	
   }

    // change the status light and send the log.
      GaragePortMovingLight.sendCommand(lightState)
       logInfo("garageport.status", "garageport is " + message)
end

As notice, this rule sends a pushover msg each time the garagedoor change position.
Also notice I have proxy items, cause the switches are flickering too much when they activate/deactivate, so I have a second rule, where I proxy the main contact switches.

EDIT - What I´m still missing it to be able to use “open/close garagedoor” command in Google insted of “turn on garagedoor”. I havn´t got to that yet. Mainly because I got so use to just say “turn on garagedoor” :smiley:
I use it every day from AA in my car, when arriving home.

Is your item a roller shutter item?

Rollershutter { ga="Garage" }

Hmm I believe I tried some time ago… But looking at my setup right now, it´s not there… Not really sure why I removed it, probably because it didnt work back then.