[SOLVED] Looking for Ideas on Garage door Solution

Looks like I have some options that I never looked into (took me 3 days to figure out the hookup).

Looks like I can times directly on the flush device…need people not to be home to try these out.

Don’t have the app installed, also gives me a way to share a group with the spouse and only present conditioned answers/keyboards. I also have a self project at work to leverage some telegram Node Red chat bot things, so more learning on how to accomplish things.

I have a Marantech 250.2 garagedoor opener. It´s far from fancy, as it use a remote with a single pushbutton to operate. First push, it starts moving, second push it stops if it´s on the move (or if it´s fully open/closed, it starts move again). Third push (if it´s not at the end) it moves in the opposite direction. Pretty ackward way to control a garagedoor in a smart way.

I have a wireless sensors at the top and at the bottom of the garagedoor. From this I know when it´s fully open or fully closed. Thats basicly it.
I have added a relay to be able to control it from our normal push buttons around the house as well as from openhab.

I have thought about how to make this a bit smarter using openhab, but I havn´t figured this one out yet. Since I cant controle the direction, its almost impossible to make anything smarter, unless I risc the chance that it may become out of sync. (ie using proxy switches for the direction will most probably fail sooner or later, when I cant controle the direction).
Best option would be to have a garagedoor opener, which has two inputs, one for for each direction.

This is pretty standard for garage door controllers, even the smart ones.

With two sensors you can keep track of the last state and based on the last state forgot it what state the door entered as a result of the button press.

Previous state Current state new state
Any Closed opening
Any Opening stopped
Opening stopped closing
Any closing stopped
Closing stopped opening
Any opened closing

Writing a rule to that truth table should not be that hard. The only gotcha is the door opener would need to report when the physical button is pressed or else you won’t be able to detect the charger from stopped to opening or closing.

For scripted automation users, @glhopital created a state machine module which is predict to implement something like this. Finished State Machine in Jython

1 Like

For opening and closing, I simply used a Sonoff SV running Tasmota. This is wired into the wired button switch. No issues with this setup.

For state, I added a heavy duty magnetic contact. In my setup this runs through my alarm system to OH, but no reason you shouldn’t be able to use one of these with a NodeMCU (and MQTT) for example as standalone sensor. Eg of the contact: https://www.amazon.com/Heavy-Duty-Magnetic-Switch-N-Contact-Circuits/dp/B00CAIVNM4

Thanks Rich… As usual you make rather complicated stuff sounds so easy :slight_smile:
It still gets beyound my knowledge unfortunaly, as there are too many things going on… I get the idea, but turning that idea into a working rule simply isn´t that simple for me.
I´ll take a look at the link you provided.

For the wired buttons (relay) I have added, this is not a issue. But for the RF remote (original Marantech remote), this will for sure become an issue.

Here’s a write up I did on how I added my garbage doors and gate to OH. Maybe it will provide some ideas.

1 Like

I tilt sensor or sonic distance sensor could be used to detect when the door is moving if it is a big problem.

It’s just a bunch of book keeping and some if statements. That’s the case for all state machines (this is what we have here).

from core.rules import rule
from core.triggers import when

prevState = None

@rule("Garage door status")
@when("Item DoorOpenedSensor changed") // sensor that is OPENED when door is fully open
@when("Item DoorClosedSensor changed") // sensor that is CLOSED when door is fully closed
@when("Item DoorController received command")
def door_ctrl(event):
    newState = "UNDEF"
    currState = items["DoorState"]
    
    # Door is fully closed
    if items["DoorClosedSensor"] == CLOSED:
        newState = "CLOSED"

    # Door is fully opened
    elif items["DoorOpenedSensor"] == CLOSED:
        newState = "OPENED"

    # Door is in motion
    elif currState != "STOPPED":
        newState = "STOPPED"

    # Door is partially open but not moving
    else:
        newState = "OPENING" if prevState == "CLOSING" else "CLOSING"

    # Could use persistence for this, keep track of the previous state so we can handle the STOPPED case
    global prevState
    prevState = currState

    events.postUpdate("DoorState", newState)
1 Like

Hmm I do have a third sensor which is indeed is a tilt sensor ( Vision zwave garage door tilt sensor which I totally forgot all about). But it wont do for a button, as the garage door will have moved quite a bit, before the sensor triggers.

You once helped me with this rule, which I´m still using. I assume much of it can be used, (btw the var moving seems to give an error, but openhab use the rule anyway. I think this happened when I updated from openhab 2.4 to 2.5. I havn´t done anything to try change it, yet):

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

rule "Garageport moving"
when
    Member of GaragePortSensors changed
then

    // 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.state == OPEN && GaragePortTopSensor.state == OPEN) {
        moving = true
        lightState = ON
    }

    // Figure out if the door is fully open or fully closed or on the move
    var message = "on the move"
    if(GaragePortBottomSensor.state == CLOSED)	{ 
	message = "fully closed"
	  GaragePortBottomLight.sendCommand(ON) 	
            sendPushoverMessage(pushoverBuilder("Garage door is fully closedt!").withSound("none"))
   }

 else 

  {	
	GaragePortBottomLight.sendCommand(OFF) 
   }

    if(GaragePortTopSensor.state == CLOSED)	{ 
	message = "fully open"
	  GaragePortTopLight.sendCommand(ON) 
            sendPushoverMessage(pushoverBuilder("Garage door is fully open!").withSound("none"))
   }
 else 
	{	
	GaragePortTopLight.sendCommand(OFF)	
   }

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


