Without this your status will at best be an approximation and at worst fall out of sync with the door. In short, you’d never really be able to rely on the Item’s state for anything.
Consider this scenario. Most garage door openers have a sensor (multiple really) where if there is an obstruction, the door will automatically stop and open. So you’ve pressed the button and the door starts to close, the sensor causes it to stop and go back up. Now your status Item says the door is closed but in truth it’s open. And now it will be out of sync forever (showing open when it’s closed and closed when it’s open) until you manually go in and fix the status.
To model a garage door you really need the contact sensors, at least one per door to know when the door is open independent from the motor.
I’m not sure whether the Shelly 1s you have support this (you need a Gen 3+, I only have Gen 2 but I am looking into getting a Gen 4 so I can replace my RPi which is doing this job for me at the moment) but you can hook a reed switch (for example) to the device through the GPIO. For example Garage door control – The unofficial Shelly guide!. And reed switches are super cheap. You’ll probably spend more on the wires.
Of course the sensor doesn’t necessarily need to be the same device as the relay, but it’s convenient.
With a contact here is how I manage my garage doors. I use GA instead of Homekit, but going through the docs for Homekit should help.
My Thing is MQTT:
version: 1
things:
mqtt:topic:mosquitto:cerberos_sensor_reporter:
bridge: mqtt:broker:broker
label: cerberos sensor_reporter
location: Garage
config:
availabilityTopic: sensor_reporter/cerberos/status
payloadAvailable: ONLINE
payloadNotAvailable: OFFLINE
channels:
garagedoor1:
type: contact
label: Large garage door
description: Large garage door open status
config:
stateTopic: sensor_reporter/cerberos/garagedoor1/state
"on": OPEN
"off": CLOSED
garagedoor2:
type: contact
label: Small garage door
description: Small garage door open status
config:
stateTopic: sensor_reporter/cerberos/garagedoor2/state
"on": OPEN
"off": CLOSED
garagedoor1_opener:
type: switch
label: Large garage door opener
description: ""
config:
commandTopic: sensor_reporter/cerberos/garagedoor1/cmd
"on": "ON"
"off": "OFF"
garagedoor2_opener:
type: switch
label: Small garage door opener
description: Small garage door opener controller
config:
commandTopic: sensor_reporter/cerberos/garagedoor2/cmd
"on": "ON"
"off": "OFF"
online:
type: switch
label: Online status
description: Indicates online status of this sensor_reporter
config:
stateTopic: sensor_reporter/cerberos/status
"on": ONLINE
"off": OFFLINE
Items:
version: 1
items:
Garage:
type: Group
label: Garage
icon: material:garage
groups:
- Ground_Floor
tags:
- Garage
Large_Garagedoor_Sensor:
type: Contact
label: Large garage door
icon: material:garage
format: '%s'
groups:
- Large_Garagedoor
- DoorsStatus
tags:
- OpenState
- Status
channels:
mqtt:topic:mosquitto:cerberos_sensor_reporter:garagedoor1:
profile: basic-profiles:debounce-time
toItemDelay: 1000
metadata:
doorOpenReminder:
value: ' '
config:
defaultAlertDelay: PT30M
defaultRemPeriod: PT30M
listWidget:
value: widget:rlk_garagedoor_list
config:
control_item: Large_Garagedoor_Opener
name: Large Garage Door
sensor_item: Large_Garagedoor_Sensor
matter:
value: ContactSensor
Large_Garagedoor:
type: Group
label: Large Garage Door
icon: material:garage
groups:
- Garage
tags:
- GarageDoor
metadata:
listWidget:
value: ' '
config:
action: command
actionCommand: "ON"
actionFeedback: Triggered the large garage door
actionItem: Large_Garagedoor_Opener
item: Large_Garagedoor_Sensor
widget:
value: ' '
config:
action: command
actionCommand: "ON"
actionItem: Large_Garagedoor_Opener
icon: oh:garagedoor
iconUseState: true
item: Large_Garagedoor_Sensor
label: "=(items.Large_Garagedoor_Sensor.state == \"OPEN\") ? \"open\" : \"closed\""
title: Large Garage Door Opener
Large_Garagedoor_Opener:
type: Switch
label: Large garage door opener
icon: material:settings_remote
format: '%s'
groups:
- Large_Garagedoor
channel: mqtt:topic:mosquitto:cerberos_sensor_reporter:garagedoor1_opener
metadata:
ga:
value: Garage
listWidget:
value: oh-list-item
config:
action: command
actionCommand: "ON"
actionItem: Large_Garagedoor_Opener
badge: "=(items.Large_Garagedoor_Sensor.state == \"CLOSED\") ? \"closed\" : \"open\""
badgeColor: "=(items.Large_Garagedoor_Sensor.state == \"CLOSED\") ? \"green\" : \"red\""
icon: "=(items.Large_Garagedoor_Sensor.state == \"CLOSED\") ? \"f7:house\" : \"f7:house_fill\""
iconColor: "=(items.Large_Garagedoor_Sensor.state == \"CLOSED\") ? \"green\" : \"red\""
listButton: false
title: Large Garage Door
matter:
value: OnOffPlugInUnit
Small_Garagedoor_Sensor:
type: Contact
label: Small garage door
icon: material:garage
format: '%s'
groups:
- Small_Garagedoor
- DoorsStatus
tags:
- OpenState
- Status
channels:
mqtt:topic:mosquitto:cerberos_sensor_reporter:garagedoor2:
profile: basic-profiles:debounce-time
toItemDelay: 1000
metadata:
doorOpenReminder:
value: ' '
config:
defaultAlertDelay: PT90M
defaultRemPeriod: PT90M
listWidget:
value: widget:rlk_garagedoor_list
config:
control_item: Small_Garagedoor_Opener
name: Small Garage Door
sensor_item: Small_Garagedoor_Sensor
matter:
value: ContactSensor
Small_Garagedoor_Opener:
type: Switch
label: Small garage door opener
icon: material:settings_remote
format: '%s'
groups:
- Small_Garagedoor
channel: mqtt:topic:mosquitto:cerberos_sensor_reporter:garagedoor2_opener
metadata:
ga:
value: Garage
listWidget:
value: widget:rlk_garagedoor_list
matter:
value: OnOffPlugInUnit
Small_Garagedoor:
type: Group
label: Small Garagedoor
icon: material:toggle_on
groups:
- Garage
tags:
- GarageDoor
metadata:
listWidget:
value: ' '
config:
action: command
actionCommand: "ON"
actionFeedback: Triggered the small garage door
actionItem: Small_Garagedoor_Opener
item: Small_Garagedoor_Sensor
widget:
value: ' '
config:
action: command
actionCommand: "ON"
actionItem: Small_Garagedoor_Opener
icon: oh:garagedoor
iconUseState: true
item: Small_Garagedoor_Sensor
label: "=(items.Small_Garagedoor_Sensor.state == \"OPEN\") ? \"open\" : \"closed\""
title: Small Garage Door Opener
The main thing is I have a separate Item for the status and to trigger the openers.
My MainUI widget:
uid: garage_widget
tags:
- card
- garage
props:
parameters: []
parameterGroups: []
timestamp: Sep 20, 2023, 10:58:06 AM
component: f7-card
config:
title: '=(items.GarageCamera_Status.state === "ON") ? "Garage Doors" : "Garage
Doors: Camera Offline!"'
slots:
default:
- component: f7-row
config:
class:
- justify-content-center
slots:
default:
- component: f7-col
config:
width: auto
slots:
default:
- component: oh-image-card
config:
refreshInterval: 3000
style:
height: auto
width: 100%
url: '=(items.GarageCamera_Status.state === "ON") ?
items.GarageWyzeCamera_ImageURL.state :
"/static/garage.jpg"'
- component: f7-row
config:
class:
- justify-content-left
slots:
default:
- component: f7-col
slots:
default:
- component: oh-label-card
config:
action: command
actionCommand: ON
actionItem: Small_Garagedoor_Opener
footer: Small Garage Door Opener
icon: '=(items.Small_Garagedoor_Sensor.state == "CLOSED") ? "f7:house" :
"f7:house_fill"'
iconColor: '=(items.Small_Garagedoor_Sensor.state == "CLOSED") ? "green" :
"orange"'
item: Small_Garagedoor_Sensor
label: '=(items.Small_Garagedoor_Sensor.state == "OPEN") ? "close" : "open"'
- component: f7-col
slots:
default:
- component: oh-label-card
config:
action: command
actionCommand: ON
actionItem: Large_Garagedoor_Opener
footer: Large Garage Door Opener
icon: '=(items.Large_Garagedoor_Sensor.state == "CLOSED") ? "f7:house" :
"f7:house_fill"'
iconColor: '=(items.Large_Garagedoor_Sensor.state == "CLOSED") ? "green" :
"orange"'
label: '=(items.Large_Garagedoor_Sensor.state == "OPEN") ? "close" : "open"'
I also have a camera to monitor the doors.
Rules:
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Large_Garagedoor_Sensor
type: core.ItemStateChangeTrigger
- id: "2"
configuration:
itemName: Small_Garagedoor_Sensor
type: core.ItemStateChangeTrigger
conditions: []
actions:
- inputs: {}
id: "3"
configuration:
type: application/javascript
script: >-
const opener = items[event.itemName].semantics.equipment.members.find(i
=> i.type == "Switch");
console.debug('Found garage door opener Item ' + opener.name);
opener.postUpdate((event.newState == "CLOSED") ? 'OFF' : 'ON');
type: script.ScriptAction
GA treats the ON/OFF status of the control Item to indicate the OPEN/CLOSED status of the door, so this rule keeps that Item in sync with the contact sensor. Any command to the control Item causes is interpreted as a button press by the controller with the relay connected to the opener button.