Custom Component: Google Tasks (revived)

@myntath Thnx. It works like expected.

The "unknown error occurred” might be because you have not enabled Google Tasks API in google cloud platform. Atleast thats why i got it.

Got to Google Cloud PLatform > APIs and Services dashboard > Enabled APIs and Services > + ENABLE APIS AND SERVICES > search for Google Tasks > Open Google Tasks API and you should see an option to enable it.

After that i reconnected in HA and the error disappeared for me

2 Likes

I’m getting this error when I try to add or mark a task:

“Cannot call gtasks/complete_task: required key is not provided @ data[‘task_list’]”

Any ideas on what this means?

@myntath - New version is tight, nice work and thank you!

Is there an easy way to add an MDI icon to the title?

I went ahead and coded one in. You’re welcome to adjust and pull the changes as always.

In render():

<ha-card>
    <h1 class="card-header"><ha-icon class=title_icon .icon="${this.icon}"> </ha-icon>${this.header}</h1>
    <div>

In _renderStyle():

.title_icon {
   ${this.show_icon ? "" : "display: none;" }
   margin-right: 5px;
   --mdc-icon-size: ${this.icon_size};
   color: ${this.icon_color};
}

In set hass(hass):

const list_icon = entity.attributes.icon;
this.icon = this.config.icon == null ? list_icon : this.config.icon;
this.icon_size = this.config.icon_size == null ? "30px" : this.config.icon_size;
this.icon_color = this.config.icon_color == null ? "var(--primary-text-color)" : this.config.icon_color;
this.show_icon = this.config.show_icon == null ? true : this.config.show_icon;

EDIT: Updated to pull task list entity icon by default, overridden by defining icon in yaml, hidden by setting show_icon to false in yaml.

Again thank you for all you do!

I am not getting this in the gtasks lovelace card, are you calling the service directly? If so what does your yaml for the service call look like?

EDIT: I’ve confirmed the service calls work fine for me. The error message you have looks like you have left out the data from the service call. Go into developer mode, to services and select the service you want to use. Click “GO TO YAML MODE” and click “FILL EXAMPLE DATA” at the bottom then edit the values under “data:” to the ones that match your list/task and it should work (“due_date” is optional). Use this format when calling the service from your intended use case. Hope that helps.

Did everyone just figure out what they had to do to set up the Google Cloud project? I think I’ll succeed, but I find it odd that nobody’s talking about this and there’s no documentation on it.

Thanks for another contribution @russ-sentient I have added this to the master on github. I haven’t made a new version with this yet but if you set your HACS to beta and select master it should work. I have changed the icon to default as off.

Once its been tested a bit more i’ll release a new version which includes this.

1 Like

I think this project would benefit a lot from some good documentation around the google setup. I suspect a lot of issues result from errors when setting it up.

When I have time (or someone volunteers) I’ll setup a fresh google account and try run through the process from scratch and document the steps. I know it was a hassle when I first did it but it was a long time ago so I can’t really remember everything that had to be done and I already had things like projects in existence before I started.

1 Like

I needed to create a project, set up the OAuth consent screen, add Tasks, create a OAuth client ID, and then I could get the credentials json.

2 Likes

Awesome! I was debating default off to avoid breaking changes to existing setups.

I know the Google Cloud API setup was a bit of trial and error for me as well, mainly the app type needed to get the proper credentials. I believe it was desktop. A guide would be excellent.

I feel like I may have followed the nest integration guide as a reference? It’s been a long time since I had to set one up from scratch…

For the GTasks integration you do not need the Smart Device Management (SDM) part so no payment required.

@myntath - it says in there that the Desktop Auth is deprecated by google for security reasons, does this mean we will need a better OAuth setup in the future?

@Digital-Jedi

Hi, thanks for your comments. I actually missed this post somehow. Both your ideas are good and they are supported by the API. I will add them as proposed enhancement.

Thanks,

I don’t believe it is an issue for us. The deprecation happened back in 2022.

Hello,

I am not succeeding in getting a correct credentials.json file from the Google API. Get the message from the component setup “Credentials file not found”. While it is definitely there. Is it access issue to the file or it means it is not the correct or expected json file.
Still, my HA features few Google Integration with Calendar or Home.
Is there a generic tutorial to get the credentials.json from the Google API with the appropriate settings?
The json file I am getting form Google API is never named credentials.json. I rename it accordingly but it does not help.

Mostly likely it is file not found. With invalid json you would get ‘unknown error’.

When I download the credentials file from google it is named ‘client_secret_413XXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com.json’ I also renamed it credentials.json but you can use any name.

I would try checking in your home-assistant.log there may be more information but most likely home assistant can’t read the credentials file either due to permissions or user error. I place my credentials.json in “~/.home-assistant/credentials.json” and then set the location as “./credentials.json”

I’ve added some short text instructions about setting up the google API and obtaining credentials.json on the readme. If anyone has trouble with following that process please let me know and I can update the instructions.

I could make it work. Indeed the json file was OK.
The default path and file name of the integration setup can not really be edited. Even if I was changing them, there were always resuming to the default.
Still, I made a test and copied the manifest.json at multiple location of my HA and when it was placed in the config folder then it worked.

Integrated the card now.
The project seems very promising with a lot of possibility for for future updates.
Thanks @myntath for having resumed this integration of G-Tasks

Thanks for this mate, its amazing work! Ill keep following.

I’d like to add more to @Digital-Jedi’s list, task time would be super useful, maybe even repeat settings.

Anyway I enjoy it already, thanks a bunch!