From 1681d36637e130fe71569e014d11c266d29a73b3 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Wed, 27 Nov 2019 05:26:59 -0500 Subject: [PATCH] Update service domain for todoist from 'calendar' to 'todoist' (#29131) * move todoist constants to const.py and update service domain * update .coveragerc * remove unused variable * save file --- .coveragerc | 1 + .../components/calendar/services.yaml | 24 ---- homeassistant/components/todoist/calendar.py | 119 ++++++------------ homeassistant/components/todoist/const.py | 79 ++++++++++++ 4 files changed, 115 insertions(+), 108 deletions(-) create mode 100644 homeassistant/components/todoist/const.py diff --git a/.coveragerc b/.coveragerc index 73b203a181a..5e8f5e04850 100644 --- a/.coveragerc +++ b/.coveragerc @@ -692,6 +692,7 @@ omit = homeassistant/components/tile/device_tracker.py homeassistant/components/time_date/sensor.py homeassistant/components/todoist/calendar.py + homeassistant/components/todoist/const.py homeassistant/components/tof/sensor.py homeassistant/components/tomato/device_tracker.py homeassistant/components/toon/* diff --git a/homeassistant/components/calendar/services.yaml b/homeassistant/components/calendar/services.yaml index ebf0c7b1591..d8a0575bced 100644 --- a/homeassistant/components/calendar/services.yaml +++ b/homeassistant/components/calendar/services.yaml @@ -1,26 +1,2 @@ # 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. - example: Pick up the mail - project: - description: The name of the project this task should belong to. Defaults to Inbox. - example: Errands - labels: - description: Any labels that you want to apply to this task, separated by a comma. - example: Chores,Deliveries - priority: - description: The priority of this task, from 1 (normal) to 4 (urgent). - example: 2 - due_date_string: - description: The day this task is due, in natural language. - example: "tomorrow" - due_date_lang: - description: The language of due_date_string. - example: "en" - due_date: - description: The day this task is due, in format YYYY-MM-DD. - example: "2018-04-01" diff --git a/homeassistant/components/todoist/calendar.py b/homeassistant/components/todoist/calendar.py index 2e8b43c749f..eabec37a053 100644 --- a/homeassistant/components/todoist/calendar.py +++ b/homeassistant/components/todoist/calendar.py @@ -5,97 +5,48 @@ import logging from todoist.api import TodoistAPI import voluptuous as vol -from homeassistant.components.calendar import ( - DOMAIN, - PLATFORM_SCHEMA, - CalendarEventDevice, -) +from homeassistant.components.calendar import PLATFORM_SCHEMA, CalendarEventDevice from homeassistant.const import CONF_ID, CONF_NAME, CONF_TOKEN import homeassistant.helpers.config_validation as cv from homeassistant.helpers.template import DATE_STR_FORMAT from homeassistant.util import Throttle, dt +from .const import ( + ALL_DAY, + ALL_TASKS, + CHECKED, + COMPLETED, + CONF_PROJECT_DUE_DATE, + CONF_EXTRA_PROJECTS, + CONF_PROJECT_LABEL_WHITELIST, + CONF_PROJECT_WHITELIST, + CONTENT, + DATETIME, + DESCRIPTION, + DOMAIN, + DUE, + DUE_DATE, + DUE_DATE_LANG, + DUE_DATE_STRING, + DUE_DATE_VALID_LANGS, + DUE_TODAY, + END, + ID, + LABELS, + NAME, + OVERDUE, + PRIORITY, + PROJECT_ID, + PROJECT_NAME, + PROJECTS, + SERVICE_NEW_TASK, + START, + SUMMARY, + TASKS, +) + _LOGGER = logging.getLogger(__name__) -CONF_EXTRA_PROJECTS = "custom_projects" -CONF_PROJECT_DUE_DATE = "due_date_days" -CONF_PROJECT_LABEL_WHITELIST = "labels" -CONF_PROJECT_WHITELIST = "include_projects" - -# Calendar Platform: Does this calendar event last all day? -ALL_DAY = "all_day" -# Attribute: All tasks in this project -ALL_TASKS = "all_tasks" -# Todoist API: "Completed" flag -- 1 if complete, else 0 -CHECKED = "checked" -# Attribute: Is this task complete? -COMPLETED = "completed" -# Todoist API: What is this task about? -# Service Call: What is this task about? -CONTENT = "content" -# Calendar Platform: Get a calendar event's description -DESCRIPTION = "description" -# Calendar Platform: Used in the '_get_date()' method -DATETIME = "dateTime" -DUE = "due" -# Service Call: When is this task due (in natural language)? -DUE_DATE_STRING = "due_date_string" -# Service Call: The language of DUE_DATE_STRING -DUE_DATE_LANG = "due_date_lang" -# Service Call: The available options of DUE_DATE_LANG -DUE_DATE_VALID_LANGS = [ - "en", - "da", - "pl", - "zh", - "ko", - "de", - "pt", - "ja", - "it", - "fr", - "sv", - "ru", - "es", - "nl", -] -# Attribute: When is this task due? -# Service Call: When is this task due? -DUE_DATE = "due_date" -# Todoist API: Look up a task's due date -DUE_DATE_UTC = "due_date_utc" -# Attribute: Is this task due today? -DUE_TODAY = "due_today" -# Calendar Platform: When a calendar event ends -END = "end" -# Todoist API: Look up a Project/Label/Task ID -ID = "id" -# Todoist API: Fetch all labels -# Service Call: What are the labels attached to this task? -LABELS = "labels" -# Todoist API: "Name" value -NAME = "name" -# Attribute: Is this task overdue? -OVERDUE = "overdue" -# Attribute: What is this task's priority? -# Todoist API: Get a task's priority -# Service Call: What is this task's priority? -PRIORITY = "priority" -# Todoist API: Look up the Project ID a Task belongs to -PROJECT_ID = "project_id" -# Service Call: What Project do you want a Task added to? -PROJECT_NAME = "project" -# Todoist API: Fetch all Projects -PROJECTS = "projects" -# Calendar Platform: When does a calendar event start? -START = "start" -# Calendar Platform: What is the next calendar event about? -SUMMARY = "summary" -# Todoist API: Fetch all Tasks -TASKS = "items" - -SERVICE_NEW_TASK = "todoist_new_task" - NEW_TASK_SERVICE_SCHEMA = vol.Schema( { vol.Required(CONTENT): cv.string, diff --git a/homeassistant/components/todoist/const.py b/homeassistant/components/todoist/const.py new file mode 100644 index 00000000000..a1e37bf0292 --- /dev/null +++ b/homeassistant/components/todoist/const.py @@ -0,0 +1,79 @@ +"""Constants for the Todoist component.""" +CONF_EXTRA_PROJECTS = "custom_projects" +CONF_PROJECT_DUE_DATE = "due_date_days" +CONF_PROJECT_LABEL_WHITELIST = "labels" +CONF_PROJECT_WHITELIST = "include_projects" + +# Calendar Platform: Does this calendar event last all day? +ALL_DAY = "all_day" +# Attribute: All tasks in this project +ALL_TASKS = "all_tasks" +# Todoist API: "Completed" flag -- 1 if complete, else 0 +CHECKED = "checked" +# Attribute: Is this task complete? +COMPLETED = "completed" +# Todoist API: What is this task about? +# Service Call: What is this task about? +CONTENT = "content" +# Calendar Platform: Get a calendar event's description +DESCRIPTION = "description" +# Calendar Platform: Used in the '_get_date()' method +DATETIME = "dateTime" +DUE = "due" +# Service Call: When is this task due (in natural language)? +DUE_DATE_STRING = "due_date_string" +# Service Call: The language of DUE_DATE_STRING +DUE_DATE_LANG = "due_date_lang" +# Service Call: The available options of DUE_DATE_LANG +DUE_DATE_VALID_LANGS = [ + "en", + "da", + "pl", + "zh", + "ko", + "de", + "pt", + "ja", + "it", + "fr", + "sv", + "ru", + "es", + "nl", +] +# Attribute: When is this task due? +# Service Call: When is this task due? +DUE_DATE = "due_date" +# Attribute: Is this task due today? +DUE_TODAY = "due_today" +# Calendar Platform: When a calendar event ends +END = "end" +# Todoist API: Look up a Project/Label/Task ID +ID = "id" +# Todoist API: Fetch all labels +# Service Call: What are the labels attached to this task? +LABELS = "labels" +# Todoist API: "Name" value +NAME = "name" +# Attribute: Is this task overdue? +OVERDUE = "overdue" +# Attribute: What is this task's priority? +# Todoist API: Get a task's priority +# Service Call: What is this task's priority? +PRIORITY = "priority" +# Todoist API: Look up the Project ID a Task belongs to +PROJECT_ID = "project_id" +# Service Call: What Project do you want a Task added to? +PROJECT_NAME = "project" +# Todoist API: Fetch all Projects +PROJECTS = "projects" +# Calendar Platform: When does a calendar event start? +START = "start" +# Calendar Platform: What is the next calendar event about? +SUMMARY = "summary" +# Todoist API: Fetch all Tasks +TASKS = "items" + +DOMAIN = "todoist" + +SERVICE_NEW_TASK = "new_task"