Command line sensor - error with templating

Hi,

I’m trying to create command line sensor which will be using some jinja2 variables. I want to edit it in future in easy way. Unfortunately I’m getting strange errors during command execution.

Here is my test sensor:

- platform: command_line
  name: Test sensor
  scan_interval: 300 # 5 min
  command: >
    {% set array = [ '0x086bd7fffef1b8da' ] %}
    
    {% set number = 12%}
    
    echo -n "Test sensor; " && echo -n "array: [{{ array }}]; " && echo -n "Number: {{ number }}"

When I hit “RELOAD COMMAND LINE ENTITIES” in Configuration tab two things happen:

  1. /bin/sh: {%: not found is written into Core logs
  2. Sensor state is refreshed but first {% %} block is ignored
    Selection_351

When I add {% %} (empty block) at the beginning of command then after reload message is still logged into Core logs but array variable is initialized.

It looks like only first {% block is ignored.

Do you have any ideas why this is happening?