Well, it’s time to ban MyQ from my home (wasn’t working now for years), and say hello to ratgdo (Rage Against the Garage Door Opener).
A big shout-out and thank you to Paul Wieland who is the creator behind ratgdo!!
For anybody planning to do use ratgdo, here is my journey and I hope it will help you to bring your garage door back into your openHAB setup.
I am still running openHAB 2.5.12, since everything I need works and why change a running system…
I do use configuration files for all my stuff and normally do not need to use the GUI.
Pre-conditions for getting this to work is that you have MQTT Binding (version 2) installed.
1. Hardware Install
===============
Nice tutorial for programming and hardware installation of ratgdo
2. Flashing
=========
Use the MQTT flash image, my ratgdo is version 2.57
3. Setting up ratgdo
================
Find your ratgdo IP address for your LAN configuration, log in, and change the setup parameters (see below)
Note: The following names will found in your openHAB MQTT setup again:
MQTT Topic Prefix: ratgdo
Device Name: admin
Those two will be concatenated and used in the channel setup: ratgdoadmin
4. Setting up thing defintion: mqtt.thing
================================
Bridge mqtt:broker:mosquitto "Mosquitto" [
host="openhab",
port=1883,
secure=false,
username="openhabian",
password="xxxxxxxx",
clientID="openHAB_NUC"
]
{
//****************************************************************
//****************************************************************
//***************************************************
// ratgdo Garage Door opener interface
//***************************************************
Thing topic ratgdo_cmd "ratgdo_1_cmd" @ "ratgdo garage cmd" {
Channels:
Type switch : doorstop "Switch Garage Door"
[
commandTopic="ratgdoadmin/command/door", on="stop", off="stop"
]
Type switch : door "Switch Garage Door"
[
commandTopic="ratgdoadmin/command/door", on="open", off="close"
]
Type switch : light "Switch Light"
[
commandTopic="ratgdoadmin/command/light", on="on", off="off"
]
}
Thing topic ratgdo_status "ratgdo_1_status" @ "ratgdo garage status" {
Channels:
Type string : online "Online"
[
stateTopic="ratgdoadmin/status/availability"
]
Type string : light "on"
[
stateTopic="ratgdoadmin/status/light"
]
Type string : obstruction "on"
[
stateTopic="ratgdoadmin/status/obstruction"
]
Type contact : doorC "on"
[
stateTopic="ratgdoadmin/status/door",
closed="closed", open="open"
]
Type string : door "on"
[
stateTopic="ratgdoadmin/status/door"
]
Type string : lock "on"
[
stateTopic="ratgdoadmin/status/lock"
]
}
5. Setting up items: garagedoor.items
===============================
Switch GarageDoor_Opener "Open/Stop/Close Garage Door" <garagedoor> (gGarageDoor)
Contact GarageDoor_Closed "Garage Door Closed/Open" <garagedoor> (gGarageDoor)
Switch GarageDoor_IsOpening "Garage Door opening" <garagedoor> (gGarageDoor)
String GarageDoor_StatDoor "Garage Door status [%s]" <garagedoor> (gGarageDoor) { channel="mqtt:topic:mosquitto:ratgdo_status:door" }
Switch GarageDoor_Stop "Stop Garage door movement" <garagedoor> (gGarageDoor) { channel="mqtt:topic:mosquitto:ratgdo_cmd:doorstop" }
Switch GarageDoor_OpenClose "Open/Close MQTT command" <garagedoor> (gCDcmdg,GarageDoor) { channel="mqtt:topic:mosquitto:ratgdo_cmd:door" }
Switch GarageDoor_Light "On/Off Garage Door Light" <light> (gCDcmd,gGarageDoor) { channel="mqtt:topic:mosquitto:ratgdo_cmd:light" }
String GarageDoor_StatLight "Garage Light is [%s]" <light> (gRestore,gGarageDoor) { channel="mqtt:topic:mosquitto:ratgdo_status:light" }
String GarageDoor_StatObstruct "Garage Obstruction [%s]" <garagedoor> (gRestore,gGarageDoor) { channel="mqtt:topic:mosquitto:ratgdo_status:obstruction" }
String GarageDoor_StatLock "Garage Door is [%s]" <garagedoor> (gRestore,gGarageDoor) { channel="mqtt:topic:mosquitto:ratgdo_status:lock" }
String GarageDoor_StatOnline "Garage Door is [%s]" <garagedoor> (gRestore,gGarageDoor) { channel="mqtt:topic:mosquitto:ratgdo_status:online" }
Switch GarageDoor_Light_FB "Garage Door Light feedback" <light> (gGarageDoor)
6. Setting up sitemap: home.sitemap
==============================
Text label="Garage" icon=garage_detached
{
Default item=GarageDoor_Opener
Default item=GarageDoor_StatDoor
Default item=GarageDoor_Light
Default item=GarageDoor_StatLight
Default item=GarageDoor_StatObstruct
Default item=GarageDoor_StatOnline
Default item=GarageDoor_StatLock
}
7. Setting up some rules to tie everything together: garage.rules
====================================================
// ********************************************************
// Garage Door control
// ratgdo sends following strings: closed,open,opening,closing,stopped
// ********************************************************
rule "Rule Garage Door control"
when
Item GarageDoor_Opener received command
then
Thread::sleep(20) // wait a little for state to update
if (GarageDoor_Opener.state == ON) // this is the command from GUI (or another rule)
{
switch GarageDoor_StatDoor.state.toString // depending which state garage door is in:
{
case "closed":
{
GarageDoor_OpenClose.sendCommand(ON) // send MQTT open command
GarageDoor_IsOpening.sendCommand(ON) // remember on its way to open (if stopped)
}
case "open":
{
GarageDoor_OpenClose.sendCommand(OFF) // send MQTT close command
GarageDoor_IsOpening.sendCommand(OFF) // remember on its way to close (if stopped)
}
case "opening":
{
GarageDoor_Stop.sendCommand(ON) // stop movement (during opening)
GarageDoor_Stop.postUpdate(OFF) // toggle button on GUI to off
}
case "closing":
{
GarageDoor_Stop.sendCommand(ON) // stop movement (during closeing)
GarageDoor_Stop.postUpdate(OFF) // toggle button on GUI to off
}
default: // would get here for "stopped" status from ratgdo
{
if (GarageDoor_IsOpening.state == ON)
{
GarageDoor_OpenClose.sendCommand(OFF) // send MQTT close command (opening was stopped)
GarageDoor_IsOpening.sendCommand(OFF) // remember on its way to close (if stopped)
}
else
{
GarageDoor_OpenClose.sendCommand(ON) // send MQTT open command (closing was stopped)
GarageDoor_IsOpening.sendCommand(ON) // remember on its way to open (if stopped)
}
}
}
GarageDoor_Opener.sendCommand(OFF) // reset the command from GUI (or another rule)
}
end
// ********************************************************
// Garage Door Light status update
// ********************************************************
rule "Rule Garage Light status update"
when
Item GarageDoor_StatLight changed
then
if (GarageDoor_StatLight.state.toString == "off")
{
GarageDoor_Light.postUpdate(OFF)
GarageDoor_Light_FB.postUpdate(OFF)
}
if (GarageDoor_StatLight.state.toString == "on")
{
GarageDoor_Light.postUpdate(ON)
GarageDoor_Light_FB.sendCommand(ON)
}
end
// ********************************************************
// Garage Door status update
// ********************************************************
rule "Rule Garage status update"
when
Item GarageDoor_StatDoor changed
then
if (GarageDoor_StatDoor.state.toString == "closed")
{
GarageDoor_Closed.postUpdate(CLOSED)
}
if (GarageDoor_StatDoor.state.toString == "open")
{
GarageDoor_Closed.postUpdate(OPEN)
}
end
// ********************************************************
// Garage Door closed actions
// ********************************************************
rule "Rule Garage Door closed"
when
Item GarageDoor_Closed changed to CLOSED
then
Light_Hallway_Kitchen.sendCommand(ON)
end
8. Sitemap control
===============
See screen shot below, the first switch item (“Open/Stop/Close Garage Door”) is used in the rules file and is your main control. When you switch it on, it will automatically switch off. The control of the garage door is similar to your hardware button on the wall:
Garage state: Action when switch is actuated:
closed Garage door will open
open Garage door will close
closing or opening Garage door will stop moving
stopped Garage door will to move opposite direction of prior movement (i.e. when closing was stopped, it will now open)
This setup is probably not the most elegant solution, but it works for me.
You can also use the generated “GarageDoor_Closed” contact item to trigger other actions. In my case I turn on the hallway light coming into the house.
Have fun…