home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.35k stars 30.28k forks source link

Error while setting up platform google_wifi #8724

Closed nodinosaur closed 7 years ago

nodinosaur commented 7 years ago

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.50.1

Python release (python3 --version): 3.4

Component/platform: component.sensor.google_wifi

Description of problem: I think the Docs for this component are not clear on how to set up. Docs suggest:

  - platform: google_wifi

Yet component is not shown in States

When searching further I found the original Pull Request Which shows some further info on how to configure the sensor:

  - platform: google_wifi
    name: 'Google Wifi'
    host: 'testwifi.here'
    monitored_conditions:
      - current_version
      - new_version
      - uptime
      - last_restart
      - local_ip
      - status

However, this is slightly misleading i.e.

Traceback (if applicable): Adding logger to my configuration.yaml

logger:
  default: warn
  logs:
    homeassistant.components.sensor.google_wifi: debug

The following logs are printed;

2017-07-30 15:40:02 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform google_wifi
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 60, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.4/socket.py", line 530, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 356, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.4/http/client.py", line 1090, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.4/http/client.py", line 1128, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.4/http/client.py", line 1086, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.4/http/client.py", line 924, in _send_output
    self.send(msg)
  File "/usr/lib/python3.4/http/client.py", line 859, in send
    self.connect()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 166, in connect
    conn = self._new_conn()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x6dd03fb0>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 438, in send
    timeout=timeout
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='testwifi.here', port=80): Max retries exceeded with url: /api/v1/status (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x6dd03fb0>: Failed to establish a new connection: [Errno -2] Name or service not known',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.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/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/google_wifi.py", line 84, in setup_platform
    api = GoogleWifiAPI(host)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/google_wifi.py", line 160, in __init__
    self.update()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 303, in wrapper
    result = method(*args, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/google_wifi.py", line 169, in update
    self._request, timeout=10)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/sessions.py", line 639, in send
    r = adapter.send(request, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/requests/adapters.py", line 502, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='testwifi.here', port=80): Max retries exceeded with url: /api/v1/status (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x6dd03fb0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
nodinosaur commented 7 years ago

Updating the sensor.yaml

 - platform: google_wifi
    #name: 'Google Wifi'
    host: XXX.XXX.XXX.XXX
    monitored_conditions:
      - current_version
      - new_version
      - uptime
      - last_restart
      - local_ip
      - status

Returns:

2017-07-30 15:51:47 ERROR (Thread-6) [homeassistant.components.sensor.google_wifi] Before request
2017-07-30 15:51:47 ERROR (Thread-6) [homeassistant.components.sensor.google_wifi] {'system': {'hardwareId': 'ARKHAM [redacted]', 'deviceId': '[redacted]', 'lan0Link': True, 'groupRole': 'none', 'countryCode': 'us', 'modelId': 'ACo3V', 'uptime': [redacted]}, 'software': {'updateNewVersion': '0.0.0.0', 'updateStatus': 'idle', 'updateProgress': 0.0, 'updateChannel': 'stable-channel', 'updateRequired': False, 'softwareVersion': '9460.40.5'}, 'wan': {'online': True, 'pppoeDetected': False, 'captivePortal': False, 'ethernetLink': False, 'ipAddress': True}}
2017-07-30 15:51:47 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform google_wifi
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.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/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/google_wifi.py", line 84, in setup_platform
    api = GoogleWifiAPI(host)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/google_wifi.py", line 160, in __init__
    self.update()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 303, in wrapper
    result = method(*args, **kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/google_wifi.py", line 172, in update
    self.data_format()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/sensor/google_wifi.py", line 201, in data_format
    self.data[ATTR_LOCAL_IP] = value['localIpAddress']
KeyError: 'localIpAddress'
fabaff commented 7 years ago

Yet component is not shown in States

That's because of the connection error.

However, this is slightly misleading i.e. Should host IP be wrapped in single quotes? Should name be wrapped in single quotes?

That's covered in the docs.

Can you please check if #8731 solves your issue?

fronzbot commented 7 years ago

@fabaff this issue is a duplicate of #8705 which i fixed with PR #8710 which was merged and set for the 0.50.2 milestone

balloob commented 7 years ago

Closing this as @fronzbot has fixed it.