Garagedoor opener in Homekit

Hi everyone,

I’m trying to figure out how to configure my garagedoor opener correct for homekit.

Garagedoor:
I have an electric garagedoor with a single button to open, close and stop de door movement. This button is directly connected to the garagedoor unit

I have a shelly one connected in parralel to this button. When I Press the switch for this, it turns on for 1 second and then back to off, this way it simulates the button press.
Besides the button, I have a reed sensor connected on the bottom of the garagedoor to detect if the door is closed.

In openhab they are configured the same way:
1 Relay item, to open and close the door
1 Input item, to show the status (OPEN, CLOSED)

I now have these 2 items as 2 items in homekit (A door sensor and a swich)
But I know that there is a GarageDoorOpener object for the homekit plugin, but I dont know how to connect the ObstructionStatus, CurrentDoorState, TargetDoorState to the Relay and Input item.

Which metadata object should I connect to which homekit item? or do I need additional hardware to make this work?

Hopefully someone can help with this. Thanks in advantage :slight_smile:

1 Like

i have very similar setup but with homematic instead of shelly.
here is my configurations:
items

String    garageDoorStatus     "Garagentor Status [%s]"  <door>  (gGarageDoor)      {homekit="ContactSensor", channel="homematic:HMIP-SWDO:rasmatic:0000:1#STATE"}
Switch    garageSwitch  "Garagetor"    {channel="homematic:HmIP-WGC:rasmatic:001:3#STATE"}

Group           gGarage           "Garage"                                      {homekit="GarageDoorOpener"}
Switch          garageObstruction "Garage Obstruction"          (gGarage)       {homekit="ObstructionStatus"}
String          garageCurrentState "Garage Current State [%s]"  (gGarage)       {homekit="CurrentDoorState"}
String          garageTargetState "Garage Target State [%s]"    (gGarage)       {homekit="TargetDoorState", alexa="ModeController.mode" [category="EXTERIOR_BLIND", supportedModes="Closed=@Value.Close, Open=@Value.Open",actionMappings="Close=Closed,Open=Open", friendlyNames="Garage", language="de"]}

rules

rule "garage door state update"
when
     Item garageDoorStatus received update
then
     if (garageDoorStatus.state == "OPEN" ) {
        garageCurrentState.sendCommand("OPEN")
        garageTargetState.postUpdate("OPEN")
     } else {
         garageCurrentState.sendCommand("CLOSED")
        garageTargetState.postUpdate("CLOSED")
     }
    garageSwitch.sendCommand(OFF)
end

rule "garage door target state"
when
     Item garageTargetState received command
then
    garageSwitch.sendCommand(ON)
    garageSwitch.sendCommand(OFF)
end
3 Likes

I’ve tried to fix it with your data, but I haven’t been completely solved it. I was wondering, in your configuration you have two groups:

Your garageDoorStatus is connected to the group gGarageDoor
and all your other items are connected to the group gGarage

And only the gGarage has the homekit tag GarageDoorOpener and the gGarageDoor isn’t shown in your configuration.

At my configuration the garagedoor only pops up in homekit when I connect the garageDoorStatus to the gGarage instead of .gGarageDoor. Am I doing something wrong here or should I connect it to gGarage?

you dont need to have gGarageDoor group. it is basically a group for contact sensor i want to add “battery status” to it, therefore the group

1 Like

Ah good to know, I Found out that the reason something isn’t working is because the if statement in the rule isn’t resolved correct. When lookin at the logs I see the following:

2020-10-12 12:14:45.759 [vent.ItemStateChangedEvent] - ShellyGarageDeurInput changed from CLOSED to OPEN
2020-10-12 12:14:45.762 [ERROR] [lipse.smarthome.model.script.LogTest] - Input Update
2020-10-12 12:14:45.770 [ERROR] [lipse.smarthome.model.script.LogTest] - INPUT CLOSED

When my rule is like this:

rule "garage door state update"
when
     Item ShellyGarageDeurInput received update
then
     logError("LogTest", "Input Update")
     if (ShellyGarageDeurInput.state == "OPEN" ) {
        logError("LogTest", "INPUT OPEN")

        garageCurrentState.sendCommand("OPEN")
        garageTargetState.postUpdate("OPEN")
     } else {
        logError("LogTest", "INPUT CLOSED")

        garageCurrentState.sendCommand("CLOSED")
        garageTargetState.postUpdate("CLOSED")
     }
    ShellyGarageDeurRelay.sendCommand(OFF)
end

For some reason it doesn’t accept the if statement to be true:
if (ShellyGarageDeurInput.state == "OPEN" )
I also tried:
if (ShellyGarageDeurInput.state.equals("OPEN"))
But that didn’t change the behaviour

Fixed it by changing the rule to:
if (ShellyGarageDeurInput.state.toString() == 'OPEN' )

Thanks for the help @yfre

