Autostart problem on virtualenv raspberry pi

HI all,

So I had an issue where I couldn’t edit configuration.yaml from SSH. I therefore created a new group called hass and added my users pi and homeassistant.

However when I restarted homeassistant using the following…

sudo systemctl restart home-assistant@ultron

… I’m getting the following error on startup.

[email protected] - Home Assistant
Loaded: loaded (/lib/systemd/system/[email protected]; enabled)
Active: failed (Result: exit-code) since Tue 2017-04-25 18:17:24 +01; 6s ago
Process: 21897 ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c /home/homeassistant/.homeassistant (code=exited, status=203/EXEC)
Main PID: 21897 (code=exited, status=203/EXEC)

I’m actually really baffled here. Any ideas guys? I’m at my wit’s end and quite close to just wiping and starting again, this time using AIO installer since it seems to work for others so well.

Bit more info - the last thing I wanted to edit was adding an nmap process to scan my network every 10 minutes for known devices.

Weirdly my HA web service still works (???) but my iOS devices no longer show up. Config file is OK, and the error log from the developer info page isn’t updating at all.

I assume that the HA user has no longer write access to your config files.
It can read configuration.yaml, so web service works. But for ios an logfile it needs write access.
What if you login as HA user, can you write the files?

1 Like

I just logged into the HA user and opened the file ‘ios.conf’, and tried to save it with ‘:w’. The file is readonly… I assume this means you’re right!

A red bar comes up at the bottom saying:

E45: ‘readonly’ option is set (add ! to override)

But when I try to override, it says:

"ios.conf E212: Can’t open file for writing

How do I fix this? :confused: Is there a solution here that still allows me to continue to configure my files outside of the terminal? Kinda hate using vi so I’m ssh’ing to the files and using atom on linux.

Please login as pi and post the output of:
sudo ls -la /home/homeassistant
and
sudo ls -la /home/homeassistant/.homeassistant

Use nano, simply the best.

1 Like

First command:

total 52
drwxr-xr-x 7 homeassistant hass 4096 Apr 24 21:22 .
drwxr-xr-x 4 root root 4096 Apr 24 12:17 …
-rw------- 1 homeassistant homeassistant 2190 Apr 25 18:47 .bash_history
-rw-r–r-- 1 homeassistant homeassistant 220 Jan 15 00:14 .bash_logout
-rw-r–r-- 1 homeassistant homeassistant 3512 Apr 10 10:17 .bashrc
drwxr-xr-x 2 homeassistant homeassistant 4096 Apr 24 12:28 bin
drwx------ 3 homeassistant homeassistant 4096 Apr 24 12:32 .cache
drwxrwxr-x 4 homeassistant hass 4096 Apr 25 19:21 .homeassistant
drwxr-xr-x 2 homeassistant homeassistant 4096 Apr 24 12:28 include
drwxr-xr-x 4 homeassistant homeassistant 4096 Apr 24 12:28 lib
-rw-r–r-- 1 homeassistant homeassistant 675 Jan 15 00:14 .profile
-rw-r–r-- 1 homeassistant homeassistant 120 Apr 24 21:22 .ps4-wake.credentials.json
-rw-r–r-- 1 homeassistant homeassistant 69 Apr 24 12:28 pyvenv.cfg

Second command:

total 4980
drwxrwxr-x 4 homeassistant hass 4096 Apr 25 19:21 .
drwxr-xr-x 7 homeassistant hass 4096 Apr 24 21:22 …
-rw-r–r-- 1 homeassistant hass 85 Apr 25 09:08 bravia.conf
-rw-r–r-- 1 kintesh pi 2755 Apr 25 17:37 configuration.yaml
drwxr-xr-x 53 kintesh pi 4096 Apr 25 19:17 deps
-rw-r–r-- 1 kintesh pi 407 Apr 25 16:23 groups.yaml
-rw-r–r-- 1 homeassistant hass 6 Apr 25 18:27 .HA_VERSION
-rw-r–r-- 1 kintesh pi 16969 Apr 25 19:31 home-assistant.log
-rw-r–r-- 1 homeassistant hass 4998144 Apr 25 19:07 home-assistant_v2.db
-rw-r–r-- 1 kintesh pi 32768 Apr 25 19:12 home-assistant_v2.db-shm
-rw-r–r-- 1 kintesh pi 0 Apr 25 19:10 home-assistant_v2.db-wal
-rw-r–r-- 1 kintesh pi 1265 Apr 25 15:09 ios.conf
-rw-r–r-- 1 kintesh pi 0 Apr 25 16:11 known_devices.yaml
drwxr-xr-x 2 homeassistant hass 4096 Apr 24 12:54 tts
-rw-r–r-- 1 homeassistant hass 44 Apr 24 12:36 .uuid

