“PermissionError: [Errno 13] Permission denied: ‘/home/homeassistant/.homeassistant/known_devices.yaml’
"
What does it means?
It sounds like a file permission error. Does that file exists? And if so what are the permissions on it? You can run ls -l
in the .homeassistant folder to get the permissions and the owner. I am assuming the homeassistant user does not own the file so you could try running sudo chown homeassistant known_devices.yaml
and see if that fixes the problem. If it doesn’t exist run touch known_devices.yaml
while logged in as homeassistant.
this is the result of ls -l command
pi@hassbian:/home/homeassistant/.homeassistant$ ls -l
totale 122056
-rwxr-xr-x 1 root root 4734 mar 24 14:25 6279886fde090b3038f267098bcca771a6efa946_en_-_google.mp3
-rwxr-xr-x 1 root root 6002 mar 24 14:23 audiocontrol.yaml
-rw-r–r-- 1 homeassistant homeassistant 13719 mar 29 17:30 automations.yaml
-rwxr-xr-x 1 root root 2134 mar 24 14:24 certificate.pem
-rw-r–r-- 1 homeassistant homeassistant 12978 mar 29 18:16 configuration.yaml
drwxr-xr-x 3 root root 4096 mar 27 20:52 custom_components
drwxr-xr-x 2 homeassistant homeassistant 4096 mar 24 13:11 deps
-rwxr-xr-x 1 root root 817 mar 28 23:29 device_tracker.yaml
-rw-r–r-- 1 homeassistant homeassistant 3401 mar 24 14:24 entity_registry.yaml
-rwxr-xr-x 1 root root 216 mar 24 14:24 feedreader.pickle
-rwxr-xr-x 1 root root 297 mar 24 15:34 gitupdate.sh
-rwxr-xr-x 1 root root 54 mar 24 14:24 gpmpd.conf
-rw-r–r-- 1 homeassistant homeassistant 8835 mar 29 12:45 groups.yaml
-rw-r–r-- 1 homeassistant homeassistant 3430 mar 29 18:17 home-assistant.log
-rw-r–r-- 1 homeassistant homeassistant 124796928 mar 29 18:56 home-assistant_v2.db
-rwxr-xr-x 1 root root 5492 mar 24 20:59 known_devices.yaml
-rwxr-xr-x 1 root root 3792 mar 24 14:24 mp_general.yaml
drwxr-xr-x 2 root root 4096 mar 24 14:24 panels
-rwxr-xr-x 1 root root 3272 mar 24 14:24 privkey.pem
-rw-r–r-- 1 root root 3605 mar 26 21:08 scenes.yaml
-rw-r–r-- 1 homeassistant homeassistant 11183 mar 29 15:06 scripts.yaml
-rw-r–r-- 1 homeassistant homeassistant 229 mar 27 19:48 secrets.yaml
-rwxr-xr-x 1 root root 10971 mar 29 12:38 sensors.yaml
-rwxr-xr-x 1 root root 10933 mar 27 22:01 switches.yaml
drwxr-xr-x 2 root root 4096 mar 24 14:24 themes
drwxr-xr-x 2 homeassistant homeassistant 4096 mar 24 14:24 tts
-rwxr–r-- 1 root root 2240 mar 24 23:46 update.sh
drwxr-xr-x 2 root root 4096 mar 27 20:51 www
-rwxr-xr-x 1 root root 161 mar 24 14:24 zones.yaml
pi@hassbian:/home/homeassistant/.homeassistant$
And now?
It looks like the file is owned by root. Run sudo chown homeassistant known_devices.yaml
and that should fix it.
Ok i did… but also noticed some .yaml files are owned by root… must i change also all .yaml files?
I would just to be safe. I am pretty sure all of the files inside of my .homeassistant folder are owned by the homeassistant user but I need to double check that. I know all of the yaml files should be.
Ok, for now i will change the owner to all .yaml files, then if you double check and let me know i will do what is right…
Just another question:
I use to edit .yaml files a text editor via sftp way and to connect to the .homeassistant folder i use root as user and the root password as password. Is this correct? And if could it be better to enter as homeassistant user, how to do this in an sftp connection?
I would edit the yaml files as the homeassistant user. That way you won’t change the permissions on the files on accident. I’m not sure how you’re connecting with sftp, but if you’re doing it through the command line I know you can specify the user by doing user@ip
. For example it would be homeassistant@your_hass_ip
. If it’s through a program you should be able to specify the username.
If i try to connect as homeassistan@myhasspi i am asked a password for that user i never set… which is the default password for the homeassistant user in a hassbian installation?
I don’t know. I believe I changed mine with sudo passwd homeassistant
. Also I checked my .homeassistant folder and I don’t have as many folders in there as you do but all of my files are owned by homeassistant. To make it easier you should be able to run sudo chown homeassistant ./*
in each directory in .homeassistant instead of for each file.
technically the the homeassistant user doesn’t need to own all of the files in that directory. it only at least needs write permissions on the files it will automatically update (log files, known_devices, entity_registry, etc). it needs at least read permissions on the rest.
I use notepad++to edit my yaml files as sudo and many of those files are owned by root and i don’t have any problems.
Hi, I had exactly the same issue. No doubt you’re well sorted by now as it’s years since you posted this query, but just in case anyone else ends up at this post, I’ve found a solution that worked for me which might help.
I’m guessing that you followed the installation guide hsd something like this line:
sudo useradd -rm homeassistant -G dialout, gpio, i2c
I’m no expert, but what this appears to do is create a new user which is all it does. The guide I used then continued on with a line to create the user directory and assign it’s permissions to the new ‘homeassistant’ user, again something like this:
cd/srv
sudo mkdir homeassistant
sudo chown homeassistant:homeassistant homeassistant
What it apparently doesn’t do is give the new ‘homeassistant’ user a password, which for homeassistant itself isn’t an issue but for the likes of remote access it is as it needs to have one set. To fix this try:
sudo passwd homeassistant
which should allow you to set up the missing password.
This fixed it for me so hope it helps someone else out there…