Error running command line from sensor


I have a problem with running a command as a command line sensor. I have these lines in my config.yaml:

  - platform: command_line
    name: Flydata
    command: "python3 /usr/share/hassio/homeassistant/python_scripts/ {{ states('sensor.openskyflights') }}" 

The sensor triggers everytime the sensors.openskyflghts changes. Passing the flightnbr to the python scrpt.

When I run this command in the terminal it works great, but when the sensor tries to run it fails with the following error:

Logger: homeassistant.components.command_line
Source: components/command_line/
Integration: command_line (documentation, issues)
First occurred: 10:05:42 (60 occurrences)
Last logged: 11:04:42

  • Command failed: python3 /usr/share/hassio/homeassistant/python_scripts/ NAX523
  • Command failed: python3 /usr/share/hassio/homeassistant/python_scripts/ KLM29U
  • Command failed: python3 /usr/share/hassio/homeassistant/python_scripts/ LNOFY

Running the comman from terminal returns what you see in the enclosed picture

I appreciate if the help I can get.
I’m running hassio on docker on Ubuntu.

Well, for starters, the code that you pasted above appears to have an unmatched single quote at the end. Does that quote exist in the config file?

No, it doesn’t. I made an error when posting and marking the yaml code. Have corrected the post.

I finally solved this. Problem was referencing the correct directory in Ubuntu and privileges.

Having this sensor in the configuration.yaml

  - platform: command_line
    name: flydata
    command: "python3 /config/ {{ states('sensor.openskyflights') }}"
    scan_interval: 5  

It was alos necessary to move the scripts to the config directory. Having them in the python_scripts directory made them crash on some imports. That worked when place in the config directory.