[求助] 关于先锋s6风扇改esp32控制的求助

去年在水群的时候知道了先锋的s6风扇,看有大佬做了esp32控制的pcb并可以接入homeassistant,遂购入一台准备进行改造,没有用大佬的板子,而是自己画了一板。奈何这个风扇的摇头控制使用了步进电机,可以控制角度,虽通过esphome也成功驱动了步进电机的往复运转,但在关于角度的控制上,esphome似乎不太好实现。
后因天气热起来要使用,就暂停了折腾,一直搁置到现在,如今气温又升起来了,又该把它搞起来了。遂来论坛提问求助一下。
如制作改装主板的大佬看到,望不吝赐教。
风扇的参数

使用esphome的代码

api:
  encryption:
    key: "xxxxx“
  services:
    - service: control_stepper
      variables:
        target: int
      then:
        - stepper.report_position:
            id : stepper_vmc
            position: 0
        - stepper.set_target:
            id: stepper_vmc
            target: !lambda 'return target;'
        - logger.log:
            format: "The target value is %d"
            args : ['target']
ota:
  password: "xxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Dxh-S6-Pro Fallback Hotspot"
    password: "xdynCDsJMk2x"
substitutions:
  device_name: Dxh-S6-Pro
web_server:
  port: 80
captive_portal:
output:
  - platform: ledc
    pin: 23
    frequency: 1000Hz
    id: lt1    
fan:
  - platform: speed
    output: lt1
    name: "${device_name}"
    id: dc_fan   
    restore_mode: RESTORE_DEFAULT_ON
binary_sensor:
  - platform: gpio #四档固定风速切换
    pin:
      number: 34
      mode: INPUT
      inverted: True
    name: "speed"
    internal: True
    on_press:
      then:
        - fan.turn_on: dc_fan    
        - lambda: |-
            if (id(dc_fan).state) {
              if (id(dc_fan).speed == 35) {
                id(fan_med).turn_on();
              } else if (id(dc_fan).speed == 50){
                  id(fan_medhigh).turn_on();
                } else if (id(dc_fan).speed == 75){
                  id(fan_high).turn_on();
                } else {
                id(fan_low).turn_on();
              }
              }   
    on_click:
      min_length: 300ms
      max_length: 1000ms
      then:
        - fan.turn_off: dc_fan    
        - switch.turn_off: sp1
        - switch.turn_off: sp2
        - switch.turn_off: sp3
        - switch.turn_off: sp4
        - switch.turn_off: angleled1
        - switch.turn_off: angleled2
        - switch.turn_off: angleled3
        - switch.turn_off: angleled4
                                        
  - platform: gpio #摇头控制
    pin:
      number: 35
      mode: INPUT
      inverted: True
    name: "speed"
    internal: True
    on_press:
      if:
        condition:
           switch.is_off: angleled1
        then:
          - switch.turn_on: angleled1
        else: 
          - if:
              condition:
                switch.is_off: angleled2   
              then:     
                - switch.turn_on: angleled2
              else: 
                - if:
                    condition:
                      switch.is_off: angleled3   
                    then:     
                      - switch.turn_on: angleled3
                    else: 
                      - if:
                          condition:
                            switch.is_off: angleled4
                          then:     
                            - switch.turn_on: angleled4
sensor:
  - platform: duty_cycle #通过占空比的变动来切换风速指示灯
    pin: 23
    name: fan speed Sensor
    id: fan_speed
    update_interval: 1s
    internal: True    
    on_value:
      then:      
        - lambda: |-
            if (id(dc_fan).state) {
              if (id(dc_fan).speed < 36) {
                id(sp1).turn_on();
              } else if (id(dc_fan).speed < 51){
                  id(sp2).turn_on();
                } else if (id(dc_fan).speed < 76){
                  id(sp3).turn_on();
                } else {
                id(sp4).turn_on();
              }
              }    
switch: 
  - platform: template
    id: left
    name: "${device_name} Stepper position -250"
    turn_on_action:
      - stepper.set_target:
            id: stepper_vmc
            target: -250
  - platform: template
    id: right
    name: "${device_name} Stepper position 250"
    turn_on_action:
      - stepper.set_target:
            id: stepper_vmc
            target: 250

  - platform: template #模板开关,风速低
    id: fan_low
    turn_on_action:
      - fan.turn_on:
          id: dc_fan
          speed: 35
          
  - platform: template #模板开关,风速中
    id: fan_med
    turn_on_action:
      - fan.turn_on:
          id: dc_fan
          speed: 50
          
  - platform: template #模板开关,风速中高
    id: fan_medhigh
    turn_on_action:
      - fan.turn_on:
          id: dc_fan
          speed: 75
  - platform: template #模板开关,风速高
    id: fan_high
    turn_on_action:
      - fan.turn_on:
          id: dc_fan
          speed: 100              
