Help why this rule doesn't fire in automation

So I have a rule

  - platform: template
    value_template: '{{(states.proximity.fred_distance_from_home | float) >=2.0 and
      (states.proximity.fred_distance_from_home | float) <=8.0 and states.proximity.mark_distance_from_home.attributes.dir_of_travel
      == "towards" }}'

and it shows no error, but never seems to fire, even though the conditions i.e. proximity is between 2 and 8 from home and direction is towards have been tested. Any ideas?

Did you test with the template editor in the dev tools?

Are you getting any warnings in the log? For example, that it has trouble identifying the entity (or entities) within value_template responsible for triggering?

If it can’t find the entity it must monitor, it will post a warning to the log. If this is the case, it will only evaluate the value_template on startup and then never again. To fix it, you must explicitly identify the entity (or entities) to be monitored (because Home Assistant can’t automatically identify it).

just a thought, but you are using fred_distance_from_home for distance but mark_distance_from_home for direction. Not really sure if that’s what you meant to do…

Sorry that was just a typo, tried it in template editor and it fires, could be something to do we the update frequency of the proximity and direction, thanks for the help I will try again :slight_smile:

If you trigger the automation once a minute and move your template to conditions, does it work?
Not saying that would be the final solution just a thought to help debug.