Custom component : Google Tasks

Update !

Now it survives to reboot :slight_smile:

Update :
A custom card for Lovelace :slight_smile:

@BlueBlueBlob I’m having the same issue.

Ok I can reproduce error :
Before adding to config flow, you need to add gtasks configuration in configuration.yaml like

gtasks : 
  credentials_location: '/config/credentials.json'
  default_list: 'Corvées'
  token_location: '/config/token.pickle'

Restart and then add Gtasks by Integration

My bad readme file is not correct

What do you with before adding to config flow?

Integration menu

What is this token?

It’s the oauth2 token. It will be generated on your first authentication.
The variable is the path where this file can writable and stored.

Followed all the instructions but adding via Integration never works. I’m getting this in the logs:
Any help much appreciated

‘ascii’ codec can’t decode byte 0xe4 in position 1: ordinal not in range(128)
Traceback (most recent call last):
File “/config/custom_components/gtasks/config_flow.py”, line 46, in async_step_init
self.hass.data[DOMAIN_DATA][“gtasks_obj”] = GtasksAPI(self.creds, self.token_file)
File “/usr/local/lib/python3.7/site-packages/gtasks_api/gtasks_api.py”, line 21, in init
self._connect()
File “/usr/local/lib/python3.7/site-packages/gtasks_api/gtasks_api.py”, line 29, in _connect
self._creds = pickle.load(token)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe4 in position 1: ordinal not in range(128)

And this is my config

gtasks:
credentials_location: /config/credentials.json
default_list: “Sorrento”
token_location: /config/token.pickle

Hi,
Thanks for reporting :+1:
Is /config in your whitelist ? Like this :

whitelist_external_dirs:
  - /config

Regards
Edit : I certainly need to update install steps

Tried that, made no difference. Have tried all different paths and through trial and error I think it’s picking up on the credentials and token but on clicking add GTasks via Integration, this is the error I get in it’s entirety.

2020-01-16 20:06:24 INFO (MainThread) [custom_components.gtasks.config_flow] None
2020-01-16 20:06:24 ERROR (MainThread) [custom_components.gtasks.config_flow] ‘ascii’ codec can’t decode byte 0xe4 in position 1: ordinal not in range(128)
Traceback (most recent call last):
File “/config/custom_components/gtasks/config_flow.py”, line 46, in async_step_init
self.hass.data[DOMAIN_DATA][“gtasks_obj”] = GtasksAPI(self.creds, self.token_file)
File “/usr/local/lib/python3.7/site-packages/gtasks_api/gtasks_api.py”, line 21, in init
self._connect()
File “/usr/local/lib/python3.7/site-packages/gtasks_api/gtasks_api.py”, line 29, in _connect
self._creds = pickle.load(token)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe4 in position 1: ordinal not in range(128)
2020-01-16 20:06:24 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 39, in real_ip_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/ban.py”, line 72, in ban_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/auth.py”, line 135, in auth_middleware
return await handler(request)
File “/usr/src/homeassistant/homeassistant/components/http/view.py”, line 123, in handle
result = await result
File “/usr/src/homeassistant/homeassistant/components/config/config_entries.py”, line 127, in post
return await super().post(request)
File “/usr/src/homeassistant/homeassistant/components/http/data_validator.py”, line 50, in wrapper
result = await method(view, request, *args, **kwargs)
File “/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py”, line 59, in post
handler, context={“source”: config_entries.SOURCE_USER}
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 109, in async_init
result = await self._async_handle_step(flow, flow.init_step, data)
File “/usr/src/homeassistant/homeassistant/data_entry_flow.py”, line 172, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File “/config/custom_components/gtasks/config_flow.py”, line 59, in async_step_user
return await self.async_step_init(user_input)
File “/config/custom_components/gtasks/config_flow.py”, line 53, in async_step_init
raise e
File “/config/custom_components/gtasks/config_flow.py”, line 46, in async_step_init
self.hass.data[DOMAIN_DATA][“gtasks_obj”] = GtasksAPI(self.creds, self.token_file)
File “/usr/local/lib/python3.7/site-packages/gtasks_api/gtasks_api.py”, line 21, in init
self._connect()
File “/usr/local/lib/python3.7/site-packages/gtasks_api/gtasks_api.py”, line 29, in _connect
self._creds = pickle.load(token)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe4 in position 1: ordinal not in range(128)

I’m trying to reproduce it.
Keep in touch

I don’t know.
Are you running hassio ?

After some search, seems to be an access file issue or a python version issue.
If you are running in hassio, try to change path to /share

Ok found this : https://github.com/googleapis/google-api-python-client/issues/776

Can you try to delete the token pickle file please and retry.

And this if you are not running hassos : https://github.com/googleapis/google-api-python-client/issues/774#issuecomment-548859939

Yes that could be the problem. I’m running in docker on a VM which is headless so I had to create the token on my mac and copy over. I’m guessing that hasn’t worked. How can I create a token from the command line without a browser?

Ok, thx for informations.
You need only 1 file : credentials.json. (in /config from homeassisant)
Once your configuration.yaml is set up. Restart.
Go to integration, look for gtasks and add.

Now : the link you see, you can copy paste in the browser you want, like on your Mac. The result should be a code. Copy paste this code in the same box as the link in HA and submit.
Check your /config and now you should see the token.pickle

You need a browser but not in HA. I do authentication on my smartphone. You just need the return code.

Keep in touch

Deleted credentials & token. Re-created on mac. Now getting the following error:

2020-01-21 18:00:56 WARNING (MainThread) [googleapiclient.discovery_cache] file_cache is unavailable when using oauth2client >= 4.0.0 Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect from google.appengine.api import memcache ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/googleapiclient/discovery_cache/file_cache.py”, line 33, in
from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named ‘oauth2client.contrib.locked_file’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/googleapiclient/discovery_cache/file_cache.py”, line 37, in
from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named ‘oauth2client.locked_file’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/googleapiclient/discovery_cache/init.py”, line 41, in autodetect
from . import file_cache
File “/usr/local/lib/python3.7/site-packages/googleapiclient/discovery_cache/file_cache.py”, line 41, in
‘file_cache is unavailable when using oauth2client >= 4.0.0’)
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0

As you see, it’s just a warning. I have the same.
Did you receive a notification/mail on your Google account saying you are connected ?
Are sensors appear ?

Boom! Got my default list :smile: Thank you!!
Is it possible to get my other lists too?

Great ! I will update documentation regarding your case. Thanks.

For now it’s only 1 couple sensors (sensor and binary sensor) for 1 list.

It’s on my to-do list to have more than 1 list.

I thank you to take time because I thought it’s working only for me :joy_cat: