Hello HA community. I’m new to HA and am having trouble calling a shell script from a button WITH a variable. It works fine without the variable. I’ve tried various permutations of with and without single and double quotes. I have also tried to call the shell command directly from the button and it display same pattern as above (works without a variable, but not with).
What am I doing wrong or missing?
My button is configured as:
type: custom:button-card
name: Shade Down
tap_action:
action: call-service
service: script.send_to_somfy
service_data:
somfy_cmd: 0109D
My script is configured as:
send_to_somfy:
sequence:
- service: shell_command.send_to_somfy
target:
entity_id: shell_command.send_to_somfy
data_template:
somfy_command: "{{ somfy_cmd }}"
- service: system_log.write
data:
message: "{{ somfy_cmd }}" # <---- This gets written correctly to the log
level: warning
My configuration.yaml has this shell_command:
shell_command:
send_to_somfy: echo {{ somfy_command }} >> /dev/ttyS0 # <---- This DOESN'T work
shade_mancave_up: echo "0109U" >> /dev/ttyS0 # <---- This works!!
shade_mancave_up2: echo 0109U >> /dev/ttyS0 # <---- This works!!