Help setting up slider to send uart comands

Hello there.

I need to create a slider from 6 to 32 that each value that i select in the slider, i can send to uart as like this: - uart.write: “:0110001400010203E8ED\r\n”

The code is to create a slider that my wife can change the charging power. I have a button but prefer a slider, but i am having a hard time to learn how to change it. I have no coding skills.

Currently, i have like this (sorry but this way was the best that i could do it, at that time):

button:

  - platform: template
    name: "Pausa"
    on_press:
      - uart.write: ":0110001400010203E8ED\r\n"

  - platform: template
    name: "6A"
    on_press:
      - uart.write: ":01100014000102008652\r\n"

  - platform: template
    name: "8A"
    on_press:
      - uart.write: ":0110001400010200A731\r\n"

  - platform: template
    name: "10A"
    on_press:
      - uart.write: ":0110001400010200C810\r\n"

  - platform: template
    name: "12A"
    on_press:
      - uart.write: ":0110001400010200EAEE\r\n"

  - platform: template
    name: "14A"
    on_press:
      - uart.write: ":01100014000102010BCC\r\n"

  - platform: template
    name: "18A"
    on_press:
      - uart.write: ":01100014000102014D8A\r\n"

  - platform: template
    name: "20A"
    on_press:
      - uart.write: ":01100014000102019047\r\n"

Thank you for all the help!

Try with template number, it’s slider as default.

number:
  - platform: template
    name: "Template number"
    optimistic: true
    min_value: 6
    max_value: 32
    step: 1
    on_value:
      then:
        - lambda: |-
            if (x == 6) {
              id(my_uart).write_str(":01100014000102008652\r\n");
            } else if (x == 7) {
              id(my_uart).write_str(":0110001400010200A731\r\n");
            } else if
                # and so on...

ps. you have to give id to your uart component.