Can we prevent Error initializing trigger in automation?

because currently there’s an issue with the integration creating the trigger sensors used in the automation I see these:

WARNING (MainThread) [homeassistant.components.homeassistant.triggers.numeric_state] Error initializing 'Marijn bijna thuis' trigger: In 'numeric_state' condition: unknown entity sensor.here_marijn_naar_huis

on this automation, for which the conditions on the trigger entity not to be None apparently dont suffice:

  - alias: Marijn bijna thuis
    id: marijn_bijna_thuis
    trigger:
      platform: numeric_state
      entity_id: sensor.here_marijn_naar_huis
      below: 15
      above: 5
    condition:
      - >
        {{is_number(trigger.to_state.state)}}
      - >
        {{trigger.to_state is not none and
          trigger.from_state is not none and
          trigger.to_state.state != trigger.from_state.state}}
      - >
        {{states('proximity.marijn_home') != 'not set'}}
      - >
        {{state_attr('proximity.marijn_home','dir_of_travel') == 'towards' and
          states('person.marijn') != 'home'}}
      - condition: state
        entity_id: input_boolean.notify_presence
        state: 'on'
    action:
      service: notify.m
      data:
        message: >-
          Marijn is op {{states('proximity.marijn_home')}} km van huis,
          en is over {{states('sensor.here_marijn_naar_huis')}} minuten thuis!

how can we prevent an error like this?

1 Like

It might be better to track the user’s device entering an area.

For example: create a new zone with radius X and center on your house.
Then trigger the automation when the device enters that zone.

my point was not so much the logic of the automation itself, (which has been working perfectly fine over the years) but the fact core throws the warning it can not initiate the automation because of the non-existing trigger entity.

In Discord, we’ve established no condition can prevent that.
So, in the event this would happen again, the warning does indicate an issue and should be looked in to :wink:

1 Like

Did you manage to get rid of this warning? Having the same issue with a trigger sensor.