ESPHome Read 2 Digit Value from Input Number, Break into Separate 1 Digit Numbers

Hello Everyone,

Like the title explains, I am trying to separate the 2 digit value from my inputnumber sensor and convert it to the individual numbers. Long story short, this is for a volume control for an old Stereo Receiver, which I am sending control commands to. Please see here for more info (Need Help using RS232 to control a receiver).

input_number:
  integramainvolume:
    name: Integra Main Volume
    initial: 10
    min: 10
    max: 64
    step: 1

Here is some Python code I created to do something similar, just curious how to bring it into the ESPHome format. volume_1st and volume_2nd are the individual numbers.

volume = int(input("What is the desired volume level?:  "))

volume_str = str(volume)

volume_1st = volume_str[0]
volume_2nd = volume_str[1]

print ("MVL - Master Volume Command")
print ("[0x21, 0x31, 0x4D, 0x56, 0x4C, 0x3"+ volume_1st +", 0x3"+ volume_2nd + ", 0x0D, 0x0A]")

This will then be sent with a uart.write command when the integramainvolume value changes. Here is what I have started with:

sensor:
  - platform: homeassistant
    name: "Integra Main Volume"
    entity_id: input_number.integramainvolume
    on_value:
      then:

#take volume number, 2 digits, break it down to 2 separate 1 digit numbers
#insert into below string
	- uart.write: 0x21, 0x31, 0x4D, 0x56, 0x4C, 0x3+ volume_1st +, 0x3+ volume_2nd + , 0x0D, 0x0A]

Thank You