Trigger from above value x to value y

Hi there,

I am looking for a trigger where I can start my automation if the value of an sensor is above value x and changes to a specific value y but I can’t find anything for this. Does anyone have a suggestion for me, please?
This doesn’t work, but I’m looking for this:

platform: state
entity_id:

  • sensor.tracker_tim
    from: “> 5”
    to: “0”

Background: I have an Tracker at my keychain which pings every 60 seconds. I have an helper which counts the minutes after the last signal. When leaving it counts high and arriving home the next signal reset it to “0” minutes.
I have a half working automation which triggers the come back routine when arriving home but when I leave the house with my wife and leave the keychain at home the automation triggers falsely. And I can’t specify a fix from value cause it depends on my leave.
I assume there’s a smart and small solution, so I thank you for every tip.

The trigger:

trigger:
  - platform: numeric_state
    entity_id: sensor.tracker_tim
    below: 5

Will trigger when the sensor value crosses from above 5 to below 5.

You can then follow it up with a state condition that checks if the current state is 0.

condition:
  - condition: state
    entity_id: sensor.tracker_tim
    state: 0

The condition will be checked right after the trigger.

So it has to go from above 5 directly to 0 to pass to the actions.

Also FYI to format your post correctly highlight the text and press the </> button (may be in the “cog” settings menu on mobile displays).

Or you can do this: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

Ah, perfect.
At the moment I’m still overwhelmed for all the options and the small differences which makes it a smart und simple solution and a big and complicated thing with additional helpers etc.

Thank you very much and the hint with the formatting of code. On my mobile device I didn’t see the right button, only the Blockquote was obvious and I thought it’s better than no format. :smiley:

It seems to work btw. Thank you very much!