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.55k stars 30.35k forks source link

2022.7.x causes issue with IMAP sensor #74487

Closed DavidFW1960 closed 2 years ago

DavidFW1960 commented 2 years ago

The problem

Log errors and sensor not created

What version of Home Assistant Core has the issue?

2022.7.0b5

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?

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

Additional information

No response

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

imap documentation imap source (message by IssueLinks)

frenck commented 2 years ago

This seems to be a problem in the dependency. I've created an issue upstream:

https://github.com/bamthomas/aioimaplib/issues/78

scxs535 commented 2 years ago

@thecode could you please check this? Thanks

frenck commented 2 years ago

I'm not sure why you ping/pull people into this issue @scxs535. Please don't do that.

Mentioning people for getting attention to an issue, can come across as demanding (even when that is not your intention). So please, don't do that. We have a bot active that handles that automatically (if appropriate and needed).

Thanks 👍

../Frenck

scxs535 commented 2 years ago

because thecode bumps aioimaplib to 1.0.0 (https://github.com/home-assistant/core/pull/74393), i though maybe he can help us. i have no other malice.

DavidFW1960 commented 2 years ago

OK I fixed this until they get around to fixing it upstream. It's here as a custom component if anyone else wants to try it. https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/imap

thecode commented 2 years ago

@scxs535 we get notified for issues, tagging someone without relevant information is not helpful.

I was going to work on a fix PR and noticed someone already did that https://github.com/bamthomas/aioimaplib/pull/79 so we now have to wait for it to be merged. I have verified it fixes the correct place. Once a new package is released I can bump it in HA.

scxs535 commented 2 years ago

got it, thanks for your great work

scxs535 commented 2 years ago

is there any news about the update? there is still no improvement in 2022.7.3

DavidFW1960 commented 2 years ago

is there any news about the update? there is still no improvement in 2022.7.3

You need to check the upstream issue. When that is fixed then the next release of HA will include it. Until then you can always use my custom component I linked above which includes the fix

scxs535 commented 2 years ago

i was hoping it may happen soon but i think i will use your custom component. Thanks 👍

TermiNaderTL commented 2 years ago

OK I fixed this until they get around to fixing it upstream. It's here as a custom component if anyone else wants to try it. https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/imap

I installed your custom component in HACS and it shows up as Authenticated - David's Home Assistant. I cannot find the Integration to add to HA though to use this workaround. Am I setting this up incorrectly @DavidFW1960?

DavidFW1960 commented 2 years ago

Am I setting this up incorrectl

Looks like it. You need to download those 5 files into config/custom_components/imap directory

ndbroadbent commented 2 years ago

Thanks @DavidFW1960, adding your custom component files fixed the issue for me! (This was still not fixed in 2022.7.6.)

DavidFW1960 commented 2 years ago

Thanks @DavidFW1960, adding your custom component files fixed the issue for me! (This was still not fixed in 2022.7.6.)

Yeah I am seeing no traction on the upstream PR which is what the problem is.

J-o-h-n-M commented 2 years ago

Thanks for this! I added the imap folder to my custom_components folder and it works.

But when I go to HACS, i don't see it anywhere. Should I be able to see it somewhere?

DavidFW1960 commented 2 years ago

No its not HACS compliant and there will be no updates. Its just a stopgap till its fixed upstream and rolled into core

jamesking210 commented 2 years ago

was on vacation since the 2022.7.x rollout. is this an issue upstream still?

J-o-h-n-M commented 2 years ago

was on vacation since the 2022.7.x rollout. is this an issue upstream still?

Yes its still an issue, but using https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/imap solves it.

jamesking210 commented 2 years ago

was on vacation since the 2022.7.x rollout. is this an issue upstream still?

Yes its still an issue, but using https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/imap solves it.

Thank you @J-o-h-n-M and @DavidFW1960 - worked right away

DavidFW1960 commented 2 years ago

Upstream fix merged but HA 2022.8.0b1 still hasn't merged yet

frenck commented 2 years ago

Upstream fix merged but HA 2022.8.0b1 still hasn't merged yet

We can't as upstream did indeed merge it, but hasn't released anything yet. Hence, we have nothing to change or merge on our end and are awaiting upstream.

DavidFW1960 commented 2 years ago

Upstream fix merged but HA 2022.8.0b1 still hasn't merged yet

We can't as upstream did indeed merge it, but hasn't released anything yet.

Hence, we have nothing to change or merge on our end and are awaiting upstream.

Doh! That got me last time too. Thanks

sagitt commented 2 years ago

Upstream fix merged but HA 2022.8.0b1 still hasn't merged yet

We can't as upstream did indeed merge it, but hasn't released anything yet.

Hence, we have nothing to change or merge on our end and are awaiting upstream.

Doh! That got me last time too. Thanks

Hi, there is a chance to have it in to a minor release of 2022.8.x? Or need to wait 2022.9? Still using custom component fix

DavidFW1960 commented 2 years ago

It has to be released upstream then it will be in the next HA release

frenck commented 2 years ago

I've pinged the author of the library, asking him if he would consider bumping/releasing the library with just that fix. 🙏

miraixyz commented 2 years ago

was on vacation since the 2022.7.x rollout. is this an issue upstream still?

Yes its still an issue, but using https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/imap solves it.

I copied the contents of this github into my custom_components directory, and it didn't work. My imap sensor is still missing. Any word as to when there will be a permanent fix?

J-o-h-n-M commented 2 years ago

was on vacation since the 2022.7.x rollout. is this an issue upstream still?

Yes its still an issue, but using https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/imap solves it.

I copied the contents of this github into my custom_components directory, and it didn't work. My imap sensor is still missing. Any word as to when there will be a permanent fix?

Does your folder structure look like this? image

Did you reboot HA?

miraixyz commented 2 years ago

file structure is identical, but file sizes are different. 2022-08-12 204954

miraixyz commented 2 years ago

figured out what I did wrong. I accidentally downloaded the html page and not the file. works perfectly now. Thanks for pointing me in the right direction

Jaykurb commented 2 years ago

Sorry for the extremely dumb question but how do I download the folder from https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/imap I very rarely use GitHub but when I have, there has always been a download zip file if I remember correctly

miraixyz commented 2 years ago

Not a stupid question at all. Downloading the file gave me the HTML code to the link and not the file, so I was also baffled.

I don't know if this is the best way, but what I did was just click the file, copied the code into notepad++, and saved it under the same name and file extension.

Jaykurb commented 2 years ago

I just tried the same using sublime text (notepad++ isn't available on Mac) but it didn't work and it seems I have different files sizes compared to both screenshots above.

Screenshot 2022-09-01 at 10 31 06

DavidFW1960 commented 2 years ago

There is a text editor you can use on your mac. Or you can use gitzip to download the folder. You need to click on the raw button when you open the file and select all and copy/paste to a local file

miraixyz commented 2 years ago

Sounds like you're copying some junk. Click on RAW to see just the code

Jaykurb commented 2 years ago

Really odd, I couldn't get the correct file sizes using raw or GitZip, but it's working now anyway, thank you.

J-o-h-n-M commented 2 years ago

Sorry for the extremely dumb question but how do I download the folder from https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/imap I very rarely use GitHub but when I have, there has always been a download zip file if I remember correctly

You can go to the parent page ( https://github.com/DavidFW1960/home-assistant ) and download the zip file. From there you can then just extract the IMAP folder.

sagitt commented 2 years ago

Hi, will be fixed in 2022.9? Thanks

N1c093 commented 2 years ago

Hi, will be fixed in 2022.9? Thanks

The owner of https://github.com/bamthomas/aioimaplib doesn't released a new version. Without the new release the issue can't be fixed in HA.

Short answere: Sadly not.

DavidFW1960 commented 2 years ago

Really odd, I couldn't get the correct file sizes using raw or GitZip, but it's working now anyway, thank you.

It's likely just some spaces or blank lines at the end. Also check which line terminations you are using. Linux is generally only LF not CRLF so that is probably the difference.

kds69 commented 2 years ago

OK I fixed this until they get around to fixing it upstream. It's here as a custom component if anyone else wants to try it. https://github.com/DavidFW1960/home-assistant/tree/master/custom_components/imap

Any chance you have a fix for imap_email_content as well please? I tried without success.

DavidFW1960 commented 2 years ago

Any chance you have a fix for imap_email_content as well please? I tried without success.

I don't use that one so I haven't looked at it.

amelchio commented 2 years ago

The upstream aioimaplib has released a fixed 1.0.1 version so this can be resolved for Home Assistant now by a version bump.

(The email content integration is unrelated to this one and any problems there are separate issues.)