Custom component : Google Tasks (abandoned)

Hi all.

Abandoned project you can fork it at :

gtasks custom component

Lovelace card

Regards

4 Likes

Update : add binary sensor for “passed” tasks
(Sorry for my enfEnglish)

Update : binary sensor state fix

Template exemple :

  alias: GTask done
  description: ''
  trigger:
  - entity_id: sensor.gtasks_corvees
    platform: state
  condition: []
  action:
  - service: grocy.execute_chore
    data_template:
      chore_id: >
        {% for task_old in trigger.from_state.attributes['tasks'] %}
          {% if task_old not in trigger.to_state.attributes['tasks'] %}
            {% for chore in state_attr('sensor.grocy_chores','items') %}
              {% if task_old.task_title == chore.name %}
                {{ chore.chore_id }}
              {% endif %}
            {% endfor %}
          {% endif %}
        {% endfor %}

I’m cooking hacs integration.
Keep in touch :slight_smile:

Update : hacs integration.
Feedbacks are very welcome.

Nice, I’ll try this soon.
What would make this useful for me is a lovelace card with buttons to mark a task as done.
This would be handy to display on my home dashboard tablet.
But that’s of course something else entirely :wink:

Well… How to say, im not a dev web.
But it’s a good idea to go in. I will try, no promise.

Btw, you can do it (some beta one) with template and manual card.

Sorry, I have to read love-lace custom card documentation :wink:

Keep in touch :slight_smile: :+1:

I will do it like the shopping list card.
I think it’s a base to work on it.

I tested your component, however I’m having some issues with the credentials file.
I’m using HASS in a docker container. My config is as follows:

gtasks:
  credentials_location: /local/gtaskscredentials.json
  default_list: 'Main List'
  force_login: false

And my credentials file, downloaded from the Google developer portal is in location:

{homeassistantconfigfolder}/www/gtaskscredentials.json

This is working for other files, but not for this one. Any ideas?

Is this path accessible in your configuration.yaml ?
How did you upload file ? Are permissions right ?
Sorry I use hass.io so my help will be limited, but I will do my best.

Sorry edit stuff

So I checked how to do a custom card… How to say… :joy: : I don’t know TS. I will see with time.
Sorry.

For now I’m trying to fix token refresh on reboot or HA update. (Not sure about the case)

It should be accessible because I use the same path also for some icons, that are accessible.
Permissions are also the same fot both files. Strange …

It’s not a best practice, but /share is available in setup ?
I mean, on hassio it’s a share folder.
What’s about logs, is error an access error ?
(Should be and it is…)
Try to put a sensor file on this file https://www.home-assistant.io/integrations/filesize/

Maybe try logging debug to get more information.

I solved the error with the credentials file. The addon was only able to find it when placed directly in the /config folder. I no longer have errors in the HASS log anymore, but still cannot find any new devices.

You have to add it in HA integration, look for Google Tasks.
It will ask you to login.

I tried it, but after clicking Google Tasks in the add integration popup, it loads for a short while and then again shows the popup to choose an integration.

From the error log:

2019-11-03 20:19:58 INFO (MainThread) [custom_components.gtasks.config_flow] init config flow
2019-11-03 20:19:58 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 136, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 122, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 130, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 48, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 60, in post
    handler, context={"source": config_entries.SOURCE_USER}
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 73, in async_init
    return await self._async_handle_step(flow, flow.init_step, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 132, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/config/custom_components/gtasks/config_flow.py", line 48, in async_step_user
    return await self.async_step_init(user_input)
  File "/config/custom_components/gtasks/config_flow.py", line 44, in async_step_init
    return await self.async_step_link(user_input)
  File "/config/custom_components/gtasks/config_flow.py", line 52, in async_step_link
    url = self.hass.data[DOMAIN_DATA]["auth_url"]
KeyError: 'gtasks_data'

Hell ! Never see this.
First install can take some time since HA does pip install. If you try again ?
Can you list me files in /config/custom_components/gtasks plz.

Well I think I have to rework from scratch the gtasks py lib. I did it in appdeamon and it worked better.