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

Failed to load monitor data #65

Open
chemelli74 opened this issue Apr 9, 2024 · 4 comments
Open

Failed to load monitor data #65

chemelli74 opened this issue Apr 9, 2024 · 4 comments

Comments

@chemelli74
Copy link
Contributor

Hi,

didn't investigate yet, but noticed the following error in my log:

2024-04-09 22:06:34.678 INFO (MainThread) [custom_components.shinobi.managers.rest_api] Status changed from 'Establishing connection to API' to 'Connected with temporary API key'
2024-04-09 22:06:34.725 INFO (MainThread) [custom_components.shinobi.managers.rest_api] Status changed from 'Connected with temporary API key' to 'Connected to the API'
2024-04-09 22:06:34.730 ERROR (MainThread) [custom_components.shinobi.managers.rest_api] Failed to load monitor data: {'ok': False, 'msg': 'Not Authorized'}, Error: the JSON object must be str, bytes or bytearray, not NoneType, Line: 464
2024-04-09 22:06:34.742 INFO (MainThread) [custom_components.shinobi.managers.websockets] Status changed from 'None' to 'Connected to the API'
2024-04-09 22:06:34.743 INFO (MainThread) [custom_components.shinobi.managers.websockets] Starting to listen connected

Everything, excluded #61, seems to work anyway.

@chemelli74
Copy link
Contributor Author

Investigated a bit more.
I changed the code as follow around line 461:

from:

  if monitor is None:
                        _LOGGER.debug("Invalid monitor details found")

to:

  if monitor is None or not monitor.get("ke"):
                        _LOGGER.debug("Invalid monitor details found")

and added a log line around line 315:

if self.status == ConnectivityStatus.Connected:
            _LOGGER.warning("Simone - load_monitors in update()")
            await self._load_monitors()

This is the resulting log:

2024-04-15 19:04:37.885 INFO (MainThread) [custom_components.shinobi.managers.rest_api] Status changed from 'Connected with temporary API key' to 'Connected to the API'
2024-04-15 19:04:37.886 WARNING (MainThread) [custom_components.shinobi.managers.rest_api] Simone - load_monitors in update()
2024-04-15 19:04:37.895 WARNING (MainThread) [custom_components.shinobi.managers.rest_api] Invalid monitor details found
2024-04-15 19:04:37.906 INFO (MainThread) [custom_components.shinobi.managers.websockets] Status changed from 'None' to 'Connected to the API'
2024-04-15 19:04:37.906 INFO (MainThread) [custom_components.shinobi.managers.websockets] Starting to listen connected
2024-04-15 19:04:38.962 WARNING (MainThread) [custom_components.shinobi.managers.rest_api] Simone - load_monitors in update()
2024-04-15 19:04:38.973 WARNING (MainThread) [custom_components.shinobi.managers.rest_api] Simone - load_monitors in update()

You can see that the call fails only the 1st time.
And on top of that, noticed that "update()" is called even 3 times in 1 second.

@Max6025
Copy link

Max6025 commented May 30, 2024

where is the file in homeassistant config? i.e. the pwd

@Max6025
Copy link

Max6025 commented May 30, 2024

@chemelli74

@elad-bar
Copy link
Owner

@chemelli74 according to the original error, the request was not autorized, it has nothing to do with the workaround,
the issue is in line 464 where the code is trying to load the details of the monitor and it holds nothing (because it failed),
will release full fix for that issue, both to protect the api call and the handling of the empty data

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

No branches or pull requests

3 participants