Using a helper value in a shell command

Hello,

Not sure where this type of question belongs.

I created a helper, input_number.dim_bureau for an automation

id: '1641991246299'
alias: Dim x10 lights
description: ''
trigger:
  - platform: state
    entity_id: input_number.dim_bureau
    id: dim bureau
condition: []
action:
  - service: shell_command.x10_dim
mode: single

A change to the input_number will trigger the automation (OK) and I want to pass its value to a shell command. I have trouble using the input number value in the shell command. (The number is min=0, max 31) The command works ok if I hardcode a value.

  x10_dim:  'echo pl o12 xdim {{ states("input_number.dim_bureau") }} | nc 192.168.0.26 1099'
  
  # x10_dim: echo pl o12 xdim 15 | nc 192.168.0.26 1099  #This works 20220112  -#q0  q is not a valid parameter in the version of nc in HA
  
  # from documentation: set_ac_to_slider: 'irsend SEND_ONCE DELONGHI AC_{{ states("input_number.ac_temperature") }}_AUTO'   https://www.home-assistant.io/integrations/shell_command/

What am I doing wrong?

Many thanks

Pete

input_numbers are float:

x10_dim:  'echo pl o12 xdim {{ states("input_number.dim_bureau") | int(0) }} | nc 192.168.0.26 1099'

Thank you for that, unfortunatly it appears that it was not the only problem.
(I modified your suggestion from | int(0) to |int as per examples in the documentation.)

shell_command:
  turn_off_target: "ssh -i /config/ssh_keys/20201005_privatekey_linux.ppk -o StrictHostKeyChecking=no [email protected] sudo /sbin/shutdown -h now"

  x10_dim: 'echo pl o12 xdim {{ states("input_number.x10_dim") | int }} | nc 192.168.0.26 1099'
  
  #x10_dim: echo pl o12 xdim 15 | nc 192.168.0.26 1099  #This works 20220112  -#q0  q is not a valid parameter in the version of nc in HA

Further suggestions will be appreciated!

What does that output in the Template developer tool?

Thanks for that question, which made me discover what templates are for. :grinning_face_with_smiling_eyes:

The result in the template changes with the position of the slider and gives the correct output.
I suspect the problem is with the delimiters ’ and/or " with which I am not too familiar. (Debian 11). I have tried with and without ’ at the beginning and end. No luck
Thank you for your help