Hi all, I’m pretty new to Home Assistant and need some help with a configuration issue I’m having. I have a Shelly switch that I’m using to control my garage door. The Shelly switch is recognized as two separate components, one is the actual switch and the other is the sensor of the switch (which I’m using to read as open for on and closed for off). I combined the two into a Cover so that Home Assistant recognizes the switch as a garage door and properly reads the status of the door. Here is my cover which works fine for the most part when using Home Assistant:
The problem is that I use HomeKit to publish my devices into my Apple Home. It works fine there too with one major exception, Apple Home automations and Siri. As an example I have an automation that triggers when I plug my phone into CarPlay, it checks to make sure that all the doors are shut, lights off and alarm armed. Now, when it does this even though the state of garage door may already be “Closed” it’s firing off the command close_cover in Home Assistant. This results in my garage door opening when I want it to stay closed!
What i’d like to do is have the service close_cover run an if/else, but this is where I’m stuck. If the door is open (sensor ON) then fire the command to turn on the switch. If the door is closed (sensor OFF) then i want it to do nothing. I experimented with the following but it results in configuration errors:
I’m on my phone but I think what you need to do is to define value_template with what determines your cover’s state. Based on that, the appropriate action (like close_cover) will be invoked. In the service section for action, remove the template stuff and just use the service call and entity ID.
This works fine, it’s just when HomeKit evokes the close_cover command it basically just toggles the switch ignoring the fact that the door is already closed.
Because there is no actual “off” with this switch, it just acts like a momentary button which automatically turns off after 1 second. Otherwise my garage door would be operating non-stop.
The cover should be doing this already. It’s odd that it’s not suppressing the turn off. That leads be to believe the value_template is incorrect. But it does look correct syntaxtually. Either way, you can make a script with a condition in your close cover