edit: sorry, forgot to mention, the ‘pi’ username is actually ‘kintesh’ on here.

edit2: … and “hass” is the group I’ve added both “kintesh” and “homeassistant” to.

Try:
chown -R homeassistant:hass /home/homeassistant/.homeassistant
then all files are owned by homeassistant.
then try:
chmod -R ug+rw /home/homeassistant/.homeassistant
so users in group hass can edit them to.

First one didn’t work, then I realised I needed to run it as a sudo user.

I just restarted HA though and it still won’t work. I checked ls-la on…

/home/homeassistant:

total 52
drwxr-xr-x 7 homeassistant hass 4096 Apr 24 21:22 .
drwxr-xr-x 4 root root 4096 Apr 24 12:17 …
-rw------- 1 homeassistant homeassistant 2190 Apr 25 18:47 .bash_history
-rw-r–r-- 1 homeassistant homeassistant 220 Jan 15 00:14 .bash_logout
-rw-r–r-- 1 homeassistant homeassistant 3512 Apr 10 10:17 .bashrc
drwxr-xr-x 2 homeassistant homeassistant 4096 Apr 24 12:28 bin
drwx------ 3 homeassistant homeassistant 4096 Apr 24 12:32 .cache
drwxrwxr-x 4 homeassistant hass 4096 Apr 25 19:21 .homeassistant
drwxr-xr-x 2 homeassistant homeassistant 4096 Apr 24 12:28 include
drwxr-xr-x 4 homeassistant homeassistant 4096 Apr 24 12:28 lib
-rw-r–r-- 1 homeassistant homeassistant 675 Jan 15 00:14 .profile
-rw-r–r-- 1 homeassistant homeassistant 120 Apr 24 21:22 .ps4-wake.credentials.json
-rw-r–r-- 1 homeassistant homeassistant 69 Apr 24 12:28 pyvenv.cfg

… and /home/homeassistant/.homeassistant …

drwxrwxr-x 4 homeassistant hass 4096 Apr 25 19:21 .
drwxr-xr-x 7 homeassistant hass 4096 Apr 24 21:22 …
-rw-rw-r-- 1 homeassistant hass 85 Apr 25 09:08 bravia.conf
-rw-rw-r-- 1 homeassistant hass 2755 Apr 25 17:37 configuration.yaml
drwxrwxr-x 53 homeassistant hass 4096 Apr 25 19:17 deps
-rw-rw-r-- 1 homeassistant hass 407 Apr 25 16:23 groups.yaml
-rw-rw-r-- 1 homeassistant hass 6 Apr 25 18:27 .HA_VERSION
-rw-rw-r-- 1 homeassistant hass 22086 Apr 25 19:49 home-assistant.log
-rw-rw-r-- 1 homeassistant hass 4998144 Apr 25 19:07 home-assistant_v2.db
-rw-rw-r-- 1 homeassistant hass 32768 Apr 25 19:12 home-assistant_v2.db-shm
-rw-rw-r-- 1 homeassistant hass 0 Apr 25 19:10 home-assistant_v2.db-wal
-rw-rw-r-- 1 homeassistant hass 1265 Apr 25 15:09 ios.conf
-rw-rw-r-- 1 homeassistant hass 0 Apr 25 16:11 known_devices.yaml
drwxrwxr-x 2 homeassistant hass 4096 Apr 24 12:54 tts
-rw-rw-r-- 1 homeassistant hass 44 Apr 24 12:36 .uuid

Also just double checked and I now have write access to ios.config under homeassistant, so that bit has worked.

Hmm, let me shutdown and restart my pi.

Edit: Yeah, still not working. :frowning:

[email protected] - Home Assistant
Loaded: loaded (/lib/systemd/system/[email protected]; enabled)
Active: failed (Result: exit-code) since Tue 2017-04-25 19:54:10 +01; 2min 23s ago
Process: 688 ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c /home/homeassistant/.homeassistant (code=exited, status=203/EXEC)
Main PID: 688 (code=exited, status=203/EXEC)

Apr 25 19:54:10 ultron systemd[1]: Started Home Assistant.
Apr 25 19:54:10 ultron systemd[1]: [email protected]: main process exited, code=exited, status=203/EXEC
Apr 25 19:54:10 ultron systemd[1]: Unit [email protected] entered failed state.

On the bright side, my error log is up and running so it looks like homeassistant has write access again for sure!

