Water flow sensor relay control and usage monitoring

Hello, I need help with a ESPHome config.
I cant code to save my life

I have a reverse osmosis system that makes potable water available in my house.
this system has a UV sterilizer light.

The light stays on 24/7 but the system only runs a few hrs a day, the UV bulbs have to be replaced every 6 months do to this 24/7 operation.

I have an ESP-12F_Relay_X2
and a water flow sensor Gredia GR-402b

I would like to have the ESP switch on relay1 when it detects a pulse from the sensor and keep it on for 5 minutes, it also needs to reset the timer back to 5min every time a pulse is detected.

additionally, it would be nice to have the usage reported to Home Assistant, so I can add monitor use etc.

I really would like the sensor relay logic to be on the ESP and not use a hass.io automation.

but I am truly clueless beyond the most basic configs


here is some starting code just to define what I do know

esphome:
  name: WaterRoom-RO-Controller 

esp8266:
  board: esp12e

# Use the blue LED in the device as a status LED, which will blink if there are warnings (slow) or errors (fast)
status_led:
  pin:
    number: GPIO2
    inverted: True

# x2 relay outputs, exposed as switches in Home Assistant
switch:
  - platform: gpio
    pin: GPIO5
    name: Relay1
    id: relay1
  - platform: gpio
    pin: GPIO4
    name: Relay2
    id: relay2
  # Blue LED on Board (not ESP board) as switch in Home Assistant
  - platform: gpio
    name: Led16
    pin: GPIO16
    inverted: true
	
	

sensor:
  - platform: pulse_counter
    pin: GPIO2
    unit_of_measurement: 'L/hr'
    name: 'RO-Feed-Water'
	update_interval: 60s
    filters:
       - lambda: return (x / 38.0) * 60.0;
    unit_of_measurement: "L/hr"

    total:
      unit_of_measurement: 'L'
      name: 'R-O Feed-Water'
      filters:
        - multiply: 0.38  # (1/38 pulses per L)
		
	#2280 pulses per liter or 8630 per gallon
	#F=(38*Q)±3%, Q=L/Min

is there a bounty system here? i need to get this going but its over my head,

add this on your pulse counter:

on_value_range:
     - above: 2.0 # sensor value  indicating flow
        then:
          - switch.turn_on: relay1

and on switch component:

  on_turn_on:
    - delay: 3000s
    - switch.turn_off: relay1