Getting the value from a lovelace slider card then sending to a serial port?

How would I get the value from a slider card in HA and send this value to my AV amp?

It would be much better than sending individual volume up/down commands. I think it requires some sort of template as well but I’m also rubbish at that, so any help appreciated!

Has anyone attempted this before?

I maybe should explain better.

I already use this in switches.yaml

- platform: command_line
  switches:
    arcam_volume:
      command_on: 'echo -e "\x50\x43\x5f\x2f\x31\x31\x0d" > /dev/ttyUSB0'
      command_off: 'echo -e "\x50\x43\x5f\x2f\x31\x30\x0d" > /dev/ttyUSB0'

Can I use a template, linked to a slider that will send a volume change value to the serial port?

Maybe as a REST command etc. but my templating skills are weak. It’s the 7th data bit with the volume info.