I’d like to have a way to open my garage door AND unlock my door from my car’s CarPlay setup. HOWEVER, I don’t want the door to unlock whenever someone opens the garage because I consider that a security concern. I can open the garage door via my iphone and the homekit integration which appears in carplay.
Is there a way to unlock my door ONLY when the garage door is opened via homekit? Is there another way to achieve something similar?
I know there’s a context on triggers that can be accessed in automations (I do this). If you act on something from the HA UI there will be a user context. I don’t know what will be the case for actions from HomeKit (assuming you use the HomeKit controller integration), but this might give you something to look into.
I have a HomeKit-only front door lock. With three different home automation ecosystems now, I have used HomeKit’s automations and arrival/departure presence detection to automate unlocking the front door and turning the alarm system on/off.
Unless something has changed recently, the big gotcha is that Apple’s automations cowardly refuse to unlock doors based on arrival. I have to use a virtual/dummy switch (input_boolean helper in HA) on all of my back-end HA platforms to control the lock, with four different HomeKit automation routines to keep the lock and virtual switch in sync based on whether the lock was opened/closed via the virtual switch or at the physical lock.
Anyway, I assume that you can set something similar up from the HomeKit automation side…
Do you have any good examples? I get the general concept, but I’m having trouble determining the event type and how to use use the context to filter for only HomeKit events.
Can you share your method or link to something similar? Obviously from a programmatic standpoint its simple but I’m new to working with these kind of entities. I haven’t yet learned homw to explore and experiment with them.
I don’t specifically do what you need, so I don’t have a good example of exactly that, but this is an example of how I determine which user triggered a script. This just shows how to access the context.
- service: persistent_notification.create
data:
title: System
message: >-
{% set user_id = states.script.shutdown_remote_host.context.user_id %}
{% set triggered_by = (states.person | selectattr('attributes.user_id','==', user_id)) | list | first or "system" %}
{% set first_name = "System" if triggered_by == "system" else state_attr(triggered_by.entity_id, "friendly_name").split()[0] %}
{{ first_name }} shut down {{ name }}.
Under the developer tools, try to listen to events to see the full JSON of what’s received. I didn’t know myself what to listen for when doing a quick test, so just my main gate via HomeKit while listening for all events (* – this results in a lot of data very quickly in my case).