Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'NoneType' object is not subscriptable #91

Closed
ggocsei opened this issue Dec 30, 2024 · 4 comments · Fixed by #92
Closed

TypeError: 'NoneType' object is not subscriptable #91

ggocsei opened this issue Dec 30, 2024 · 4 comments · Fixed by #92

Comments

@ggocsei
Copy link

ggocsei commented Dec 30, 2024

Hi all,

We get this error after install and setup:

Unexpected error fetching carelink data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 379, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/carelink/init.py", line 161, in _async_update_data
recent_data = await self.client.get_recent_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/carelink/api.py", line 390, in get_recent_data
if self.__session_user["role"]
~~~~~~~~~~~~~~~~~~~^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

What should be the problem?

Thanks,
Gábor

yo-han added a commit that referenced this issue Jan 2, 2025
@yo-han
Copy link
Owner

yo-han commented Jan 2, 2025

It seems there is no user session when checking for the role of the account. I made a small change to log an error when this happens instead of crashing. Maybe this helps.

@yo-han yo-han closed this as completed in #92 Jan 2, 2025
yo-han added a commit that referenced this issue Jan 2, 2025
Fixes #91

Check if user session exists
@ggocsei
Copy link
Author

ggocsei commented Jan 2, 2025

Thanks. The error is gone away, but got new:
/config/custom_components/carelink/init.py:88: SyntaxWarning: invalid escape sequence '.' date_iso = re.sub(".\d{3}Z$", "+00:00", date)

@yo-han
Copy link
Owner

yo-han commented Jan 6, 2025

This is just a syntax warning and nothing that should break the app. I will fix it still, because not exactly what you would like.

@ggocsei
Copy link
Author

ggocsei commented Jan 7, 2025

I'd like to connect my device and get the data 😄
It's connecting, but is see unknow state on every sensor. Now only this relevant warning shows up in the log:

Detected blocking call to open with args ('custom_components/carelink/logindata.json', 'r') inside the event loop by custom integration 'carelink' at custom_components/carelink/api.py, line 406: token_data = json.loads(open(filename, "r").read()) (offender: /config/custom_components/carelink/api.py, line 406: token_data = json.loads(open(filename, "r").read()))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants