Autostart issue

Hello all,

I’m trying to setup autostart following this https://home-assistant.io/getting-started/autostart-systemd/

My service file is:

homeassistant@Domo:~$ cat /etc/systemd/system/[email protected]                                                        
[Unit]
Description=Home Assistant
After=network.target

[Service]
Type=simple
User=homeassistant
#make sure the virtualenv python binary is used
Environment=VIRTUAL_ENV="/srv/homeassistant/homeassistant_venv"
Environment=PATH="$VIRTUAL_ENV/bin:$PATH"
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c "/home/homeassistant                                                                /.homeassistant"

[Install]
WantedBy=multi-user.target

but I get this error:
[email protected] - Home Assistant
Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2017-01-28 14:47:00 EST; 9min ago
Process: 2909 ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c home/homeassistant/.homeassistant (code=exited, status=203/EXEC)
Main PID: 2909 (code=exited, status=203/EXEC)

Jan 28 14:47:00 Domo systemd[1]: Started Home Assistant.
Jan 28 14:47:00 Domo systemd[1]: [email protected]: Main process exited, code=exited, status=203/EXEC
Jan 28 14:47:00 Domo systemd[1]: [email protected]: Unit entered failed state.
Jan 28 14:47:00 Domo systemd[1]: [email protected]: Failed with result 'exit-code'.

As I’m not familiar with linux, I don’t really know what to look for.
Could you point me to the right direction?

Thank you.

JP

Are the directories you’re using correct? How did you install HA?

I did the manual install with virtualenv (ubuntu server in hyper-v).
HA is in:
homeassistant) homeassistant@Domo:/srv/homeassistant$ ls
bin include lib pip-selfcheck.json

Well, given that /srv/homeassistant isn’t showing a homeassistant_venv directory, the problem is that you blindly copied the paths from the guide :wink:

I suspect if you drop /homeassistant_venv from both the Environment=VIRTUAL_ENV and ExecStart lines, you’ll be fine.

Yup, I followed the guide. I wasn’t expecting to change values that were not in “[… ]”. :wink:
Anyway, I was able to better understand how the service file is working. So after fixing the path I had to remove the double quote from ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c “/home/homeassistant” to make it works. Now, service starts automatically.
Thank you for your help.

I just found that when using autostart HA is failing detecting presence (but it works nice when started manually). Checking the log, I found this:
homeassistant@Domo:~$ cat /home/homeassistant/.homeassistant/home-assistant.log
17-01-28 18:10:02 homeassistant.components.device_tracker: Error setting up platform asuswrt
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/init.py”, line 158, in async_setup_platform
None, platform.get_scanner, hass, {DOMAIN: p_config})
File “/usr/lib/python3.5/asyncio/futures.py”, line 379, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 297, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 292, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py”, line 93, in get_scanner
scanner = AsusWrtDeviceScanner(config[DOMAIN])
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py”, line 134, in init
data = self.get_asuswrt_data()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py”, line 261, in get_asuswrt_data
result = self.ssh_connection()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/asuswrt.py”, line 180, in ssh_connection
ssh.login(self.host, self.username, **self.ssh_secret)
File “/home/homeassistant/.homeassistant/deps/pexpect/pxssh.py”, line 279, in login
spawn._spawn(self, cmd)
File “/home/homeassistant/.homeassistant/deps/pexpect/pty_spawn.py”, line 267, in _spawn
‘executable: %s.’ % self.command)
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: ssh.

I just tried nmap tracker and I get: FileNotFoundError: [Errno 2] No such file or directory: ‘arp’

Works fine in manual mode

When you say manual mode, are you starting hass as homeassistant user, or another user?

When you past in multi-line output from commands, log entries etc, it makes it much easier to read if you use the code block.

The error about arp suggests that you’ve got a PATH issue. Can you provide your configuration.yaml please (either in a code block, or up on something like pastebin, so that the formatting is preserved).

Also, what does the following command return:

/srv/homeassistant/bin/hass --script check_config

Hello,

first thank you for your time and help.

As it is a test setup (waiting to receive a PI3), I only have one user: homeassistant.
homeassistant@Domo:~$ whoami
homeassistant
homeassistant@Domo:~$ echo $PATH
/home/homeassistant/bin:/home/homeassistant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
homeassistant@Domo:~$ which ssh
/usr/bin/ssh
homeassistant@Domo:~$ which arp
/usr/sbin/arp
homeassistant@Domo:~$ /srv/homeassistant/bin/hass --script check_config
Testing configuration at /home/homeassistant/.homeassistant

