Can I use a global variable inplace of a pin

Hiya Guys,
I have global variable that is set depending on the value comming from a magnetic sensor. I use it to pick up gas usage from my gas meter. it works great but I would like to find out the frequence of the pulses so i can count current gas usage.

I beleive pulse width will help me for this, but i need to point it at a global variable and not a GPIO in.

type or paste# Example configuration entry
globals:
   - id: gas_high
     type: bool
     restore_value: no
     initial_value: 'false'

sensor:
  - platform: pulse_meter
    pin: gas_high
    name: "Pulse Meter" code here

Did you try the “pulse counter” and “pulse meter”??
Familiarize yourself with the documentation before you try to reinvent the wheel. Youll save yourself a lot of grief.