emcniece / ha_imap_attachment Goto Github PK
View Code? Open in Web Editor NEWHome Assistant IMAP Attachment Component
Home Assistant IMAP Attachment Component
Helping AussieByrd at https://community.home-assistant.io/t/parsing-pdf-email-attachments/262805/8
storage_path
parameterstorage_path
says it's required, but also has a default... so it it actually required?storage_path
is writeable during setup?Hi,
I'm hoping to set this component up to scrape cctv images sent to email by a camera with no local integration. Unfortunately I get this error in the home assistant logs.
Can you offer any insight?
cheers.
2022-06-12 15:50:45 ERROR (MainThread) [homeassistant.components.sensor] imap_attachment: Error on device update!
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 431, in _async_add_entity
await entity.async_device_update(warning=False)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity.py", line 737, in async_device_update
await task
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/ha_imap_attachment/sensor.py", line 301, in update
ATTR_ATTACHMENT_PATHS: EmailContentSensor.get_msg_attachments(email_message, self._storage_path),
File "/home/homeassistant/.homeassistant/custom_components/ha_imap_attachment/sensor.py", line 271, in get_msg_attachments
filename = attachment.get_filename()
AttributeError: 'str' object has no attribute 'get_filename'
Thanks for this fantastic addition @emcniece !
I was wondering if you'd consider implementing:
I get a lot of emails from one adress, only of which few of these contains relevant information. Then in the relevant email there are sometimes several files
I installed this custom integration by following the instructions. After adding the sensor to configuration.yaml Home Assistant won't start any longer. It stucks at "Loading data" and never redirects to the dashboard view.
- platform: imap_attachment
name: Kamera E-Mail
server: <removed>
port: 993
username: <removed>
password: <removed>
senders:
- <removed>
- <removed>
The logfile contains the following error message related to the ha_imap_attachment custom integration:
2022-01-25 21:55:48 WARNING (Recorder) [homeassistant.components.recorder] State is not JSON serializable: <state sensor.kamera_e_mail=; from=REMOVED subject=, date=Tue, 25 Jan 2022 00:18:58 +0100 (CET), body=[<email.message.Message object at 0xb0158148>], num_attachments=0, attachment_paths=[], friendly_name=Kamera E-Mail @ 2022-01-25T21:55:28.060950+01:00>
2022-01-25 21:55:51 ERROR (MainThread) [homeassistant.components.websocket_api.messages] Unable to serialize to JSON. Bad data found at $.result[10](State: sensor.kamera_e_mail).attributes.body[0]=Content-Type: image/jpeg;
name="01_20220125001853000.jpg"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="01_20220125001853000.jpg"/9j/2wCEABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19i
Z2hnPk1xeXBkeFxlZ2MBERISGBUYLxoaL2NCOEJjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2Nj
Y2NjY2NjY2NjY2NjY2NjY2NjY2NjY//AABEIAfgDgAMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAA
AAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGh
CCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hp
anN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV
[...]
After removing the entries from configuration.yaml Home Assistant will start again.
Any suggestions?
HA-Version: 2021.11.5
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:
2021-03-17 17:33:35 WARNING (MainThread) [homeassistant.loader] You are using a custom integration imap_attachment which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2021-03-17 17:33:35 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-17 17:33:35 ERROR (MainThread) [homeassistant.util.logging] Exception in async_discovery_message_received when handling msg on 'homeassistant/sensor/347538_status/config': '{"name":"Bedroom Amp status","stat_t":"tele/tasmota-bedroom_amp/HASS_STATE","avty_t":"tele/tasmota-bedroom_amp/LWT","pl_avail":"Online","pl_not_avail":"Offline","json_attr_t":"tele/tasmota-bedroom_amp/HASS_STATE","unit_of_meas":"%","val_tpl":"{{value_json['RSSI']}}","ic":"mdi:information-outline","uniq_id":"347538_status","dev":{"ids":["347538"],"name":"Bedroom Amp","mdl":"Sonoff S2X","sw":"9.1.0(tasmota)","mf":"Tasmota"}}'
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/components/mqtt/discovery.py", line 161, in async_discovery_message_received
await async_process_discovery_payload(component, discovery_id, payload)
File "/usr/src/homeassistant/homeassistant/components/mqtt/discovery.py", line 222, in async_process_discovery_payload
await hass.config_entries.async_forward_entry_setup(
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/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/helpers/discovery.py", line 195, in async_load_platform
setup_success = await setup.async_setup_component(hass, component, 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/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/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/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/helpers/discovery.py", line 195, in async_load_platform
setup_success = await setup.async_setup_component(hass, component, 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/helpers/discovery.py", line 195, in async_load_platform
setup_success = await setup.async_setup_component(hass, component, 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/helpers/discovery.py", line 195, in async_load_platform
setup_success = await setup.async_setup_component(hass, component, 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/helpers/discovery.py", line 195, in async_load_platform
setup_success = await setup.async_setup_component(hass, component, 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/helpers/discovery.py", line 195, in async_load_platform
setup_success = await setup.async_setup_component(hass, component, 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/helpers/discovery.py", line 195, in async_load_platform
setup_success = await setup.async_setup_component(hass, component, 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/helpers/discovery.py", line 195, in async_load_platform
setup_success = await setup.async_setup_component(hass, component, 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/helpers/discovery.py", line 195, in async_load_platform
setup_success = await setup.async_setup_component(hass, component, 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)
I'm on Home Assistant Core 2021.3.3 running on Docker on a RPi4.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.