my config, nothing fancy so far, I’m just testing features:
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: 45.4717
longitude: -73.6149
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 62
# metric for Metric, imperial for Imperial
unit_system: metric
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/Toronto

  customize:
    device_tracker.boba:
      icon: mdi:windows
    device_tracker.domo:
      icon: mdi:raspberrypi
    device_tracker.wii:
      icon: mdi:wii
    device_tracker.printer:
      icon: mdi:printer
  
  
# Show links to resources in log and frontend
#introduction:

# Enables the frontend
frontend:

http:
  # Uncomment this to add a password (recommended!)
  # api_password: PASSWORD
  # Uncomment this if you are using SSL or running in Docker etc
  # base_url: example.duckdns.org:8123

# Checks for available updates
updater:

# Discover some devices automatically
#discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time.
history:

# View all events in a logbook
logbook:

# Track the sun
sun:

# Weather Prediction
#sensor:
#  platform: yr

# Text to speech
tts:
  platform: google

light:
 - platform: lifx
   broadcast: 192.168.1.255

device_tracker:
# - platform: nmap_tracker
#   hosts: 192.168.1.2-255
 - platform: asuswrt
   host: 192.168.1.1
   username: admin
   password: ******

media_player:
  - platform: kodi
    host: yoda
    name: Kodi
    username: xbmc
    password: *****
  - platform: panasonic_viera
    host: 192.168.1.125

sensor:
  - platform: hydroquebec
    username: ******
    password: ******
    monitored_variables:
     - period_total_bill
     - period_length
     - period_total_days
     - period_mean_daily_bill
     - period_mean_daily_consumption
     - period_total_consumption
     - period_lower_price_consumption
     - period_higher_price_consumption
     - yesterday_total_consumption
     - yesterday_lower_price_consumption
     - yesterday_higher_price_consumption

group:
  HydroQuebec: 
    entities:
      - sensor.hydroquebec_period_total_bill
      - sensor.hydroquebec_period_length
      - sensor.hydroquebec_period_total_days
      - sensor.hydroquebec_period_mean_daily_bill
      - sensor.hydroquebec_period_mean_daily_consumption
      - sensor.hydroquebec_period_total_consumption
      - sensor.hydroquebec_period_lower_price_consumption
      - sensor.hydroquebec_period_higher_price_consumption
      - sensor.hydroquebec_yesterday_total_consumption
      - sensor.hydroquebec_yesterday_lower_price_consumption
      - sensor.hydroquebec_yesterday_higher_price_consumption
  Réseau:
    entities:
      - device_tracker.boba
      - device_tracker.christinepc
      - device_tracker.domo
      - device_tracker.jango
      - device_tracker.r2d2
      - device_tracker.yoda
      - device_tracker.wii
      - device_tracker.obi200
      - device_tracker.printer
  Famille:
    entities:
      - device_tracker.JP_Lumia
      - device_tracker.christine

  Services:
    view: yes
    name: Services
    entities:
      - group.HydroQuebec
I hope I got the block mode right this time.
  • pastebin

http://pastebin.com/A0f9QYxD

1 Like

I don’t see anything obvious in there that could be causing the issue.

However, I’m also seeing an error about ssh, what does which ssh show?

“which” locate a command by searching the $PATH. This confirms the command (ssh and arp in this case) are available through the $PATH environment variable. Unless HASS doesn’t use PATH, it should be able to use those commands. It could be a permission issue, but to me, everything is fine. So it is above my limited skills.

For the time being, disable the device tracker component since it looks like the asuswrt component is causing issues.

but…nmap tracker is failing too. When I tried it, I removed asuswrt to avoid any conflict.

What was the full error with nmap_tracker? You’ve only posted a single line of that one.

Also, which version number of HA are you running?

I’m running HA 0.37.
Running HASS manually, I find nmap to be very inaccurate (vs asuswrt) showing most hosts down when I know they are up.

Running HA service, I get this:

http://pastebin.com/Yn0ujhp8

Odd, I’ve no issues with nmap tracker. Of course, both the iPhone and recent Android versions (6.0 onwards) turn off the WiFi when they’re idle and not connected to power.

That error, combined with your other error, makes me wonder if your problem is with the install being broken, not the specific modules. Might be worth trying a fresh install.

Ok. I will wait to receive the Pi3, meanwhile I will run HA in manual mode and continue testing things.
Thank you for your time.