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
71.13k stars 29.8k forks source link

Multiple components fail to load: aiohttp.TCPConnector(loop=hass.loop, ssl=ssl_context) - TypeError: __init__() got an unexpected keyword argument 'ssl' #13644

Closed guywhocodes closed 6 years ago

guywhocodes commented 6 years ago

Home Assistant release with the issue:

0.66.0 and 0.66.1

Last working Home Assistant release (if known):

0.65.6

Operating environment (Hass.io/Docker/Windows/etc.):

PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)" NAME="Raspbian GNU/Linux" VERSION_ID="9" VERSION="9 (stretch)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org/" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

pip, virtualenv

Component/platform:

Multiple, at least Philips Hue, yr and luftdaten

https://www.home-assistant.io/components/hue/ https://www.home-assistant.io/components/sensor.yr/ https://www.home-assistant.io/components/sensor.luftdaten/

Description of problem:

After upgrading to HA 0.66.0 and 0.66.1 (using pip), the above mentioned components fail with the error message provided in the respective section of this template. HA continues to start and works but the affected sensors are not working.

When I downgrade to 0.65.6 everything works as expected.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

These are the related configuration entires (I don't think they are relevant in this case).

# Weather prediction
sensor 1:
  - platform: yr

sensor 4:
  - platform: luftdaten
    sensorid: XXXX
    monitored_conditions:
      - P1
      - P2

# Discover some devices automatically
discovery:

Traceback (if applicable):

2018-04-01 21:30:42 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/hue/__init__.py", line 90, in async_bridge_discovered
    'phue-{}.conf'.format(discovery_info['serial']))
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/hue/__init__.py", line 147, in async_setup_bridge
    await bridge.async_setup()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/hue/__init__.py", line 184, in async_setup
    websession=aiohttp_client.async_get_clientsession(self.hass)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 38, in async_get_clientsession
    hass.data[key] = async_create_clientsession(hass, verify_ssl)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 55, in async_create_clientsession
    connector = _async_get_connector(hass, verify_ssl)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 164, in _async_get_connector
    connector = aiohttp.TCPConnector(loop=hass.loop, ssl=ssl_context)
TypeError: __init__() got an unexpected keyword argument 'ssl'

I have only copied the hue error message, but the error messages for the other components are identical.

Thanks a lot for your time and effort!

fabianpk commented 6 years ago

I had the same issue, I could fix it by changing aiohttp version to 3.0.9. Not sure what I did to change version, perhaps when I installed AppDaemon.

guywhocodes commented 6 years ago

Thanks for your reply, aiohttp 3.0.9 was already installed. It was upgraded from 3.0.6 by the normal pip upgrade procedure (pip install --upgrade homeassistant). I also tried using aiohttp 3.0.6 with 0.66.1, without success.

This is a list of the installed pip packages:

aiohttp (3.0.9)
aiohttp-cors (0.7.0)
aiohue (1.3.0)
astral (1.6)
async-timeout (2.0.1)
attrs (17.4.0)
boto3 (1.5.22)
botocore (1.8.36)
broadlink (0.5.1)
certifi (2018.1.18)
chardet (3.0.4)
colorlog (3.1.2)
distro (1.2.0)
docutils (0.14)
ecdsa (0.13)
enum-compat (0.0.2)
envs (1.2.4)
future (0.16.0)
fuzzywuzzy (0.16.0)
google-api-python-client (1.6.4)
gTTS-token (1.1.1)
home-assistant-frontend (20180401.0)
homeassistant (0.66.1)
httplib2 (0.10.3)
idna (2.6)
idna-ssl (1.0.1)
Jinja2 (2.10)
jmespath (0.9.3)
librouteros (1.0.5)
luftdaten (0.1.3)
MarkupSafe (1.0)
multidict (4.1.0)
mutagen (1.40.0)
netdisco (1.3)
netifaces (0.10.6)
oauth2client (4.0.0)
paho-mqtt (1.3.1)
phue (1.0)
pip (9.0.3)
pkg-resources (0.0.0)
pyasn1 (0.4.2)
pyasn1-modules (0.2.1)
pycrypto (2.6.1)
pycryptodome (3.4.11)
python-dateutil (2.6.1)
python-jose-cryptodome (1.3.2)
python-nmap (0.6.1)
pytz (2018.3)
PyYAML (3.12)
requests (2.18.4)
rsa (3.4.2)
s3transfer (0.1.12)
setuptools (33.1.1)
six (1.11.0)
SQLAlchemy (1.2.5)
typing (3.6.4)
ua-parser (0.7.3)
uritemplate (3.0.0)
urllib3 (1.22)
user-agents (1.1.0)
voluptuous (0.11.1)
warrant (0.6.1)
xmltodict (0.11.0)
yarl (1.1.1)
zeroconf (0.20.0)

This is a diff between HA 0.65.6 and HA 0.66.1:

