Detect Age of Last Update of an Sensor

Hi, i integrate an Sensor to detect Water count Impulses.
But i want to create a sensor was tell me the water ist flowing or not.
The background is i want detect an open water tap or a hose come off.

The Sensor detect a 1 Liter Impulse.

My Question is, how can i create a Sensor that tells me the last_changed Value Age.

Is the Reed 1L Sensor last_change Age less than a Minute then the Value is Yes (Water is flowing)
Is the last_change Age older than a Minute, then the Value is Off (No Water is flowing)

Can anybody help me with the Syntax of that value? Thanks.

I try but not sure

- binary_sensor:
      - name: "Wasserfluss"
        state: "{{ now() - states.sensor.wasserverbrauch.last_changed < timedelta(seconds=30) }}"

This would be true if the time delta in seconds is less than 30 seconds:

- binary_sensor:
    - name: "Wasserfluss"
      state: "{{ (as_timestamp(now()) - as_timestamp(states.sensor.wasserverbrauch.last_changed)) | int  < 30}}"
1 Like