pgorod / power-todoist-card

Improved Todoist card for Home Assistant Lovelace UI.
MIT License
20 stars 7 forks source link

[FEATURE REQUEST] #8

Closed arretx closed 4 months ago

arretx commented 4 months ago

I'm not sure if this is a feature request or not.

I needed to create a sensor in HA that would count the number of tasks that have been completed today. So, I modified the REST sensor yaml to look like this:

- platform: rest
  name: Tasks Completed Today
  method: GET
  resource: "https://api.todoist.com/sync/v9/completed/get_all"
  headers:
    Authorization: !secret todoist_api_token
  value_template: "Ok"
  params:
    since: >
      {{ (now() - timedelta(days = 0)).strftime('%Y-%m-%dT00:00:00') }}
  json_attributes:
    - items
  scan_interval: 60

As a result, the only items in the attributes for this sensor are ones where the "completed_at" is after midnight today.

The problem with this sensor is that the "completed_at" is 7 hours off as I am in Arizona (-07:00). So, the count isn't actually correct.

I wonder if there's a way to ensure that the items pulled from the REST sensor can be adjusted to display the task complete_at time in my time zone. Or, would adjusting the above "since" parameter to the following work?

{{ (now() - timedelta(days = 1)).strftime('%Y-%m-%dT17:00:00') }}

pgorod commented 4 months ago

I feel that this is more of a Todoist API question than a Powertodoist card issue... my card has no control over what a sensor is getting from the API.

Have you tried asking Todoist support about this?

arretx commented 4 months ago

I haven't. I just went ahead and offset the sensor time and it seems to be working. Thanks for the response.

On Fri, Feb 23, 2024 at 12:32 PM pgorod @.***> wrote:

I feel that this is more of a Todoist API question than a Powertodoist card issue... my card has no control over what a sensor is getting from the API.

Have you tried asking Todoist support about this?

— Reply to this email directly, view it on GitHub https://github.com/pgorod/power-todoist-card/issues/8#issuecomment-1961879471, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHURKUUBCHPPOPZLTIQJULDYVDVFBAVCNFSM6AAAAABDXDPK3SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRHA3TSNBXGE . You are receiving this because you authored the thread.Message ID: @.***>

pgorod commented 4 months ago

Ok good. I'll close the Issue now, but let me know if there's anything else you need.

Oh, and if you want to share here how you did the offsetting of the timezone in the sensor, that might be helpful for others. Thanks.