#using REST to work with DoneTick

1 messages · Page 1 of 1 (latest)

young mulch
#

anyone know how I can make this work? I want to update a chore using an automation and assign it to a user_id (home assistant). there isn't much documentation on how to get it working on donetick's side. https://github.com/donetick/donetick/blob/main/internal/chore/api.go#L152

When I run the automation it runs without an error but fails to do anything...

rest_command:
 donetick_assign_user:
   url: "http://192.168.68.69:2021/eapi/v1/chore/{{ chore_id }}"
   method: PATCH
   headers:
     secretkey: !secret donetick_api_key
     Content-Type: "application/json"
   payload: >
     {
       "assignedTo": {{ user_id }}
     }

and the automation

alias: Dishwasher request empty
triggers:
  - entity_id: sensor.dishwasher_operation_state
    to: finished
    trigger: state
actions:
  - data:
      task_id: 9
      due_date: "{{ now().astimezone().strftime('%Y-%m-%dT23:59:00Z') }}"
    action: donetick.update_task
  - data:
      chore_id: 9
      user_id: 3
    action: rest_command.donetick_assign_user
mode: single
lone solstice
#

No experience with Donetick, but did you test the rest command another way? Via Rested for example.

north tulip
#

Also, take a look at the logs on both ends for additional clues

#

Where did you get the idea for using PATCH?

#

I'm not seeing anything that hints to that, should be PUT for updating a chore

#

However, it doesn't look like that method updates assignedTo, only name, description and dueDate

young mulch
#

turns out there was a simpler solution since donetick creates an entity for each "thing" so I just needed to do ```yaml
alias: Dishwasher request empty
triggers:

  • entity_id: sensor.dishwasher_operation_state
    to: finished
    trigger: state
    actions:
  • action: switch.turn_on
    metadata: {}
    data: {}
    target:
    entity_id: switch.donetick_things_dishwasher_cycled
  • action: donetick.update_task
    metadata: {}
    data:
    task_id: 9
    due_date: >-
    {{ now().replace(hour=23, minute=59, second=0,
    microsecond=0).isoformat() }}
    name: Empty Dishwasher
    mode: single
#

it wasnt obvious, since i needed to restart HA for it to show the entity... Which just happened by chance when I was updating HA to the newer version release...

#

regardless, changing PATCH to PUT did actually resolve the problem as well @north tulip