Unable to run python commands on the homeassistant container

This post was flagged by the community and is temporarily hidden.

I’m not sure what you’re trying to do, if you start our container, it’s ha core, it will just work.

I’m glad it’ll just work. In fact, it has been solid for me.

However, I still need to run commands. An example would be the iRobot integration that needs:

docker exec -it CONTAINER_NAME_OR_ID python -c 'import roombapy.entry_points; roombapy.entry_points.password()' ROOMBA_IP

To manually add the device. Any ideas?

while python is not there, python3 is. try that. Also ,you can run that command (to get your credentials) from ANY machine, you’re just feeding credentials into the conf, you dont NEED that file to stay on HA.

Confirming that using python3 works.

$ docker exec homeassistant python3 -m homeassistant --script check_config --config /config
Testing configuration at /config

Getting an odd response from one of the commands though:

$ docker exec homeassistant python3 -m homeassistant --script check_config --files
Testing configuration at /config/.homeassistant
yaml files (used / not used)
Failed config
  General Errors:
    - File configuration.yaml not found.

Successful config (partial)

it tells you why, you don’t have a configuration.yaml

Oh, but I do.

$ cd / && sudo find -iname configuration.yaml

What I don’t seem to have is a


file. The way Home Assistant manages its files in the container is so hard to find details on, I do wish they’d make their documention clearer.

It’s not container or docker related. Homeassistant (when a config folder is NOT defined by --config), expects configuration.yaml to reside under a .homeassistant folder inside the user’s home folder. It has the same behavior when installed on bare metal.

In your first command, you’re defining the location as --config /config so it works fine. In your second command, you’re not defining it so it is looking in the default folder which is not the right location.

Your second command needs to be docker exec homeassistant python3 -m homeassistant --script check_config --config /config --files

1 Like

that is pretty weird and tbh i’ve never used that checker before, but i dont even have a .homeassistant folder, so i suspect mine would fail with the same error…

in the one that errors, can you put --config /config in there too?

The .homeassistant folder was created by the homeassistant container installation.

Not going to put the config.yaml file there yet, will go poke the HA forums first.

No, not by the container. It was created by the incorrect command you ran without specifying the config folder location.

You really should re-read my comment above.

PS. This is exactly why we don’t support running manual commands inside the containers

I understand the reluctance to run manual commands in the containers, but with HA in particular it is often needed.

I see that the two commands are different.

The full check (docker exec homeassistant python3 -m homeassistant --script check_config --config /config) looks like it checks the entire /config folder for any issues.

The listing all loaded files command (docker exec homeassistant python3 -m homeassistant --script check_config --files) seems to scan the entire installation to confirm what’s good.

Either way, now I can run commands if I need to. I shall continue my Home Assistant journey of attempting to work out where all the configuration values are stored so I can pull them all into yaml files and store them on a repository somewhere.

No, it doesn’t. --config /config means you’re telling homeassistant to use /config as the config folder location when you run it, which is correct because that’s where the config folder is located with our image.

No, it doesn’t. Here, you’re not telling homeassistant where the config folder is located (because you did not pass the argument --config blah, so ha assumes the config is at the default location, which is /{user's home folder}/.homeassistant, which equates to /config/.homeassistant, which is not the right location for our image. It doesn’t see a folder there, so it creates it, and then gives you an error about missing config file inside of it.

I honestly don’t know how to make it any clearer.

That’s clear now - thank you for the detailed explanation, and thank you again for your patience!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.