I was really happy to see the CalDAV integration supporting ToDos/Tasks now. That has been one of the features I’ve been really hoping for.
I tried to use a a template in the due_datetime
variable of the todo.add_item
. However no matter what I tried, I only got an error.
The service call I tried looks something like this:
service: todo.add_item
target:
entity_id: todo.chores
data:
item: Fold the dried Laundry!
description: Fold the dried Laundry!
due_datetime: "{{ (now() + timedelta(hours=36)) }}"
However, even with something like due_datetime: "{{ (now() + timedelta(hours=36)).isoformat(timespec='seconds') }}"
, i.e. either returning the time as a datetime
in the first example or as a str
in the second, the service call fails, with the python-caldav
package complaining:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 655, in async_trigger
await self.action_script.async_run(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1578, in async_run
return await asyncio.shield(run.async_run())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 704, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
return long_task.result()
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/todo/__init__.py", line 455, in _async_add_todo_item
await entity.async_create_todo_item(
File "/usr/src/homeassistant/homeassistant/components/caldav/todo.py", line 147, in async_create_todo_item
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/caldav/objects.py", line 765, in save_todo
data=self._use_or_create_ics(ical, objtype="VTODO", **ical_data),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/caldav/objects.py", line 733, in _use_or_create_ics
return vcal.create_ical(objtype=objtype, **ical_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/caldav/lib/vcal.py", line 184, in create_ical
component.add(prop, props[prop])
File "/usr/local/lib/python3.11/site-packages/icalendar/cal.py", line 194, in add
value = self._encode(name, value, parameters, encode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/icalendar/cal.py", line 145, in _encode
obj = klass(value)
^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/icalendar/prop.py", line 312, in __init__
raise ValueError('You must use datetime, date, timedelta, '
ValueError: You must use datetime, date, timedelta, time or tuple (for periods)
Am I doing something wrong after all?
Edit: As asked by @petro, I opened a bug report.