How to set an alert if the value measured by the sensor does not change for a certain time?


I would like to ask you for help with setting up automation. I looked through some older threads about this, but unfortunately I couldn’t get the automation set up properly.
The point is that I am using an ultrasonic sensor to measure the distance. If the value that the sensor measures (in cm) remains unchanged for a long time, I know that the sensor needs to be cleaned.
So I would need an automation that sends a notification to the phone if the sensor keeps measuring the same value for a certain period of time.

I set this up (10 minutes is for easy testing):

  alias: Test
  description: ''
  - platform: state
    - sensor.ts_ft002_hladinomer_d
      hours: 0
      minutes: 10
      seconds: 0
  condition: []
  - device_id: b217d35d300b78be20b279023bb2367c
    domain: mobile_app
    type: notify
    message: Msg
    title: Title
      ttl: 0
      priority: high
  mode: single

The notification appears if the value does not change for 10 minutes, but unfortunately it comes three times in a row. And this is repeated over and over. Sometimes every 10 minutes and sometimes even more often.
Please advise how to set it up better?

Once again, I am asking for advice. If I have the automation set up, as mentioned above, the notification goes several times repeatedly, even earlier than after 10 minutes.
I need to make it so that the notification comes if the value measured by the sensor is still the same for 10 minutes. The sensor measures once every three minutes. This means that if there are three measurements in a row with the same value, I will get a notification.
I can’t even use state.last_changed because state.last_changed along with state.last_updated changes every 3 minutes even though the measured value is still the same.
It occurs to me that I could perhaps use the numeric state of the sensor as a trigger. However, I don’t know how to enter the template value: if the measured value with the seznor is the same for 10 minutes.