How to create boolean sensor showing stable/unstable humidity?

I’m using History Explorer custom card which most important task is to monitor humidity levels inside an indoor groow room (agriculture). Its cruicial to keep humidity levels very stable (61-62%).

  1. Green line represents humidity.
  2. Red stripe represents on/off state dehumidifier.
  3. Blue line represents power in Watt of the above.

As you can see from green line at most of time humidity fluctuate in range 61-62 rH. Thats fine. I want to keep it that way.
The issue here is the fluctuation in range off 61-65 coming up every 20 min lasting for about 20 min. This is obviouselly caused by automated dehumidifier. I would like to fine tune the automation to get stable levels 61-62 at all time.

I think a helpfull tool would be first to create a boolean sensor which could be included to history graph’s timeline under dehumidifier on/off state. I would like this sensor to indicate 2 states:

  1. Stable. When humidity changes oscilate in range of 1%
  2. Unstable. When humidity changes oscilate in range greater than 1%.

How can I create such sensor as template in configuration.yaml?