Proportional Stepper Motor Control (Float to Int)

Hello all,

New HA user here, running Hass.io (4.15) on Oracle VM Virtual Box. If any experienced users of ESPHome/yaml could please advice, I would be greatly appreciative and esp.ecially grateful!

My objective is have some sensor value mapped proportionally (linearly) to a stepper motor, controlling it’s variable position when the sensor value exceeds a fixed threshold value.

Below is the config which was successful for a simple ‘go to absolute target’ type function, but produces an error message in it’s current form (Can’t use floats for stepper.set_target). The sensor T-values are floats, therefore the mapped step position values (0 -> 50) are also floats and of course, steppers need ints!

The crux: could anyone please advise how to round down or constrain those mapped step positions to ints, or, if there’s another way to track sensor value accurately - I’m open to all suggestions.

I’ve omitted basic config blocks.

i2c:
  sda: 4
  scl: 5
  scan: True
  id: bus_a

sensor:
  - platform: bme280
    temperature:
      name: "BME280 Temperature"
      filters: 
        - calibrate_linear:                // Linearly mapping a sensor range to the range of step positions  
           - 22 -> 32                         // An arbitrary 10 degree range above my sensor threshold to act
           - 0 -> 50                           // The range of step positions (from closed to fully open)

      on_value_range:                  // Automation code
        - above: 22.0                     //  Threshold above which to track position
          then:
            - stepper.set_target:      
               id: a1_stepper
               target: calibrate_linear            // The mapped variable
           
        - below: 22.0
          then:
            - stepper.set_target:
               id: a1_stepper
               target: 0                                  // Closing the valve when T < threshold
               
      oversampling: 16x      
    pressure:
      name: "BME280 Pressure"
    humidity:
      name: "BME280 Humidity"
    address: 0x76
    update_interval: 2s  

stepper:
  - platform: a4988
    id: a1_stepper
    step_pin: 14
    dir_pin: 12
    max_speed: 20 steps/s

Thanks for any advice in advance!