Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wake on Lan - switch status not working #5930

Closed
cgtobi opened this issue Feb 12, 2017 · 4 comments
Closed

Wake on Lan - switch status not working #5930

cgtobi opened this issue Feb 12, 2017 · 4 comments

Comments

@cgtobi
Copy link
Contributor

cgtobi commented Feb 12, 2017

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
0.38.1

Python release (python3 --version):
Python 3.5.2

Component/platform:
Raspberry Pi 3 (with Ubuntu 16.04, virtualenv)

Description of problem:
Wake on lan works as expected, but the switch does not show the actual status of the device. When successfully woken the target host is not shown as 'on' even if its reachable via ping, nmap, ssh, etc. When triggered, it switches to 'on' for a second or two and than goes back to 'off'.

Expected:
The switch shows whether target host is 'online' or 'offline'.

Problem-relevant configuration.yaml entries and steps to reproduce:

switch:
  - platform: wake_on_lan
    name: "server"
    mac_address: "70-85-C2-AA-BB-FA"
    host: "192.168.1.30"

device_tracker:    
  - platform: nmap_tracker
    hosts: 192.168.1.1/24

Traceback (if applicable):

Additional info:

@rchiarelly
Copy link

Due to this bug I have been unable to use the web gui to trigger the turn_off activity. I have to call it via the remote

@vassilis-panos
Copy link

I confirm this. The switch does not show the status of the device.

@cgtobi
Copy link
Contributor Author

cgtobi commented Mar 3, 2017

This is still an issue with 0.39.1. Here is the discussion on the forum.

I wrote a little python script to ping the host the way HA does it but I only get what I expect, which doesn't really help in tracking down the root of the problem.

import platform
import subprocess as sp

DEFAULT_PING_TIMEOUT = 1
hosts = ('foo', '192.168.1.100', 'foo.local.')

for host in hosts:
    ping_cmd = 'ping -c 1 -W {} {}'.format(
                DEFAULT_PING_TIMEOUT, host)

    status = sp.getstatusoutput(ping_cmd)[0]
    print(host, status)

@cgtobi
Copy link
Contributor Author

cgtobi commented Mar 3, 2017

I made some tests and found that the virtual environment within the systemd service was missing a few paths.
So here is my fix. Edit your systemd service and add :/usr/bin to the line starting with Environment=PATH="$VIRTUAL_ENV/bin:.

e.g.

Environment=PATH="$VIRTUAL_ENV/bin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/sbin:/bin:$PATH"

Than simply sudo systemctl daemon-reload and restart home assistant or reboot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants