Open Morphy99 opened 3 years ago
Hey, thank you so much for taking the time to hop over to Github and open this issue. I think I saw your comment on the forums, didn't get a chance to reply yet.
I find it quite strange that this IMAP sensor causes issues with a different sensor and I'd like to figure out if it really is a problem with this code. Would you be able to help me narrow it down? I don't have MQTT running on my instance but I might be able to set something up.
I don't see any mention of the ha_imap_attachment code in the stacktrace you've provided. HA logs warnings for it at the top, but only that 1) this is an unofficial & untested integration and 2) that this integration doesn't have a version
field in the manifest. Neither of those are explicit errors, so I'm wondering if perhaps this error you're seeing is not actually caused by the ha_imap_attachment integration.
Thank you for your help!
Hi no problem thanks for taking the time to reply! I thought I'd post it here in case you hadn't seen the post on HA forum as I sometimes don't get notifications from there.
It is a strange issue, the MQTT integration works fine without this component enabled. I've got the imap_email_content sensor if that's what you mean? That has a different name to yours.
I've just this week tested this sensor for the first time and my HA has been running MQTT for a couple of years!
I can see if I can get some more logs if that helps? I can also try with another instance which just has mqtt and this IMAP sensor?
Cool, if it's easy then yes please test on the instance that only has MQTT and ha_imap_attachment! I think that should tell us if there's a naming conflict with imap_email_content. I know they have different names on the surface but I'm wondering if somehow there's a problem with how the inner methods are registered.
So after more testing, the plot thickens! The README.md suggests all that is need for the sensor to work is this:
Next add the sensor definition:
sensor: - platform: imap_attachment name: IMAP Attachments storage_path: /config/attachments
By default this configuration will extract all text content found in the first page of the PDF.
Which is all I added.
HOWEVER, it goes on to mention imap_email_content settings which is how I expected it to work, in conjunction with imap_email_content. Now I realise we have to put the imap_email_content settings in as well as per the Full Configuration Example and the Implementation Example. The confusing thing is in these examples you've left out storage_path which is required I think?!
After adding this to my sensors.yaml:
- platform: imap_attachment
name: IMAP Attachments
storage_path: "/media_dir"
server: imap.gmail.com
port: 993
username: "user@gmail.com"
password: "pw"
senders:
- user2@gmail.com
I also commented out imap_email_content sensor so as to eliminate any conflicts but still got the async_setup_component errors.
With a relatively fresh instance only running a few MQTT sensors on HASSOS, something different now. Just checking configuration after adding the sensor to yaml throws this error:
2021-03-24 09:57:31 WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'imap_attachment'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'imap_attachment'
2021-03-24 09:57:31 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/util/package.py", line 37, in is_installed
req = pkg_resources.Requirement.parse(package)
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3139, in parse
req, = parse_requirements(s)
ValueError: not enough values to unpack (expected 1, got 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
resp = await self._request_handler(request)
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 119, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 56, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 129, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/core.py", line 29, in post
errors = await async_check_ha_config_file(request.app["hass"])
File "/usr/src/homeassistant/homeassistant/config.py", line 885, in async_check_ha_config_file
res = await check_config.async_check_ha_config_file(hass)
File "/usr/src/homeassistant/homeassistant/helpers/check_config.py", line 201, in async_check_ha_config_file
p_integration = await async_get_integration_with_requirements(
File "/usr/src/homeassistant/homeassistant/requirements.py", line 79, in async_get_integration_with_requirements
await async_process_requirements(
File "/usr/src/homeassistant/homeassistant/requirements.py", line 126, in async_process_requirements
if pkg_util.is_installed(req):
File "/usr/src/homeassistant/homeassistant/util/package.py", line 41, in is_installed
req = pkg_resources.Requirement.parse(urlparse(package).fragment)
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3139, in parse
req, = parse_requirements(s)
ValueError: not enough values to unpack (expected 1, got 0)
Trying to restart HA from the Server Controls I keep getting this in the log which is my imap_email_content sensor:
2021-03-24 10:02:40 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.email_content is taking over 10 seconds
and it doesn't restart. I had to reboot the Host.
After rebooting I get a different error:
ERROR (MainThread) [homeassistant.bootstrap] Error setting up integration sensor - received exception
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/util/package.py", line 37, in is_installed
req = pkg_resources.Requirement.parse(package)
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3139, in parse
req, = parse_requirements(s)
ValueError: not enough values to unpack (expected 1, got 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 895, in async_forward_entry_setup
result = await async_setup_component(self.hass, domain, self._hass_config)
File "/usr/src/homeassistant/homeassistant/setup.py", line 57, in async_setup_component
return await setup_tasks[domain] # type: ignore
File "/usr/src/homeassistant/homeassistant/setup.py", line 64, in async_setup_component
return await task # type: ignore
File "/usr/src/homeassistant/homeassistant/setup.py", line 174, in _async_setup_component
processed_config = await conf_util.async_process_component_config(
File "/usr/src/homeassistant/homeassistant/config.py", line 828, in async_process_component_config
p_integration = await async_get_integration_with_requirements(hass, p_name)
File "/usr/src/homeassistant/homeassistant/requirements.py", line 79, in async_get_integration_with_requirements
await async_process_requirements(
File "/usr/src/homeassistant/homeassistant/requirements.py", line 126, in async_process_requirements
if pkg_util.is_installed(req):
File "/usr/src/homeassistant/homeassistant/util/package.py", line 41, in is_installed
req = pkg_resources.Requirement.parse(urlparse(package).fragment)
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3139, in parse
req, = parse_requirements(s)
ValueError: not enough values to unpack (expected 1, got 0)
2021-03-24 10:09:48 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/util/package.py", line 37, in is_installed
req = pkg_resources.Requirement.parse(package)
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3139, in parse
req, = parse_requirements(s)
ValueError: not enough values to unpack (expected 1, got 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 895, in async_forward_entry_setup
result = await async_setup_component(self.hass, domain, self._hass_config)
File "/usr/src/homeassistant/homeassistant/setup.py", line 57, in async_setup_component
return await setup_tasks[domain] # type: ignore
File "/usr/src/homeassistant/homeassistant/setup.py", line 64, in async_setup_component
return await task # type: ignore
File "/usr/src/homeassistant/homeassistant/setup.py", line 174, in _async_setup_component
processed_config = await conf_util.async_process_component_config(
File "/usr/src/homeassistant/homeassistant/config.py", line 828, in async_process_component_config
p_integration = await async_get_integration_with_requirements(hass, p_name)
File "/usr/src/homeassistant/homeassistant/requirements.py", line 79, in async_get_integration_with_requirements
await async_process_requirements(
File "/usr/src/homeassistant/homeassistant/requirements.py", line 126, in async_process_requirements
if pkg_util.is_installed(req):
File "/usr/src/homeassistant/homeassistant/util/package.py", line 41, in is_installed
req = pkg_resources.Requirement.parse(urlparse(package).fragment)
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3139, in parse
req, = parse_requirements(s)
ValueError: not enough values to unpack (expected 1, got 0)
Anything else you want me to try?
Wow, thank you for the detailed testing notes, this is very useful. I'll try to replicate. It kind of looks like the config flow for the component isn't set up correctly, though I'm not sure what could have changed to drastically in recent versions.
Out of curiosity, what version of HA are you on?
Thanks, let me know if you want me to try anything else.
I'm on Home Assistant Core 2021.3.3 running on Docker on a RPi4. My other instance which is practically fresh is on HASSOS, latest stable HA Core as well.
Having the same issue running a virtually identical setup with HA 2023.3.6
Hi
I tried to use your custom component however it created an issue with MQTT discovery in my HA instance as soon as I enabled in my yaml:
I'm on Home Assistant Core 2021.3.3 running on Docker on a RPi4.