ESPHome servo control - multiple servos?

I've fought Ubiquiti/ESP32 connectivity issues all day - finally found the 8 digit wifi password fix - and have my first servo responding to a slider thanks to this vid:

I'd like to do two servos, the YT vid does, but does not show full YAML in vid or his Git link. I have two sliders on the ESP32 page, but both control the first motor - even though I've specified second servo.

number:

  • platform: template
    id: servoSlider1
    name: $name 1
    icon: mdi:sync
    optimistic: true
    min_value: -100
    max_value: 100
    initial_value: 0
    step: 5
    on_value:
    then:
    - lambda: !lambda |-
    // Servo Write range is: -1.0 to 1.0, so divide by 100
    id(servo1).write(x / 100.0);

  • platform: template
    id: servoSlider2
    name: $name 2
    icon: mdi:sync
    optimistic: true
    min_value: -100
    max_value: 100
    initial_value: 0
    step: 5
    on_value:
    then:
    - lambda: !lambda |-
    // Servo Write range is: -1.0 to 1.0, so divide by 100
    id(servo1).write(x / 100.0);

servo:

  • id: servo1
    output: output1
    auto_detach_time: 5s # Optional - Default 0 (Always On)
  • id: servo2
    output: output2
    auto_detach_time: 5s # Optional - Default 0 (Always On)

output:

  • platform: ledc # For ESP8266 use: esp8266_pwm
    id: output1
    pin: 23
    frequency: 50 Hz # MUST BE 50Hz

  • platform: ledc # For ESP8266 use: esp8266_pwm
    id: output2
    pin: 22
    frequency: 50 Hz # MUST BE 50Hz

I'm wrong somewhere.

Hello mynameisplayer ,
Thanks for coming here and asking a question.
Would you be so kind as to adjusting the format of your code so that we can read it properly & check the YAML spacing, etc. Editing your original is the preferred way. It is very hard for us to tell what is what when the text formatter jumbles everything like that.
You can use the </> button like this... How to format your code in forum posts
OR... Here is an example of how to fix formatting from the site FAQ Page.
How to help us help you - or How to ask a good question.

As @Sir_Goodenough says makes life easier if you format your YAML so we can read, but the last line of your servoSlider2 template number has the wrong target servo.

This line in the second number block

id(servo1).write(x / 100.0);

Controls which is the target servo, it should be

- platform: template
  id: servoSlider2
  name: $name 2
  icon: mdi:sync
  optimistic: true
  min_value: -100
  max_value: 100
  initial_value: 0
  step: 5
  on_value:
    then:
       - lambda: !lambda |-
         // Servo Write range is: -1.0 to 1.0, so divide by 100
         id(servo2).write(x / 100.0);

Thanks. I just removed the lambda lines before I saw this. Two servos working.

Other than fixing your alignment and syntax spacing it looks fine to me and I only lowered some auto_detach_times from 5s to 2s because 5 seemed like quite a long delay for most scenarios but, idk if you do need 5 then by all means change it back.

So, you've flashed this code onto your esp32 and you cant either servo to work??

You need to provide details like links and/or pictures of your servo type/brand, a picture of your wiring, you need to provide detailes about how you're powering everything + the new servos and whether those servos will even work on the low 3.3v from a gpio or whether it requires some odd voltage like 7v - 9v as so many other servos frequently do.....

So....... We need more details here dude, we're not psychics that will just read your mind to find this stuff out. You need to provide all this really important details and not just this post but for every post you make, you need to provide these types of details too.

number:
  - platform: template
    id: servoSlider1
    name: $name 1
    icon: mdi:sync
    optimistic: true
    min_value: -100
    max_value: 100
    initial_value: 0
    step: 5
    on_value:
    then:
        - lambda: !lambda |-
           // Servo Write range is: -1.0 to 1.0, so divide by 100
            id(servo1).write(x / 100.0);

  - platform: template
    id: servoSlider2
    name: $name 2
    icon: mdi:sync
    optimistic: true
    min_value: -100
    max_value: 100
    initial_value: 0
      step: 5
    on_value:
    then:
      - lambda: !lambda |-
           // Servo Write range is: -1.0 to 1.0, so divide by 100
          id(servo1).write(x / 100.0);

servo:
  id: servo1
  output: output1
  name: "Servo 1"
  auto_detach_time: 2s # Optional - Default 0 (Always On)

  id: servo2
  name: "Servo 2"
  output: output2
  auto_detach_time: 2s # Optional - Default 0 (Always On)

output:

  platform: ledc # For ESP8266 use: esp8266_pwm
  id: output1
  pin: 23
  frequency: 50 Hz # MUST BE 50Hz

  platform: ledc # For ESP8266 use: esp8266_pwm
  id: output2
  pin: 22
  frequency: 50 Hz # MUST BE 50Hz