History_stats going mad?

Need some help, because this is driving me crazy!

I have an automation set up that turns on my hot water circulation pump for 2 minutes every 10 minutes.
As I had some issues in the past with the reliability of my Hook thingie, I set up a history_stats sensor and an automation that triggered a notification if the pump had been running for too long.

The sensor is supposed to measure how long (in %) the pump was on during the last 20 minutes (should be 20%, right?) and a notification is supposed to be triggered when the value is above 42%. This value should never be reached if my basic math above is correct.

Nevertheless, a notification comes through on average at least once per hour.
I had occasions where I received a notification every ten minutes.

Is there something wrong with my setup or is the sensor just going nuts?

#######################################################################
# Setting up the history sensor
sensor:
  - platform: history_stats
    name: CPump ON last 20min
    entity_id: switch.mplug2
    state: 'on'
    type: ratio
    end: '{{ now() }}'
    duration: 00:20

######################################################################
# Notify if Circulation Pump has been on for long
automation:
  - alias: CPump on too long
    trigger:
      platform: numeric_state
      entity_id: sensor.cpump_on_last_20min
      above: '42.0'
    action:
      - service: notify.mypushbullet
        data_template:
          title: "HASS says:"
          message: 'CPump has been on for too long @{{now().strftime("%H:%M")}}h!'

I also display the value of the sensor in a card and it sometimes shows values up to 100% although the pump has been off for the last 8 minutes.

And finally, this is what my history shows:

The pump turns on for 2 minutes every 10 minutes:

The stats show it’s been on for 60% of the last 20 minutes many times:

Is this an error in the platform people have seen before or am I working on some incorrect assumptions here?

May I ask you what circulation pump you use and how it’s connected to ha?

This is the pump I’m using:
https://www.amazon.com/Watts-500800-Instant-Recirculating-Install/dp/B000E78XHG

I simply have smart plug (TP-Link HS105) that turns power for the pump on and off.