Problem with Binary sensor PING

Hi,
Im having problem with setting up the binary ping sensor, get this error when loading it:

2017-05-10 14:29:01 INFO (MainThread) [homeassistant.loader] Loaded binary_sensor.ping from homeassistant.components.binary_sensor.ping
2017-05-10 14:29:01 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.ping
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/components/binary_sensor/ping.py", line 93, in update
    self.ping.update()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/components/binary_sensor/ping.py", line 142, in update
    self.data = self.ping()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/components/binary_sensor/ping.py", line 117, in ping
    self._ping_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
FileNotFoundError: [Errno 2] No such file or directory: 'ping'
    status = sp.call(ping_cmd, stdout=sp.DEVNULL)
FileNotFoundError: [Errno 2] No such file or directory: 'ping'

Running on OSX.

binary_sensor.YAML:

  - platform: ping
    host: 192.168.10.1

Any idea what can be wrong?

/Ola

We assume that ping is in PATH and the user who runs Home Assistant has access to the binary.

I am recently seeing lots of Tracebacks in my logs related to FileNotFoundError: [Errno 2] No such file or directory: 'ping' as well.

I’m running home-assistant 0.63.2 on a Mac Mini. Ping is on my machine. Its parent directory is in my PATH. I seem to be running hass as the same user that has access to the binary.

$ which ping
/sbin/ping

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

$ cat /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

$ whoami
broox

$ ps aux | grep hass
broox            2224   0.0  0.0  2441988    472 s000  R+    1:58PM   0:00.00 grep hass
broox             658   0.0  2.6  2735344 110888   ??  S     9:56AM  19:15.11 /usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python /usr/local/bin/hass

I’m running hass using the autostart script: hass --script macos install

Am I missing something?

1 Like

/sbin is missing from the ~/Library/LaunchAgents/org.homeassistant.plist file that the script installs.

1 Like

I’m just running into this very issue now. Is there a way to edit the plist file and have it not overwrite when running hass --script macos restart?

I am experiencing exactly this issue. Running on a Mac Mini and /sbin is also in my $PATH and I am running hass as this very user. Very strange indeed. Did you find a work-around for this? Thanks!

Maybe lose the 4 spaces at the beginning of each line?

nah, its not a YAML issue but rather an issue w/ finding the ‘ping’ binary.

device_tracker:
  - platform: ping
    hosts:
      hostone: 10.0.1.12

I figured out how to solve this but have no idea how to explain what @broox and I both experience w/ our $PATH variables.

After running the install script:

hass --script macos install

Unload the service:

launchctl unload Library/LaunchAgents/org.homeassistant.plist

Edit the ~/Library/LaunchAgents/org.homeassistant.plist file to include any missing paths (/sbin, /bin for examples) and then load the modified plist file:

launchctl load Library/LaunchAgents/org.homeassistant.plist
1 Like

I’ve been digging into this problem too.
What I can tell you is that the macos install script copies the plist from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/homeassistant/scripts/macos/launchd.plist into the launchd system.

The plist includes $PATH in its path statement, and it looks like it assumes that the users path will get included in the process path. My testing shows that this is not the case. Thus, the only items in the home assistant path are those items that are hard-coded into the plist.

You can resolve this, just as rynam0 has identified by modifying the plist. The only problem with this approach is that every time home assistant gets upgraded, or if you re-run the macOS install script, you’ll have to do it again.

I resolved this by replacing the launchctl plist in my update script with a copy that has /sbin in the path.

1 Like