Hmm, I’m not sure whether posting my ip like this is an issue, but I guess all the forums and websites I’m registered at already have it.

The following errors have been logged this session:

17-04-25 19:54:17 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=36 from 2017-04-25 16:39:22.255840)
17-04-25 19:55:29 ERROR (Thread-6) [homeassistant.components.ios] Reading config file /home/homeassistant/.homeassistant/ios.conf failed: Extra data: line 1 column 1264 - line 2 column 1 (char 1263 - 1265)
17-04-25 19:55:29 ERROR (MainThread) [homeassistant.components.notify] Error setting up platform ios
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/notify/init.py”, line 101, in async_setup_platform
None, platform.get_service, hass, p_config, discovery_info)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/notify/ios.py”, line 48, in get_service
if not ios.devices_with_push():
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/ios.py”, line 210, in devices_with_push
for device_name, device in CONFIG_FILE[ATTR_DEVICES].items():
TypeError: ‘NoneType’ object is not subscriptable
17-04-25 19:55:29 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform ios
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 155, in _async_setup_platform
entity_platform.schedule_add_entities, discovery_info
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/ios.py”, line 26, in setup_platform
for device_name, device in ios.devices().items():
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/ios.py”, line 228, in devices
return CONFIG_FILE[ATTR_DEVICES]
TypeError: ‘NoneType’ object is not subscriptable
17-04-25 19:55:51 WARNING (Thread-3) [netdisco.ssdp] Found malformed XML at http://192.168.0.19:49153/description2.xml:
17-04-25 19:55:51 WARNING (Thread-3) [netdisco.ssdp] Error fetching description at http://192.168.0.15:52416/devdesc.xml
17-04-25 19:55:51 WARNING (Thread-3) [netdisco.ssdp] Found malformed XML at http://192.168.0.18:49153/description1.xml:
17-04-25 19:55:51 WARNING (Thread-3) [netdisco.ssdp] Found malformed XML at http://192.168.0.19:49153/description5.xml:
17-04-25 19:55:51 WARNING (Thread-3) [netdisco.ssdp] Found malformed XML at http://192.168.0.19:49153/description1.xml:
17-04-25 19:55:51 WARNING (Thread-3) [netdisco.ssdp] Found malformed XML at http://192.168.0.18:49153/description0.xml:
17-04-25 19:55:52 WARNING (Thread-3) [netdisco.ssdp] Found malformed XML at http://192.168.0.19:49153/description3.xml:
17-04-25 19:56:00 ERROR (Thread-1) [homeassistant.components.switch.command_line] Command failed: nmap -p 9295 192.168.0.14 | grep -w -Eo “open”
17-04-25 19:56:31 ERROR (Thread-3) [homeassistant.components.switch.command_line] Command failed: nmap -p 9295 192.168.0.14 | grep -w -Eo “open”
17-04-25 19:57:02 ERROR (Thread-5) [homeassistant.components.switch.command_line] Command failed: nmap -p 9295 192.168.0.14 | grep -w -Eo “open”
17-04-25 19:57:33 ERROR (Thread-7) [homeassistant.components.switch.command_line] Command failed: nmap -p 9295 192.168.0.14 | grep -w -Eo “open”
17-04-25 19:58:04 ERROR (Thread-3) [homeassistant.components.switch.command_line] Command failed: nmap -p 9295 192.168.0.14 | grep -w -Eo “open”
17-04-25 19:58:35 ERROR (Thread-6) [homeassistant.components.switch.command_line] Command failed: nmap -p 9295 192.168.0.14 | grep -w -Eo “open”
17-04-25 19:59:06 ERROR (Thread-5) [homeassistant.components.switch.command_line] Command failed: nmap -p 9295 192.168.0.14 | grep -w -Eo “open”

Don’t know what all those errors mean. Maybe you switch all permissions back to the beginning. User an group should be homeassistant, so try:
sudo chown -R homeassistant:homeassistant /home/homeassistant

Hmm, that didn’t work.

I have a feeling I’ve messed up somewhere with:

  1. my iOS config file (no idea how to refresh it)
  2. I can’t get nmap to scan correctly (it should be scanning every x seconds or something for new devices)

if I can get both of those to work I think most of these errors will disappear and it might mean a clean restart.

Worth a shot, I’ll keep digging.

Thank you very much for your help!

Just rename the ios.conf to ios.conf.bak and give it a try.
I think it get’s created when you login from your iphone.

No such luck I’m afraid.

I think I might just reflash and install using AIO installer.

Something must have gone wrong while trying all this out. I’d like to at least mod my pi’s name - hopefully AIO installer allows that!