Cannot get a commandline sensor to work

I try to get a commandline sensor to work
This is the yaml:

- platform: command_line
  name: gateway_woonkamer_temperatuur
  command: '/usr/bin/python3 /home/homeassistant/python_scripts/'
  scan_interval: 60
  unit_of_measurement: '°C'

The content of

x = 12.3

In the logbook I get the message:

Logger: homeassistant.components.command_line
Source: components/command_line/
Integration: command_line (documentation, issues)
First occurred: 23:46:03 (3 occurrences)
Last logged: 23:48:03

Command failed: /usr/bin/python3 /home/homeassistant/python_scripts/

When I run in a terminal i get 12.3 as output.

What am I doing wrong?

How are you running HA? HA OS, Supervised install, docker, venv etc? The correct path to your script will vary depending on the answer.
If running in a venv, the path is likely


For the other cases


Also, the script should be inside the config folder reachable by HA, so place it in

You missed the /.homeassistant/

Sorry, of course I should have mentioned that: HA is running in Docker with Docker Compose.
The config folder is “/home/homeassistant”. There are also the yaml-files and the db-file.

You set me on the right track.
With docker the standard folders like /usr/bin/ are not accesible.
I give myself a shell in the homeassistant docker with:
docker exec -it homeassistant /bin/bash
I then figured out that this shell starts in de config-folder of homeassistant
So the comandline should be:
python3 python_scripts/
And that worked fine!!

1 Like