Hardware setup for water meter pulse output

The municipality installed today a new water meter with pulse output. Before I start to connect my ESPHome device, I would like to verify the hardware setup to avoid any possible damages caused. I have little skills for the electronics here.

Water meter device: Axioma F1/IP65
Max load current: 20 mA
Max voltage: 50V
Pulse length: 125 ms
Pulses per litre: 1

Planned setup
+Pulse → D2 (GPIO04)
GND → G

ESPHome configuration:

sensor:
  - platform: pulse_counter
    pin:
      number: GPIO04
      inverted: true
      mode:
        input: true
        pullup: true
     unit_of_measurement: 'l/min'

Questions:

  • Can I connect PINs directly as above or do I to add a separate power source with a pullup resistor as seen in the diagram below
  • Any other problems with the above setup