Custom component : Google Tasks (abandoned)

Template error :
Need " around {{ and }}
Like :

data_template:
      task_title: Some task
      tasks_list: Dagpass
      due_date: "{{ now().date() }}"

@BlueBlueBlob I didnā€™t get a response on this one.

I have installed it successfully but when I click ā€œTrackā€ it takes a minute before the task is removed from the list. Is it possible to make it disappear faster?

I already force a refresh sensor. With one list, I need to refresh my browser. But it doesnā€™t take 1 minute.
How many list do you track ?

Just got this integration and plugin set up using HACS. Great work!

I do have a minor bug/issue to report though :slight_smile: I use a list called #GroceryList (the hashtag makes it appear alphabetically at the top of a bunch of other lists I use in a 3rd party iOS app for Tasks). Home Assistant happily let me add the list using the integration and, as expected, dropped the # symbol from the sensor and binary sensor ids. But when I clicked Track on a task in the list, the following error message appeared in the Home Assistant logs:
Forced update failed. Entity sensor.gtasks_#grocerylist not found.
When I browsed away from the View the list was on and came back later, the card had updated to reflect the task item was now marked complete, so I think it may only be the forced update that is failing, if that helps.

Thanks again for creating this and let me know if you need any more details or action from me and Iā€™ll be happy to help!

1 Like

Thanks,
I know list name handling is not good.
I will try to find a fix. Btw it seems more a bug from card.
Keep in touch, thx for feedbacks :+1:

I just follow 2 lists. 48 seconds including a browser refresh.

Can you try the new version and report time plz ?

Do you have some JS skills ?
Btw can you try with the new version ? Just to know if some char are skipped.
And thanks :slight_smile:

Iā€™m pretty amateur, I can follow javascript and python fairly well, but writing my own is another story :-).

Tried the new version but same result as last. I did start digging in to the code in the card and integration, and it looks to me that in https://github.com/BlueBlueBlob/lovelace-gtasks-card/blob/b557b59cdef404682a0b6ddb2222f4c8981e19da/gtasks-card.js, around line 86-88 is where the service is called to set the task complete:

    _track(task_name){
      this._hass.callService("gtasks", "complete_task", {
        task_title: task_name,
        tasks_list: this.list_name
      });
    }

Then in https://github.com/BlueBlueBlob/gtasks/blob/852f8105d655f5d138e31c08bf19219ad0c37e88/custom_components/gtasks/init.py#L170, the complete_task(call) function, the task list name is used on line 184:

                '{}.{}_{}'.format(CONF_SENSOR, DOMAIN, list.lower())) , hass.loop)

Would it makes sense to pass the configured entity from the cardā€™s _track() function into the complete_task function instead of (or really, in addition to) the list_title?

Something like

    _track(task_name){
      this._hass.callService("gtasks", "complete_task", {
        task_title: task_name,
        tasks_entity: this.entity,
        tasks_list: this.list_name
      });
    }

Then update the complete_task function:

    def complete_task(call):
        task_name = call.data.get(ATTR_TASK_TITLE)
        list = call.data.get(ATTR_TASKS_LIST)
        list_entity = call.data.get(ATTR_TASKS_ENTITY) # ATTR_TASKS_ENTITY would need to be added to const.py as well
        client = hass.data[DOMAIN_DATA]["client"]
        list_id = client.tasks_lists_id[list]
        service = client._service
        try:
            list = unicodedata.normalize('NFKD', list).encode('ascii','ignore').decode("utf-8")
            task_id = client.gapi.get_task_id(list_id, task_name)
            task_to_complete = service.tasks().get(tasklist=list_id, task=task_id).execute()
            task_to_complete['status'] = 'completed'
            service.tasks().update(tasklist=list_id, task=task_to_complete['id'], body=task_to_complete).execute()
            asyncio.run_coroutine_threadsafe(entity_component.async_update_entity(
                hass,
                list_entity) , hass.loop) # Passing the entity as configured in the card, rather than the list title, to be updated here.  Also simplified a bit by removing the format() function here that used the CONF_SENSOR and DOMAIN consts.  Not sure if that's bad style or not :-)
        except Exception as e:
            _LOGGER.exception(e)

1 Like

Thx
I found a simple a way. I donā€™t want to change the service call schema again.

Try update and let me know

1 Like

Confirmed fixed! Thanks very much!

1 Like

Thx again for reporting :+1:
Btw my question about JS : do you know how to force refresh on the custom card ?

:smiley_cat:

Sorry no, Iā€™m still wrapping my head around how to create a custom card :slight_smile: and thatā€™s one of the (many) parts I donā€™t understand yet.

My base is from https://github.com/isabellaalstrom/lovelace-grocy-chores-card maybe it can help you.

I get an Unkown error when trying to add from Integrations. Any idea why this is happening?

Can you provide logs please.

I had the same error @sunnydsouza.

@BlueBlueBlob a package is missing in the requirements of the custom components.
You have to add the ā€œgoogle-auth-httplib2ā€ library.
You can do this in ā€œ/config/custom_components/gtasks/manifest.jsonā€ :

  "requirements": [
    "gtasks_api==0.0.8",
    "integrationhelper",
    "google-auth-httplib2"
  ],

Now ,It work for me.

Hi,
Thanks for reporting.
Itā€™s weird because gtasks_api already needs this package.
Without log I can not confirm itā€™s related to other issue.

Btw do you have the warning about you can not use file cache with lib ?

Hi,
thanks for that custom component + lovelace card. For me itā€™s a perfect alternative until multiple shopping cards are available.
With the help from https://github.com/gadgetchnnel/lovelace-text-input-row I can add also new tasks directly from the lovelace UI

1 Like

Thx :slight_smile:
I had to rework services regarding new ha stuff.
Like service through device and you will not need custom card :slight_smile:

Keep in touch and thank you :+1: