How to troubleshoot automations that auto start during service restart?

One of my automations that opens the garage when group “family” state changes to “home” (at least one group member comes home) starts by itself when I restart the service. I have added the check for HASS start and its strange why it started so late…
Here is the sequence of events:

Open garage when family member comes home and garage door is closed has been triggered by state of group.family
11:32:38 PM - 18 minutes ago - Show trace
Home Assistant has started up turned on by Hass Startup Notification
11:29:03 PM - 22 minutes ago
Uptime seconds changed to 50
11:29:00 PM - 22 minutes ago
Garage Door turned on by Car in Garage
11:28:36 PM - 22 minutes ago
Car in Garage was detected at home
11:28:36 PM - 22 minutes ago
garage_door_lock was locked
11:28:31 PM - 22 minutes ago
Hass Startup Notification has been triggered by Home Assistant starting
11:28:31 PM - 22 minutes ago - Show trace
Garage Door Status changed to Closed
11:28:31 PM - 22 minutes ago
Family changed to Home
11:28:31 PM - 22 minutes ago

We were all at home. Group family status before restart was Home. So looking at the time after restart, Family changed the status to “Home”, but that was before this event, that is a condition of the automation, that happened 30 seconds later:
Home Assistant has started up turned on by Hass Startup Notification
11:29:03 PM - 22 minutes ago

And the automation was triggered at 11:32:38 PM, which is like 3.5 mins later. I am lost as to why it happened and what to do to stop it.

Tace has this:
Triggered by the state of group.family at June 4, 2021, 11:32:38 PM
Test state condition
condition 0 entity_id 0
Test state condition
condition 1 entity_id 0
Call service cover.open_cover on entities cover.mygarage
1 second later
Garage Door Status (sensor.garage_status) changed to Opening
Call service notify.family_devices
Finished at June 4, 2021, 11:32:39 PM (runtime: 1.12 seconds)

And… Looking at the trace file again, there is another event just seconds later, but this time it did not fire up, probably because it was already open:
Triggered by the state of group.family at June 4, 2021, 11:32:52 PM
Test state condition
condition 0 entity_id 0
Stopped because a condition failed at June 4, 2021, 11:32:52 PM (runtime: 0.00 seconds)

This is my automation:

alias: Open garage when family member comes home and garage door is closed
description: ''
trigger:
  - platform: state
    entity_id: group.family
    to: home
condition:
  - condition: state
    entity_id: cover.mygarage
    state: closed
    attribute: door_state
  - condition: state
    entity_id: input_boolean.homeassistant_booted
    state: 'on'
action:
  - service: cover.open_cover
    target:
      entity_id: cover.mygarage
  - service: notify.family_devices
    data:
      message: >-
        Family member {{ trigger.to_state.attributes.friendly_name }} came home.
        Opening garage
mode: single

What was the state change on the group. Is it going from unavailable to home? Not home to home? If it’s the former add from: and to: in the trigger

After this event:
[Home Assistant] stopped
11:27:48 PM - 47 minutes ago

the only event relating to the Family is this one:
Family changed to Home
11:28:31 PM - 22 minutes ago

In the log for the group, it looks like it was in the “Unknown” state while services were starting.
I have changed the automation to be From: not_home To: home, so that it does not pickup the “Unknown” state event, but I cannot understand why it started. Yes, the trigger was “changed to home”, but that should have triggered it BEFORE the “HASS started” condition, so it should have failed

This set of conditions should prevent nearly all false triggers after a restart. Apologies for the screenshot of text, I’m on my mobile:

2 Likes

If @ home text :grin:

thank you! will use these for sure

Is it possible to somehow define it globally, so that automations do not launch if these conditions are met?

No.

=) it was worth a try