// Items
// Group GaragePortSensors	- Group Top and Bottom sensors.
// GaragePortBottomSensor 	- Bottom sensor
// GaragePortTopSensor	 	- Top sensor
// GaragePortMovingLight 	- Virtuel item, control light for door open or on the move.
// GaragePortBottomLight	- Virtuel item, control light for door has reached the bottom (fully closed)
// GaragePortTopLight 		- Virtuel item, controle light for door has reached the top (fully open).
//
// Logic:
// When Garageport is fully closed and not moving, GaragePortBottomSensor will be CLOSED and GaragePortTopSensor will be OPEN. 
// When Garageport is fully open, GaragePortTopSensor will be CLOSED and GaragePortBottomSensor will be OPEN. 
// When Garageport is on the move, both sensors wil be OPEN, untill garageport reach the end, then either GaragePortTopSensor or GaragePortBottomSensor will be CLOSED, depending on direction.

Your Rule does pretty much the same as mine except I have it indicate which direction the door is moving.

Thanks for all the input.

I now have a working model with a Node MCU running Tasmota, 2 reed switches (one for Open and one for closed) and a relay.

Now for my next issue…

My garage door needs a Push switch action to trigger the open/close but my relay stays in the open position until i reselect it to closed.

How can i make the relay complete a momentary output to trigger the door open/close?

Thanks

Im having loads of errors when i use this rule in my rules, its not liking the ‘when’ and also the ‘froms’ at the top.

Did you install and configure Jyrhon and the Helper Libraries?

oh… No, how would i do this?

https://openhab-scripters.github.io/openhab-helper-libraries/index.html

Right, Thanks for the help so far…

I now have it set up and working.

I have a switch and 2 contacts, an open and a close.

ITEMS

Switch GarageDoorSW             "Garage Door SW"                                 <garagedoor>  [ "Switchable" ]         {channel="mqtt:topic:Garage_Door:Garage_Door_SW" ,expire="1s,command=OFF",autoupdate="false" }
Contact GarageDoorOContact      "Door Open Contact [%s]"                         <garagedoor>                           {channel="mqtt:topic:Garage_Door:G_Door_O_Contact"}
Contact GarageDoorCContact      "Door Closed Contact [%s]"                       <garagedoor>                           {channel="mqtt:topic:Garage_Door:G_Door_C_Contact"}

SITEMAP

     Frame label="Garage Door" {

Switch item=GarageDoorSW icon="garagedoor" mappings=[ON="OPEN"] visibility=[GarageDoorCContact == CLOSED]
Switch item=GarageDoorSW icon="garagedoor" mappings=[ON="CLOSE"] visibility=[GarageDoorCContact == OPEN]
Text item=GarageDoorCContact label="Garage Door is...."
Text item=GarageDoorOContact label="Garage Door is...."
                            }

CLOSED


TRAVELLING

OPEN

Because the switch is momentary due to the 1s expiry, I want to create a dummy switch that has 2 states that reflects the state of the Door Close Contact. So a switch to create the open/close command and the state of the switch is created by the feedback of the Garage closed contact. I mainly want this for Apple Home integration.

I also want to create something that with feedback 3 states - Closed, Travelling, Open - that reflects the status of the 2 contact sensors,

Ive tried this:

> //GARAGE DOOR STATE
> 
> rule "Garage door opening"
> 
> when
> 
> Item GarageDoorCContact changed to OPEN  //Door opening
> 
> then
> 
> GarageDoorCContact.postUpdate( "OPENING" )
> 
> end
> 
> rule "Garage door closing"
> 
> when
> 
> Item GarageDoorOContact changed to CLOSED //Door closing
> 
> then
> 
> GarageDoorOContact.postUpdate(  "CLOSING" )
> 
> end
> 
> rule "Garage door closed"
> 
> when
> 
> Item GarageDoorCContact changed to CLOSED  // Door closed
> 
> then
> 
> GarageDoorCContact.postUpdate(  "CLOSED" )
> 
> end
> rule  "Garage door open"
> 
> when
> 
> Item GarageDoorOContact changed to OPEN  //Door open
> 
> then
> 
> GarageDoorOContact.postUpdate( "OPEN" )
> 
> end

But get the errors:

[WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert 'OPENING' to a state type which item 'GarageDoorCContact' accepts: [OpenClosedType, UnDefType].

[WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert 'CLOSING' to a state type which item 'GarageDoorOContact' accepts: [OpenClosedType, UnDefType].

Any help appreciated :+1:

A Contact Item can only have the states OPEN and CLOSED. OPENING and CLOSING are not valid states. You need to use a String Item to represent those states.

1 Like

Can i just change the Contact item to a string item?

It depends on how that existing Contact Item is used. If you have it configured for persistence, it might break the database for that Item. At a minimum it will lose all the historic data associated with that Item as you can’t have a column in the database of two different types. If it is a member of a Group:Contact it might break the Group since it will no longer be a Contact Item.

But in general changing the type of an Item is no problem.

1 Like

Hmm, I once had a problem changing item type. I think I sat a Dimmer for at Switch item (on/off). Either the binding or openhab (cant recall exactly), gave an error.
But I would assume, String would always be fine.

Probably the binding. Often it dictates what the Item Type can be to link to a given channel. Which raised a good point. @jay7210, you probably have to change the Channel type on the MQTT Channel linked to this item to a text type.

1 Like