I have an automation to open a garage door automatically as I drive towards my house. It worked for a while and then stopped working. I used the device_tracked as the trigger. I use the same automation for my wife, and for her it never triggered.
I have checked and re-checked all the phone companion app permissions and sensors (including making sure the app is not a put to sleep) and - as you will see below - this is unlikely to be the issue.
The issue is the trigger. It never fires. I have tried this approach:
- trigger: zone
entity_id: device_tracker.sm_s938b
zone: zone.home
event: enter
This worked for a while and the stopped working.
So I have also tried this approach:
- trigger: state
entity_id: person.john_smith
to: home
And out of an excess of frustration I have even tried the either-or approach:
triggers:
- trigger: zone
entity_id: device_tracker.sm_s938b
zone: zone.home
event: enter
- trigger: state
entity_id: person.john_smith
to: home
Now, here is the twist. To debug this I created a few separate automations to just send me a notification to my phone. And both of these triggers fire appropriately and reliably on that automation. So for some reason the EXACT same trigger fires on one automation but not another. Can anyone help me debug this?
I include the code of the entire malfunctioning automation below, as I suspect perhaps something else (like the complicated jinja stuff at the bottom?) might be interfering with the processing of the triggers. I can just not imagine how or why. The jinja template at the bottom analyses the leftmost 17 characters of every bluetooth connection (ie the MAC) to determine which vehicle I am driving and hence which garage door should open.
Here goes:
alias: Open correct garage door
description: Open correct garage door for approaching vehicle
triggers:
- trigger: zone
entity_id: device_tracker.sm_s938b
zone: zone.home
event: enter
- trigger: state
entity_id: person.john_smith
to: home
conditions:
- alias: check whether garage door is closed
condition: template
value_template: >
{{ is_state('binary_sensor.omnilink_garage_dr_'~ garage_door_num, 'off')
}}
- alias: In which case no vehicle is connected
condition: template
value_template: "{{ garage_door_num != 0 }}"
actions:
- action: light.turn_on
metadata: {}
target:
entity_id: light.omnilink_garagedr_{{ garage_door_num }}
data: {}
variables:
garage_door_num: >
{# #1 Jeep, #2 VW, #3 Audi, 0 = none #}
{% set connected = state_attr('sensor.sm_s938b_bluetooth_connection',
'connected_paired_devices') | default([]) %}
{% set macs = connected | map('regex_search', '^.{17}') | map('upper') | list %}
{% if
'F8:6D:CC:A7:ED:2D' in macs %}
1
{% elif '9C:8D:7C:32:6F:52' in macs %}
2
{% elif '00:0E:9F:73:06:72' in macs %}
3
{% else %}
0
{% endif %}
mode: single
I’m a bit at my wit’s end here. Like I said, the exact same triggers fire if I use them in simpler automations. But in this case, the automation does not trigger at all.

