Service with shell_command doesn't work

Hi comrades.
Can you advice, please.
I have following definition in configurations.yaml (still testing):

shell_command:
  update_nar_mon: echo "{{ states.sensor['28_011913b19b3a_temperature'] }}" > /home/homeassistant/.homeassistant/temp.txt

the ultimate goal after successful writing into the file --> curl external server with counters information (on it’s update triggered from automation).

Above definition parsed successfully ( i can saw errors if there was an extra bracket or quotes mismatch - so it works somehow). However, when i am invoking this service from within developer_tools–>services, nothing really happens. File remains unchanged. No errors in log. File temp.txt has all necessary permissions.

what am i doing wrong?

Nothing in the “Developer tools > logs”?

finally i found the issue (thanks google and other practitioners):

The shell component can execute a command and take the output of a template as parameter for the command. When a template is used as a parameter, the command execution is more strict and you are not allowed to use pipes or redirection to file. Should you need to use more complex command lines with pipes and templates, you could add them to a shell script and call the script instead.

1 Like