Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail attachment not working when you get files from subdirectory within /config/something #127

Closed
sclgroup opened this issue Mar 12, 2023 · 2 comments

Comments

@sclgroup
Copy link

sclgroup commented Mar 12, 2023

Hi Roger,

I greatly appreciate your work, seems your integration which can send an email WITH attachement only.
... however when you want to get an email attachement from subdirectory (eg. /config/somesubdir/somefile.csv, the service gives an error.

This test service:

service: notify.o365_email_siratotanya
data:
  message: Test from outlook.com
  title: Test from outlook.com
  data:
   target: [email protected]
   attachments:
      - /config/boiler/boilerdata.csv

gives an error. This is the log:

2023-03-12 20:40:13.731 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: build_config_file_path() takes 2 positional arguments but 3 were given
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1808, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 264, in _async_notify_message_service
await self.async_send_message(**kwargs)
File "/config/custom_components/o365/notify.py", line 113, in async_send_message
self._build_attachments(data, new_message.attachments)
File "/config/custom_components/o365/notify.py", line 169, in _build_attachments
attachments = [get_ha_filepath(self._hass, x) for x in attachments]
File "/config/custom_components/o365/notify.py", line 169, in
attachments = [get_ha_filepath(self._hass, x) for x in attachments]
File "/config/custom_components/o365/utils.py", line 223, in get_ha_filepath
_filepath = build_config_file_path(hass, *_filepath.parts[2:])
TypeError: build_config_file_path() takes 2 positional arguments but 3 were given
2023-03-12 20:40:13.745 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140320519985696] Error handling message: Unknown error (unknown_error) Palkó László from 192.168.1.102 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.63)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
await func(hass, connection, msg)
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 647, in handle_execute_script
await script_obj.async_run(msg.get("variables"), context=context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1808, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1845, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/components/notify/legacy.py", line 264, in _async_notify_message_service
await self.async_send_message(**kwargs)
File "/config/custom_components/o365/notify.py", line 113, in async_send_message
self._build_attachments(data, new_message.attachments)
File "/config/custom_components/o365/notify.py", line 169, in _build_attachments
attachments = [get_ha_filepath(self._hass, x) for x in attachments]
File "/config/custom_components/o365/notify.py", line 169, in
attachments = [get_ha_filepath(self._hass, x) for x in attachments]
File "/config/custom_components/o365/utils.py", line 223, in get_ha_filepath
_filepath = build_config_file_path(hass, *_filepath.parts[2:])
TypeError: build_config_file_path() takes 2 positional arguments but 3 were given

Cheers,

Laszlo

@RogerSelwyn
Copy link
Owner

Ok, I’ll take a look over the next few days.

@RogerSelwyn
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants