Problem with value passing to command line

Continuing the discussion from Pass value to command line:

Can anyone help me to make this work? I am using a shell command component to create irsend commands. They work great if I do not attempt to use a template variable. From my configuration.yaml file:

input_boolean:
sony_amp:
name: Sony Amp Power
initial: off
icon: mdi:power

input_slider:
ampvol:
name: Sony Amp Volume
initial: 24
min: 0
max: 32
step: 2

automation:
alias: Sony Amp Power Off
trigger:
platform: state
entity_id: input_boolean.sony_amp
to: ‘off’
action:
service: shell_command.set_power_on_off

automation 2:
alias: Sony Amp Power On
trigger:
platform: state
entity_id: input_boolean.sony_amp
to: ‘on’
action:
service: shell_command.set_power_on_off

automation 3:
alias: Sony Amp Volume Set
trigger:
platform: state
entity_id: input_slider.ampvol
action:
service: shell_command.set_vol_amp

shell_command:
set_power_on_off: ‘irsend SEND_ONCE SONYAMP KEY_POWER’
#set_vol_amp: ‘irsend SEND_ONCE SONYAMP KEY_VOLUMEUP’
#set_vol_amp: ‘irsend -#{{states.input_slider.ampvol.state}} SEND_ONCE SONYAMP KEY_VOLUMEUP’
set_vol_amp: ‘irsend -#{{20}} SEND_ONCE SONYAMP KEY_VOLUMEUP’

The only shell command that does not work here is the one where I am trying to send the input slider state value. All the others work just fine.

Thanks for any suggestions

Did you try to remove the single quotes around your command?

Because I have the exact same setup and it works fine for me. Furthermore do you need that input slider? Do you actually use it on the GUI or something? Because I had one for my volume earlier but you can just pass a variable to the shell command if you call the service to run it.

Cheers

Edit:
Nvm I just saw that you use the slider to call the shell command. Maybe you should change that to only call on value changed anyways :slight_smile:

Recently the input_sliders converted from being floats to ints but that broke a few of my irsend commands because they became, for example:
irsend -#20.0 SEND_ONCE ... blah blah

so the trick is to convert them to ints like this:

set_vol_amp: 'irsend -#{{states.input_slider.ampvol.state | int}} SEND_ONCE SONYAMP KEY_VOLUMEUP'

Let me know if it works.

1 Like

Super excellent! That works. Thank you very much.

Is there a way we can update the documentation so everyone else gets the benefit?

Happy to help out if there is something I can do.

Once again thank you …now to scripting…