Template sensor - refresh rate - heating type

Hello,
I have a contact sensor on my gas meter. It opens and closes every 0.01 m3 and adding 0.01 m3 to a counter in HA:

- id: '1639044086214'
  alias: Gazomierz
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.gazomierz_contact
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: counter.increment
    target:
      entity_id: counter.licznik_gazu
  mode: single

Depending on heating type being currently used it updates with different speeds.

If house heating is on I usually get 0.01 m3 increasement every 80-90 seconds.
If water heating is on I usually get 0.01 m3 increasement every 30 seconds.

I would like to create a binary sensor or even 2 binary sensors that detects these kind of states.
So I need 3 states:

  1. No increcement for more than 120 seconds
  2. detect open/close every 90 seconds (that would turn on first binary sensor)
  3. detect open/close every 30 seconds (that would turn on second binary sensor)

I tried trend but it doesn’t work.
Any idea how to achieve this?

It should be the perfect integration for this application.

What went wrong?

When the heating goes off there is no read out from the meter. It just stops. The trend sensor doesnt go off in this case.