Skip to content

Commit

Permalink
Remove date tracking from services
Browse files Browse the repository at this point in the history
  • Loading branch information
isabellaalstrom committed Sep 6, 2021
1 parent 26ea491 commit 81f0675
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.
2 changes: 1 addition & 1 deletion custom_components/grocy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Base component constants
NAME = "Grocy"
DOMAIN = "grocy"
VERSION = "master"
VERSION = "v3.2.0"

ISSUE_URL = "https://github.com/custom-components/grocy/issues"

Expand Down
18 changes: 2 additions & 16 deletions custom_components/grocy/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
SERVICE_SPOILED = "spoiled"
SERVICE_TRANSACTION_TYPE = "transaction_type"
SERVICE_CHORE_ID = "chore_id"
SERVICE_TRACKED_TIME = "tracked_time"
SERVICE_DONE_BY = "done_by"
SERVICE_TASK_ID = "task_id"
SERVICE_DONE_TIME = "done_time"
SERVICE_ENTITY_TYPE = "entity_type"
SERVICE_DATA = "data"

Expand Down Expand Up @@ -59,7 +57,6 @@
{
vol.Required(SERVICE_CHORE_ID): int,
vol.Optional(SERVICE_DONE_BY): int,
vol.Optional(SERVICE_TRACKED_TIME): str,
}
)
)
Expand All @@ -68,7 +65,6 @@
vol.Schema(
{
vol.Required(SERVICE_TASK_ID): int,
vol.Optional(SERVICE_DONE_TIME): str,
}
)
)
Expand Down Expand Up @@ -196,14 +192,9 @@ async def async_execute_chore_service(hass, coordinator, data):
"""Execute a chore in Grocy."""
chore_id = data[SERVICE_CHORE_ID]
done_by = data.get(SERVICE_DONE_BY, "")
tracked_time_str = data.get(SERVICE_TRACKED_TIME, "")

tracked_time = datetime.now()
if tracked_time_str is not None and tracked_time_str != "":
tracked_time = iso8601.parse_date(tracked_time_str)

def wrapper():
coordinator.api.execute_chore(chore_id, done_by, tracked_time)
coordinator.api.execute_chore(chore_id, done_by)

await hass.async_add_executor_job(wrapper)

Expand All @@ -215,14 +206,9 @@ def wrapper():
async def async_complete_task_service(hass, coordinator, data):
"""Complete a task in Grocy."""
task_id = data[SERVICE_TASK_ID]
done_time_str = data.get(SERVICE_DONE_TIME, None)

done_time = datetime.now()
if done_time_str is not None and done_time_str != "":
done_time = iso8601.parse_date(done_time_str)

def wrapper():
coordinator.api.complete_task(task_id, done_time)
coordinator.api.complete_task(task_id)

await hass.async_add_executor_job(wrapper)

Expand Down
12 changes: 0 additions & 12 deletions custom_components/grocy/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ execute_chore:
description: The id of the user who executed the chore
selector:
text:
tracked_time:
name: Tracked time
example: '2019-06-18T19:00:00.251Z'
description: The timestamp at when the chore got executed as ISO8601
selector:
text:

complete_task:
name: Complete Task
Expand All @@ -103,12 +97,6 @@ complete_task:
description: The id of the task to complete
selector:
text:
done_time:
name: Done Time
example: '2019-06-18T19:00:00.251Z'
description: The timestamp at when the task got completed as ISO8601
selector:
text:

add_generic:
name: Add Generic
Expand Down

0 comments on commit 81f0675

Please sign in to comment.