Can I pass cover template action failures to Homekit via the HA Homekit integration?

TL;DR: is it possible to pass failure info from a cover template action (e.g. open_cover) to Apple Homekit via the HA Homekit integration?


I’ve built yet-another garage door opener using:

  • A Sonoff SV, with the relay connected to terminals on the garage door opener and a reed switch that detects when the door is closed and is connected to a GPIO.
  • Tasmota
  • Home Assistant with:
    • the Tasmota integration, which exposed the relay and the reed switch as a button and binary sensor;
    • a cover template, which wraps the button and sensor into a garage door cover; and
    • the Homekit integration, which exports the cover to my Apple Home universe.

I can open the garage door by talking to Siri or by poking and prodding my Apple Watch or iPhone.

There’s nothing novel here, and it all works reasonably well.

There’s one pitfall, however. I actually have two of these set up at different (widely separated) locations and I’ve discovered that it’s easy to trigger a garage door in the Apple Watch Home app while I’m try scroll around and figure out which location it’s using.

I’ve triggered the garage door in the remote location more than once… While my friends think this is hilarious, it’s a pain to get someone to go look at my garage door to make triply sure that it’s closed (with time, I’m sure I’ll come to trust the reed switch sensor, but…).

My solution is to use a spare GPIO on the Sonoff as a “virtual relay” which I pass up through the stack as a “Garage door enabled” switch. I use geofencing in Apple Home to turn the switch off when I leave a location and can override it manually. I’ve extended the cover actions to look like so (full template included below):

      open_cover:
        - condition: state
          entity_id: binary_sensor.garage_door_opener_switch1
          state: "on"
        - condition: state
          entity_id: switch.garage_door_opener_enabler
          state: "on"
        - action: switch.turn_on
          target:
            entity_id: switch.garage_door_opener_button

This works, in the sense that the garage door will only open when the enabler is on. Working with the cover in Home Assistant is solid.

BUT, when I use an Apple Home App, it doesn’t seem to know that the garage door is disabled and just sits forever in the “opening” state.

This all leads me to my questions:

  • Is there some way for the open_cover operation to pass success/failure/status info back up through the Apple Homekit integration to Apple Home, so that it knows that it’s request to open the door failed?

  • Is there some way to get the garage door in Apple Home (via the HA Homekit integration or ???) to time out and get it’s status based on the sensor?

Thanks for any suggestions!

g.


Here’s the full cover template, in case it’s useful:

- platform: template
  covers:
    #
    # THE MAIN THING TO KNOW WHEN REASONING ABOUT THE BITS BELOW...
    # When the door is closed, binary_sensor.garage_door_opener_switch1 is on.
    #
    garage_door:
      device_class: garage
      unique_id: "garage door"
      friendly_name: "Garage Door"
      # Value template returns open/true or closed/false.  When the
      # switch is off, the value should be open/true.
      value_template: "{{ is_state('binary_sensor.garage_door_opener_switch1', 'off') }}"
      # You can only open the door if it's currently closed, hence the
      # condition test.
      open_cover:
        - condition: state
          entity_id: binary_sensor.garage_door_opener_switch1
          state: "on"
        - condition: state
          entity_id: switch.garage_door_opener_enabler
          state: "on"
        - action: switch.turn_on
          target:
            entity_id: switch.garage_door_opener_button
      # You can only close the door if it's currently open, hence the
      # condition test.
      close_cover:
        - condition: state
          entity_id: binary_sensor.garage_door_opener_switch1
          state: "off"
        - condition: state
          entity_id: switch.garage_door_opener_enabler
          state: "on"
        - action: switch.turn_on
          target:
            entity_id: switch.garage_door_opener_button
      # You can always stop the motion.
      stop_cover:
        - condition: state
          entity_id: switch.garage_door_opener_enabler
          state: "on"
        - action: switch.turn_on target: entity_id: switch.garage_door_opener_button ```