## 以下为风速指示
  - platform: gpio  #Speed1
    pin: 12
    name: "sp1"
    id: sp1
    restore_mode: ALWAYS_OFF 
    internal: True    
    interlock: &interlock_group [sp1, sp2,sp3,sp4]
    interlock_wait_time: 100ms
  - platform: gpio  #Speed2
    pin: 13
    name: "sp2"   
    id: sp2
    restore_mode: ALWAYS_OFF 
    internal: True
    interlock: *interlock_group
    interlock_wait_time: 100ms
  - platform: gpio  #Speed3
    pin: 15
    restore_mode: ALWAYS_OFF 
    name: "sp3"
    id: sp3
    internal: True
    interlock: *interlock_group
    interlock_wait_time: 100ms   
  - platform: gpio  #Speed4
    pin: 2
    restore_mode: ALWAYS_OFF 
    name: "sp4"
    id: sp4
    internal: True
    interlock: *interlock_group
    interlock_wait_time: 100ms   
## 以下为角度指示    
  - platform: gpio #30度
    pin: 25
    id: angleled1
    name: "angleled1"  
    on_turn_on:
      - repeat:
          count: 999999  
          then:          
            - stepper.set_target:
                id: stepper_vmc
                target: -250
            - delay: 4s                
            - stepper.set_target:
                id: stepper_vmc
                target: 250
            - delay: 4s    
    restore_mode: ALWAYS_OFF
    interlock: &interlock_group2 [angleled1, angleled2,angleled3,angleled4]
    interlock_wait_time: 100ms    
#    internal: True     
  - platform: gpio  #60度
    pin: 26
    name: "angleled2"
    id: angleled2
    on_turn_on:    
      - repeat:
          count: 999999  
          then:          
            - stepper.set_target:
                id: stepper_vmc
                target: -500
            - delay: 7s                
            - stepper.set_target:
                id: stepper_vmc
                target: 500
            - delay: 7s     
    restore_mode: ALWAYS_OFF 
#    internal: True
    interlock: *interlock_group2    
  - platform: gpio #90度
    pin: 27
    id: angleled3
    on_turn_on:    
      - repeat:
          count: 999999  
          then:          
            - stepper.set_target:
                id: stepper_vmc
                target: -1000
            - delay: 10s                
            - stepper.set_target:
                id: stepper_vmc
                target: 1000
            - delay: 10s       
    restore_mode: ALWAYS_OFF
    name: "angleled3"
#    internal: True 
    interlock: *interlock_group2
  - platform: gpio  #180度
    pin: 14
    name: "angleled4"
    id: angleled4
    on_turn_on:    
      - repeat:
          count: 999999  
          then:          
            - stepper.set_target:
                id: stepper_vmc
                target: -1500
            - delay: 20s                
            - stepper.set_target:
                id: stepper_vmc
                target: 1500
            - delay: 20s     
    restore_mode: ALWAYS_OFF 
    interlock: *interlock_group2    
#    internal: True    
## 以下为定时指示 
  - platform: gpio  #定时显示4#led
    pin: 33
    restore_mode: ALWAYS_OFF 
    name: "led_4h"
    id: led_4h
    internal: True
  - platform: gpio  #定时显示3#led
    pin: 32
    name: "led_3h"
    id: led_3h
    restore_mode: ALWAYS_OFF 
    internal: True
  - platform: gpio  #定时显示2#led
    pin: 4
    name: "led_2h"
    id: led_2h
    restore_mode: ALWAYS_OFF 
    internal: True
  - platform: gpio   #定时显示1#led
    pin: 16
    name: "led_1h"
    id: led_1h
    restore_mode: ALWAYS_OFF 
    internal: True
    
stepper:
  - platform: uln2003
    id: stepper_vmc
    pin_a: 19
    pin_b: 18
    pin_c: 5
    pin_d: 17
    max_speed: 175 steps/s

    # Optional:
    acceleration: inf
    deceleration: inf 

步进的遥头算法麻烦。