1 Like

Hi,
thanks for this thread.
The problem I stumbled upon was different, but it is solved in your rule @yfre:

When I opened the garage door manually (by remote control or simple wired switch) the CURRENT_DOOR_STATE did change. But my rule did not alter the TARGET_DOOR_STATE, so HomeKit got confused because that states did not match. The Home app displayed “closing” or “opening”.

So please always make sure that the target state follows the current state, like it is done in @yfre’s rule. Use an “postUpdate()” so that the state is updated but no command executed. Use “received command” in the rule that triggers the motion.

Seems very obvious, but this might help anyone else.

Hi,

Sorry but I need some help here. I have also a Shelly One in place to control my garage door.
Everything is working fine so that there is one button for controlling UP, STOP, DOWN, STOP and a String where the current status is stored.

I have added the homekit items so that the Garage appears in my Home App. If I control my Garage Door via OH the Homekit App is updated correctly.
The issue I have currently is, that when I try to open/close the garage door from the Homekit app nothing happens. It looks that this homekit switch is doing nothing.

I thought that the Switch „garageObstruction“ is doing this stuff and have linked in to my Shelly in PaperUI, too but this changed nothing.

Any hint?

garageObstruction tells whether the garage door is blocked by something.
for open/close you should use TargetDoorState and CurrentDoorState

if it is still not working please share your metadata configuration

Thanks for the reply. I have troubleshoot a little bit further with the event logs. If the homekit switch was set the TargetDoorState is changed.

Now I understood how this is working in general. Then the problem was that my shelly can only turned on. It will turn off after 1 sec automatically. So I have to change the rules a little bit morgen but now it is working.
I can control the garage door still in my OH environment and also via Homekit and carplay directly from inside my car. Thanks

1 Like

Hi all,

checking my luck in this old thread. First, thanks a lot this helped to add my two garagedoors to Homekit. Just one thing, more an Apple question rather than openHAB: Any idea how I can DISABLE siri voice commands for my garagedoors? I want to control only via iPhone/iPad and avoid someone yelling in front of my garage: HEY SIRI OPEN GARAGEDOOR.

thanks in advance

Stefan

1 Like

right, siri control is dangerous as everyone can use it.
i dont think one can disable siri selective. you can disable it for all homekit devices only

just to be precise. when you say “disable for all homekit devices”. Do you mean

  • to completely turn off Siri on my iPhone
  • or to turn off Siri to control any homekit accessory on any phone, but still being able to ask Siri to play a specific song, or inform about the weather

Latter would be fine for me. The only accessories I use are the garage doors for carplay.

hm, i had wrong assumption one can disable/enable siri per app. but it looks like one can only exclude app from search result and suggestions, but not from siri. :frowning:

Whenever i try to open the garage door using Siri on my device, it will always go “you need to unlock your iPhone first”. However since what i use is similar to the others (not Shelly but a Zigbee device that does the same thing) i wonder if closing the garage door (even when closed will toggle and open the garage door and trigger the open) will prompt the same request.

I am also trying to figure out how to connect my Shelly-controlled garage door to Homekit.

Is it correct that the Homekit add-on is only reading the CurrentDoorState item to get the status and setting TargetDoorState if a change is triggered via an Apple device? For the CurrentDoorState, is posting an update enough for the Homekit add-on to register the change, or do I need to post a command? And for TargetDoorState, is the Homekit add-on posting a command?

I also have a the power channel of the Shelly for triggering the garage door, it will then either open/close the garage door depending on its physical state. My input channel of the Shelly is mapped to a status indicator of the garage door and I have a script that updates a status item to OPEN/CLOSED/OPENING/CLOSING.

Is it correct that the Homekit add-on is only reading the CurrentDoorState item to get the status and setting TargetDoorState if a change is triggered via an Apple device?

it is not important what has triggered the change. you can send command from script or via web ui. openHAB will notify homekit about the chnage. important: post update does not trigger any notification on connected channels, e.g. homekit. this is the main difference between update and command. this was done on purpose, sometimes the status has to be changed without notification to connected channels.

add on also sends commands.

1 Like

Understood, thanks. But is the Homekit add-on also processing changes to the TargetDoorState and sending them to Apple devices? If a status change is triggered by other means than Homekit, do I need to update the TargetDoorState or is it sufficient to update CurrentDoorState?

Edit: tested this and yes, TargetDoorState should be updated. I am using the Home Widget app, and that one seems to read the status from TargetDoorState, if it is not updated, the status change is not reflected in the app.

in my case, if current and target states are different, home app shows something like “Opening…”, “Closing…” and if they are the same, then the status is “closed”/“open”

That is interesting - according to the documentation the CurrentDoorState has states for OPENING and CLOSING, and I wrote scripts to set those values. So from your observation that would not have been necessary? I’ll test that, it would simplify my scripting.