Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions homeassistant/components/calendar/services.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# Describes the format for available calendar services

todoist:
new_task:
description: Create a new task and add it to a project.
fields:
content:
description: The name of the task (Required).
example: Pick up the mail
project:
description: The name of the project this task should belong to. Defaults to Inbox (Optional).
example: Errands
labels:
description: Any labels that you want to apply to this task, separated by a comma (Optional).
example: Chores,Deliveries
priority:
description: The priority of this task, from 1 (normal) to 4 (urgent) (Optional).
example: 2
due_date:
description: The day this task is due, in format YYYY-MM-DD (Optional).
example: "2018-04-01"
todoist_new_task:
description: Create a new task and add it to a project.
fields:
content:
description: The name of the task (Required).
example: Pick up the mail
project:
description: The name of the project this task should belong to. Defaults to Inbox (Optional).
example: Errands
labels:
description: Any labels that you want to apply to this task, separated by a comma (Optional).
example: Chores,Deliveries
priority:
description: The priority of this task, from 1 (normal) to 4 (urgent) (Optional).
example: 2
date_string:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other due date parameter is called due_date - so one might wonder whether this is another type of date? Perhaps a name like due_date_string would make things clearer?

description: The day this task is due, in natural language (Optional).
example: "tomorrow"
date_lang:
description: The langurage of date_string (Optional).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

example: "en"
due_date:
description: The day this task is due, in format YYYY-MM-DD (Optional).
example: "2018-04-01"
17 changes: 16 additions & 1 deletion homeassistant/components/calendar/todoist.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
DESCRIPTION = 'description'
# Calendar Platform: Used in the '_get_date()' method
DATETIME = 'dateTime'
# Service Call: When is this task due (in natural language)?
DATE_STRING = 'date_string'
# Service Call: The language of DATE_STRING
DATE_LANG = 'date_lang'
# Attribute: When is this task due?
# Service Call: When is this task due?
DUE_DATE = 'due_date'
Expand Down Expand Up @@ -83,7 +87,9 @@
vol.Optional(PROJECT_NAME, default='inbox'): vol.All(cv.string, vol.Lower),
vol.Optional(LABELS): cv.ensure_list_csv,
vol.Optional(PRIORITY): vol.All(vol.Coerce(int), vol.Range(min=1, max=4)),
vol.Optional(DUE_DATE): cv.string,
vol.Optional(DATE_STRING): cv.string,
vol.Optional(DATE_LANG): vol.All(cv.string, vol.Length(min=2, max=2)),
vol.Optional(DUE_DATE): cv.string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since specifying both a date string and a due date is not possible (see below), this should probably already be caught in validation?

})

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
Expand Down Expand Up @@ -186,7 +192,16 @@ def handle_new_task(call):
if PRIORITY in call.data:
item.update(priority=call.data[PRIORITY])

if DATE_STRING in call.data:
item.update(date_string=call.data[DATE_STRING])

if DATE_LANG in call.data:
item.update(date_lang=call.data[DATE_LANG])

if DUE_DATE in call.data:
# Make sure only DUE_DATE is set

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should at least issue a warning here, if it's not already caught by service validation (see above).

item.update(date_string='')

due_date = dt.parse_datetime(call.data[DUE_DATE])
if due_date is None:
due = dt.parse_date(call.data[DUE_DATE])
Expand Down