Nema 17, a4988 and Esphome Dosing Pump to set target with inputnumber help

I’m currently working on a new project for my hydroponic ph up and down. Got the nema 17 working with esphome and a4988 driver for dispensing of the solution, but I want to have an input_number to control the set_target.

I got the input to work but cannot figure out how to implement it in my code. Any help appreciated

You have this section that is mentioned in esphome documentation of a4988, that needs to go under API with the automation when the input number is changed:

api:

   services:
     - service: control_stepper
       variables:
         target: int
       then:
         - stepper.set_target:
             id: doser_ph_up
             target: !lambda 'return target;'

Current Esphome code:


ota:

wifi:

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:

captive_portal:

stepper:
  - platform: a4988
    id: doser_ph_up
    step_pin: D3
    dir_pin: 
      number: D4
      inverted: true
    max_speed: 3000 steps/s

    # Optional:
    sleep_pin: 
      number: D2
      inverted: true
    acceleration: inf
    deceleration: inf

switch:
  - platform: template
    name: "pH Up"
    id: doser_ph_up_switch
    optimistic: true
    turn_on_action:
            - logger.log: "Setting $(name) stepper position to 0"
            - stepper.report_position:
                id: doser_ph_up
                position: 0
            - logger.log: "Setting $(name) stepper position to 2000"
            - stepper.set_target: 
                id: doser_ph_up
                target: 2000
            - logger.log: "Setting $(name) stepper speed to 2500"
            - stepper.set_speed:
                id: doser_ph_up
                speed: 2500 steps/s
            - wait_until: # Wait until endstop reached
                lambda: 'return (id(doser_ph_up).current_position == 2000 );'
            - logger.log: "Stepper $(name) reached its target 2000"
            - switch.turn_off: doser_ph_up_switch

Do you have a wiring diagram of this? The Docs are pretty riddled. What PSU did you use?