Event trigger when HomeKit sends a command?

I want to fire an action when HomeKit sends the command to close my garage door. Not just when the garage closes, but specifically when HomeKit closes it (see screenshot below). This event is written to LogBook. I just don’t know how to capture it in an automation. Can you help?

image

You want to watch for the homekit_state_change event.

Thanks @bdraco! I was not aware of homekit_state_change. Would my trigger and condition look something like the below?

  trigger:
    - platform: event
      event_type: homekit_state_change
  - condition: template
    value_template: '{{ "close_cover" in trigger.event.data.message }}'

You probably want a condition to match the entity_id as well

It took some tinkering, but I got it. It all went into the trigger, so I didn’t need a condition. Thanks for your help!

  trigger:
    - platform: event
      event_type: homekit_state_change
      event_data:
        entity_id: "cover.garage_door"
        service: "close_cover"
2 Likes