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
73.53k stars 30.71k forks source link

2022.7 Causes error with IMAP sensor #74215

Closed DavidFW1960 closed 2 years ago

DavidFW1960 commented 2 years ago

The problem

Sensor not loading

What version of Home Assistant Core has the issue?

2022.7.0b0

What was the last working version of Home Assistant Core?

2022.6.x

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

IMAP

Link to integration documentation on our website

https://www.home-assistant.io/integrations/imap/

Diagnostics information

No response

Example YAML snippet

# Alarm Emails
  - platform: imap
    name: Alarm Triggers
    server: imap.gmail.com
    port: 993
    username: !secret outlooksyncuser
    password: !secret outlooksyncpass
    folder: inbox
    search: !secret alarmnotification

### Anything in the logs that might be useful for us?

```txt
2022-06-30 09:08:49 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up imap platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/imap/sensor.py", line 67, in async_setup_platform
    if not await sensor.connection():
  File "/usr/src/homeassistant/homeassistant/components/imap/sensor.py", line 126, in connection
    self._connection = IMAP4_SSL(self._server, self._port)
  File "/usr/local/lib/python3.10/site-packages/aioimaplib/aioimaplib.py", line 826, in __init__
    super().__init__(host, port, loop, timeout, None, ssl_context)
  File "/usr/local/lib/python3.10/site-packages/aioimaplib/aioimaplib.py", line 682, in __init__
    self.create_client(host, port, loop, conn_lost_cb, ssl_context)
  File "/usr/local/lib/python3.10/site-packages/aioimaplib/aioimaplib.py", line 832, in create_client
    super().create_client(host, port, loop, conn_lost_cb, ssl_context)
  File "/usr/local/lib/python3.10/site-packages/aioimaplib/aioimaplib.py", line 687, in create_client
    self.protocol = IMAP4ClientProtocol(local_loop, conn_lost_cb)
  File "/usr/local/lib/python3.10/site-packages/aioimaplib/aioimaplib.py", line 326, in __init__
    self._idle_event = asyncio.Event(loop=loop)
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 168, in __init__
    super().__init__(loop=loop)
  File "/usr/local/lib/python3.10/asyncio/mixins.py", line 17, in __init__
    raise TypeError(
TypeError: As of 3.10, the *loop* parameter was removed from Event() since it is no longer necessary


### Additional information

_No response_
probot-home-assistant[bot] commented 2 years ago

imap documentation imap source (message by IssueLinks)

balloob commented 2 years ago

This requires https://github.com/bamthomas/aioimaplib/pull/76 to be compatible with Python 3.10. It was opened 2 months ago and has not received any traction.

DavidFW1960 commented 2 years ago

This requires bamthomas/aioimaplib#76 to be compatible with Python 3.10. It was opened 2 months ago and has not received any traction.

Looks like a fix for this was merged earlier today

balloob commented 2 years ago

We need it to be released too https://pypi.org/project/aioimaplib/#history

thecode commented 2 years ago

1.0.0 Released: https://pypi.org/project/aioimaplib/1.0.0/

DavidFW1960 commented 2 years ago

Still errors

2022-07-06 11:27:01 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport
    await waiter
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 637, in _on_handshake_complete
    raise handshake_exc
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 682, in _process_write_backlog
    ssldata = self._sslpipe.do_handshake(
  File "/usr/local/lib/python3.10/asyncio/sslproto.py", line 116, in do_handshake
    self._sslobj = self._context.wrap_bio(
  File "/usr/local/lib/python3.10/ssl.py", line 527, in wrap_bio
    return self.sslobject_class._create(
  File "/usr/local/lib/python3.10/ssl.py", line 866, in _create
    sslobj = context._wrap_bio(
ssl.SSLError: Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:801)

No error when I disable imap sensor in config and restart

balloob commented 2 years ago

@DavidFW1960 that is something else. Please open a new issue.