1c1
< aiohttp (3.0.6)
---
> aiohttp (3.0.9)
3,5c3,5
< aiohue (0.3.0)
< astral (1.5)
< async-timeout (2.0.0)
---
> aiohue (1.3.0)
> astral (1.6)
> async-timeout (2.0.1)
22,23c22,23
< home-assistant-frontend (20180310.0)
< homeassistant (0.65.6)
---
> home-assistant-frontend (20180401.0)
> homeassistant (0.66.1)
55c55
< SQLAlchemy (1.2.2)
---
> SQLAlchemy (1.2.5)
guywhocodes commented 6 years ago

I have build a new virtual environment and installed Home Assistant following the guide provided at https://www.home-assistant.io/docs/installation/virtualenv/ but the problem remains. For me this seems to be an Home Assistant issue.

2018-04-04 19:37:16 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform luftdaten
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 82, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/luftdaten.py", line 71, in async_setup_platform
    session = async_get_clientsession(hass)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 38, in async_get_clientsession
    hass.data[key] = async_create_clientsession(hass, verify_ssl)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 55, in async_create_clientsession
    connector = _async_get_connector(hass, verify_ssl)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 164, in _async_get_connector
    connector = aiohttp.TCPConnector(loop=hass.loop, ssl=ssl_context)
TypeError: __init__() got an unexpected keyword argument 'ssl'
2018-04-04 19:37:16 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform yr
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 82, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/yr.py", line 95, in async_setup_platform
    yield from weather.fetching_data()
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/yr.py", line 169, in fetching_data
    websession = async_get_clientsession(self.hass)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 38, in async_get_clientsession
    hass.data[key] = async_create_clientsession(hass, verify_ssl)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 55, in async_create_clientsession
    connector = _async_get_connector(hass, verify_ssl)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 164, in _async_get_connector
    connector = aiohttp.TCPConnector(loop=hass.loop, ssl=ssl_context)
TypeError: __init__() got an unexpected keyword argument 'ssl'
2018-04-04 19:37:16 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform luftdaten
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 82, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/luftdaten.py", line 71, in async_setup_platform
    session = async_get_clientsession(hass)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 38, in async_get_clientsession
    hass.data[key] = async_create_clientsession(hass, verify_ssl)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 55, in async_create_clientsession
    connector = _async_get_connector(hass, verify_ssl)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/aiohttp_client.py", line 164, in _async_get_connector
    connector = aiohttp.TCPConnector(loop=hass.loop, ssl=ssl_context)
TypeError: __init__() got an unexpected keyword argument 'ssl'
kirichkov commented 6 years ago

It looks like the offending line is https://github.com/home-assistant/home-assistant/blob/0081764ddc05f6146de45db091bd5202c3946499/homeassistant/helpers/aiohttp_client.py#L164

aiohttp doesn't accept a ssl argument. When I changed ssl to ssl_context it started working, i.e.:

connector = aiohttp.TCPConnector(loop=hass.loop, ssl_context=ssl_context)

I hope someone more knowledgable with AIOHTTP than me reviews this and fixes it.

guywhocodes commented 6 years ago

Thanks, I can confirm that change proposed by kirichkov is fixing the issue.

ksya commented 6 years ago

This indeed fixes the issue. Thanks.

joydashy commented 6 years ago

Same issue here, it's breaking Philips Hue on 0.66.1

balloob commented 6 years ago

You are somehow having an old version of aiohttp installed. The correct version is 3.0. Please remove all files under <config dir>/deps

As of 3.0, ssl has been deprecated and ssl_context is the correct keyword: http://aiohttp.readthedocs.io/en/stable/changes.html#deprecations-and-removals

kirichkov commented 6 years ago

I think this is a conflict between AppDaemon (version 3.0 installs aiohttp-2.3.10) and HASS, which requires version 3.0.

So I guess everyone who has that problem is running appdaemon and hass from the same virtual environment

MartinHjelmare commented 6 years ago

@balloob I think you made a typo there and inverted what is deprecated. It's ssl_context that is deprecated.

guywhocodes commented 6 years ago

So I guess everyone who has that problem is running appdaemon and hass from the same virtual environment

I do not have AppDaemon installed and I don't have aiohhttp 2.3.x installed in my virtual environment (but it was at some point). I have remove all files under /deps and I will see with the next release whether the issue still persists.

voxic commented 6 years ago

I can confirm that the issue started after installing Appdaemon in the same virtualenv as HASS.

Fixed by manually upgrading aiohttp inside of the virtualenv. pip3 install --upgrade aiohttp

Appdaemon seems to be running fine.

oskapt commented 6 years ago

Ran into this today during an upgrade of HA. I updated to Raspbian Stretch and then upgraded HA. Among other things, HA failed to automatically install pyatv==0.3.9, so I did so manually. This appears to have removed aiohttp-3.1.3 and installed aiohttp-2.3.10:

Installing collected packages: aiohttp, cffi, cryptography, pyatv
  Found existing installation: aiohttp 3.1.3
    Uninstalling aiohttp-3.1.3:
      Successfully uninstalled aiohttp-3.1.3
Successfully installed aiohttp-2.3.10 cffi-1.11.5 cryptography-2.2.2 pyatv-0.3.9

It was after this change that the error about ssl and ssl_context appeared. Manually upgrading aiohttp again resolved the issue.