Custom Component: Google Tasks (revived)

Thanks that is quite helpful. Looks like the API has a default for the amount of tasks returned

  • Default: maxResults=20

Looks like I can bump that up to 100 easily enough but might have to do a bit more work if we want to go over that amount…

Yeah, 20 would be fine if they were at least the next 20 due. Any idea why it pulls a seemingly random 20? 100 would solve some problems for sure, but what’s the logic for the limited tasks it retrieves?

I use these bits to be able to create tasks using voice assist. It defaults to tomorrow as the due date (I think since the task name is wildcarded, parsing a due date from the voice command might be tricky)

Anyway, hope it helps someone :slight_smile:

Custom Sentence
===============

  CreateTask:
      data:
         - sentences:
            - "Create [a] task to {task}"


Intent Script
=============

CreateTask:
   speech:
     text: "I shall create a task to remind you to {{task}}"
   action:
     service: gtasks.new_task
     data:
       task_title: "{{task}}"
       tasks_list: My Tasks
       due_date: "{{(now() + timedelta(days=1)).date() }}"
2 Likes

On my quick test it seemed to me to be based on the order in which the tasks were created.

I’ve increased the results returned to 100 for now. You can get this through hacs by setting your version to master. There is a way to retrieve ‘nextPages’ as well to go over 100 but that will take a bit more work to add.

Another note to add that this limitation also applies to anyone with more than 100 different lists.

This has solved my issue for now, thanks! Looks like I have 47 tasks. I’ll just try to keep it under 100 unless there’s a wider need for more. :sunglasses:

Another question, if I split the tasks into multiple lists, would I still be limited to 100 tasks total across all lists?

Edit: the answer is yes. Multiple lists allow having >100 total tasks.

Fantastic addition to my Home Assistant.

It did force me to finally get rid of my subtasks (only supported by 3rd party https://fullscreen-for-googletasks.com/ anyways) which have due dates… but that’s fine. I should have been making separate lists anyways. Now I have 3 types of “To Do” lists! And yes, I am also one of those that require >20 tasks per list… so thanks for that!

FYI this is getting added to Home Assistant in the upcoming release

1 Like

Oh cool, thanks for bringing this to my attention. Will be very nice to have a builtin version. I’m sure they will have a proper login flow. Assuming this ends up with all the same functionality this project will be redundant and so I will probably retire it in due course.

Would there be a way to add a horizontal rule between the tasks on the lovelace card?

Plz don’t retire the project… I’ve been waiting for the HA update but ended up learning to-do lists have a horrible support… No dates, times, repetition… nesting etc

Maybe you could youse the HA core support to improve your project? Sry, I’m not a coder I may say something stupid

Looks like the new native integration can’t do all the things that Gtasks can do. In fact, it literally just syncs items in lists… the items aren’t actually accessible as entities in any manner (ie can’t extract items and send reminders to displays or voice assistants)… and no due dates. Basically useless as an integration except to automatically add and delete tasks… and the only thing that Home Assistant can access directly is the number of unfinished items. Sigh. Useless.

It basically just adds sync to the previously-added shopping list integration… it might be useful as a shopping list… but it already was.

So my gtasks card seems broken, there is no text field to enter new tasks into. The “<paper-input>” tag seems to have been deprecated. I have changed the gtasks-card.js HTML section to “<ha-textfield ...>” ( from “<paper input ...>” ) which solves the issue. It isn’t formatted very nicely and I don’t currently have time to try and write css to get it looking purty but it works again.

I realize they just added the integration into core but as others have mentioned, it doesnt expose the tasks in the attributes, I am guessing you would have to pull the data from the HA API with get requests like what is needed for calendar components like atomic-calendar.

I also like the styling of this card much better than their clunky one, so I would prefer to continue using this integration and card. I will continue to help where I can.

@myntath - if you could push the update I mentioned above, not sure if it is affecting others but I noticed today that I was unable to enter any text into the card for the create task section.

90% of the time I used the tasks app on my phone, but occasionally I use HA to add tasks.

Thanks again for keeping this alive!

This should be possible, I may try and accomplish it if I find some spare time. It would add another level of complexity to the config, but should be doable with a <div> with height = 1px, set the background to a color, set the margins and done.

Possibly add one config entry "hr_color: " to the card config. If not set - no rule. If set, rule of noted color. Give it a class, and let y’all customize it in cardmod.

I went ahead and added a crude separator:

On phone:

@myntath : here is a link to my .js if you want to compare and push the changes: gtasks-card.js.

I have added three possible config entries:
show_hr: true/false ( default false )
hr_color: hex, name ( default ‘white’, can be 4 byte hex with alpha )
hr_end: true/false ( default true ) set false to remove last hr after final event.

cardmod: css class: ‘hr-separator’ ( you can over-ride everything there, height, width, etc., etc… )

1 Like

hi, do i need to do anything other than replace paper-input with ha-textfield please? because i have tried that and it does not appear to have worked!
much appreciation and thanks to everyone working on this integration, which i much prefer and would rather keep using if i can fix this one issue!
thanks again

Where are you changing it? If you change it in the js file you will need to rename the .gz file to something like “.gz.old”, and clear your browser cache. Make sure to change the </paper-input> closing tag also. No other changes were necessary for me.

If you make a bunch of changes in the js file you might have to add “?v=1” after the .js resource in settings-dashboards “…” Resources. Increment once for each change and clear cache. It’s a pain but it works.

Hopefully @myntath will get around to pushing the changes. Otherwise I would consider forking it.

I get the erro how can I fix it? and what does it mean?

This error originated from a custom integration.

Logger: custom_components.gtasks
Source: custom_components/gtasks/init.py:223
Integration: GTasks (documentation)
First occurred: November 19, 2023 at 11:51:05 PM (3 occurrences)
Last logged: 12:30:05 AM

<HttpError 503 when requesting https://tasks.googleapis.com/tasks/v1/lists/MTYyNDc4NjU4NDcyODYxNzAxOTE6NDIxNzc0Nzc5MjU2OTA4NDow/tasks?showCompleted=false&maxResults=100&alt=json returned “The service is currently unavailable.”. Details: “[{‘message’: ‘The service is currently unavailable.’, ‘domain’: ‘global’, ‘reason’: ‘backendError’}]”>
<HttpError 503 when requesting https://tasks.googleapis.com/tasks/v1/lists/MTYyNDc4NjU4NDcyODYxNzAxOTE6MDow/tasks?showCompleted=false&maxResults=100&alt=json returned “The service is currently unavailable.”. Details: “[{‘message’: ‘The service is currently unavailable.’, ‘domain’: ‘global’, ‘reason’: ‘backendError’}]”>
Traceback (most recent call last):
File “/config/custom_components/gtasks/init.py”, line 223, in update_data
tasks_list_sensor = await self.hass.async_add_executor_job(request_sensor.execute)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/googleapiclient/_helpers.py”, line 130, in positional_wrapper
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.11/site-packages/googleapiclient/http.py”, line 938, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 503 when requesting https://tasks.googleapis.com/tasks/v1/lists/MTYyNDc4NjU4NDcyODYxNzAxOTE6NDIxNzc0Nzc5MjU2OTA4NDow/tasks?showCompleted=false&maxResults=100&alt=json returned “The service is currently unavailable.”. Details: “[{‘message’: ‘The service is currently unavailable.’, ‘domain’: ‘global’, ‘reason’: ‘backendError’}]”>

Got it, thanks
It was renaming the gz file and the clearing the cache that I needed to know.
Thanks again

1 Like

Love the potential of this! I’m trying to set this up but am constantly getting the cant find credentials file error. Any thoughts?
cred missing