Running vacuum if history shows it was not cleaning in the last 24 hours (and i'm not at home)

Hello, i have a Mi Mop Pro vacuum and have it integrated in Home Assistant with home-assistant-vacuum-styj02ym.
Now I want to automate it but I can’t find a way to analyze the last day of history data and using it to make a rule. Sadly my vacuum does not have a “last running” state or something like that so I thought of using the history. This are the supported states of the vacuum:

    0: STATE_IDLE,
    1: STATE_IDLE,
    2: STATE_PAUSED,
    3: STATE_CLEANING,
    4: STATE_RETURNING,
    5: STATE_DOCKED,
    6: STATE_CLEANING,  # Vacuum & Mop
    7: STATE_CLEANING   # Mop only

I thought to look in the history if STATE_CLEANING was active in the last 24 hours and if not, run if if I’m not home.
Maybe someone can help out?

Maybe create a History Stats sensor for it and use it in your automation?

sensor:
  - platform: history_stats
    name: Cleaning last 24h
    entity_id: <vacuum entity I’d>
    state: < state(s) to monitor >
    type: count
    duration: 24:00:00

Thanks, I’ll try it later!