elad-bar / ha-shinobi

Shinobi Video custom component for HA
53 stars 5 forks source link

Cannot Connect to Shinobi - Missing Permanent API Key #40

Closed algaen closed 1 year ago

algaen commented 1 year ago

I am having an issue connecting Home Assistant to Shinobi since my update to the shinobi component to 2.0.26. After the update my cameras no longer connected so I removed the component, intending to reconfigure. Whenever I do the initial integration configuration I get a timeout error with 'Missing Permanent API Key'.

With debug enabled I get the following in the logs:

2022-11-27 18:28:36.488 DEBUG (MainThread) [custom_components.shinobi.config_flow] Starting async_step_user of Shinobi Video
2022-11-27 18:28:36.490 DEBUG (MainThread) [custom_components.shinobi.configuration.managers.configuration_manager] Validate login
2022-11-27 18:28:36.490 INFO (MainThread) [custom_components.shinobi.component.api.api] Initializing Shinobi Video
2022-11-27 18:28:36.490 INFO (MainThread) [custom_components.shinobi.core.api.base_api] Performing login
2022-11-27 18:28:36.490 DEBUG (MainThread) [custom_components.shinobi.component.api.api] POST http://10.23.10.10:8070/?json=true, Url Encoded: False
2022-11-27 18:28:36.506 DEBUG (MainThread) [custom_components.shinobi.component.api.api] Status of http://10.23.10.10:8070/?json=true: 200
2022-11-27 18:28:36.510 DEBUG (MainThread) [custom_components.shinobi.component.api.api] GET http://10.23.10.10:8070/8891a4201adca80274853405a5f07190/api/uhUYXqkkPT/list
2022-11-27 18:30:36.514 ERROR (MainThread) [custom_components.shinobi.component.api.api] Failed to get data from {base_url}{api_key}/api/{group_id}/list, Error: Server disconnected, Line: 203
2022-11-27 18:30:36.515 WARNING (MainThread) [custom_components.shinobi.component.api.api] Invalid response while trying to get API keys, Payload is empty
2022-11-27 18:30:36.517 WARNING (MainThread) [custom_components.shinobi.config_flow] Failed to create integration, Error: missing_permanent_api_key

I have an API key setup om Shinobi following the recommended configuration and I have had the component working for a long time. My Shinobi instance and my HomeAssistant instance are both running in dockers on an Unraid server so I do not expect there are any network issues.

The strange thing is that I can open the URL referenced (http://10.23.10.10:8070/8891a4201adca80274853405a5f07190/api/uhUYXqkkPT/list) in my browser as well as using the Home-Assistant docker WebUI in Unraid. In both cases I get an immediate result - pasted below. It shows an API key but I removed it since I don't think we want to share those broadly.

{
   "ok": true,
   "uid": "zBG9AHrmij",
   "ke": "uhUYXqkkPT",
   "keys": [
      {
         "ke": "uhUYXqkkPT",
         "uid": "zBG9AHrmij",
         "ip": "0.0.0.0",
         "code": "####",
         "details": {
            "auth_socket": "1",
            "get_monitors": "1",
            "control_monitors": "1",
            "get_logs": "1",
            "watch_stream": "1",
            "watch_snapshot": "1",
            "watch_videos": "1",
            "delete_videos": "1"
         },
         "time": "2022-11-26T00:03:41.000Z"
      }
   ]
}
elad-bar commented 1 year ago

Please check issue #39 and let me know if the workaround works for you

Thanks

algaen commented 1 year ago

I assume you are referring to: The workaround is to set value in the NVR or wait for next release, hopefully tomorrow

I already had the number of days of video to retain set to 28 in Shinobi. This did not work. Please advise if there is something else I should be checking/setting.

elad-bar commented 1 year ago

I had it on Saturday but it was related to Shinobi, didn't see the key over the UI of Shinobi although it was available over the API, redployed it and it started working again, If that does solve the issue i will need to investigate in logs and maybe release an additional release with more logs

elad-bar commented 1 year ago

Having the error in line 203 makes me wonder if you are using the latest version or did it took place when you have restarted the HA

algaen commented 1 year ago

The issue occured when I updated my Home Assistant docker and all of my HACS integrations earlier this week. When I restarted HA my cameras were showing as unavailable so I removed the integration with the intent of reading it to fix my cameras. That was when I encountered this issue.

My Home Assistant docker, Shinobi docker and Shinobi-HA integration are all on the latest versions.

On Sun, Nov 27, 2022, 9:56 p.m. Elad Bar @.***> wrote:

Having the error in line 203 makes me wonder if you are using the latest version or did it took place when you have restarted the HA

— Reply to this email directly, view it on GitHub https://github.com/elad-bar/ha-shinobi/issues/40#issuecomment-1328537043, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEKXNXE3RMISKJ2N2GAJ53WKQ3OTANCNFSM6AAAAAASM2NI6A . You are receiving this because you authored the thread.Message ID: @.***>

elad-bar commented 1 year ago

Shinobi has many latest versions, which branch?

elad-bar commented 1 year ago

checked about that issue, not sure whether it's the same issue I have expirenced last Saterday or another one as described in released a new version v2.0.28 with potential workaround / fix for the issue foudn while working with aiohttp, more details available here

elad-bar commented 1 year ago

@algaen pls let me know if it solved the issue, thanks

algaen commented 1 year ago

Shinobi has many latest versions, which branch?

This is slightly embarrassing but I cannot tell. When I log in to 'Super' the current version number is blank. I also checked the logs but it does not list the version number.

That said, I am running the SpaceInvaderOne 'ShinobiPro' docker installed on Unraid from Community Applications. It has not been updated in 10 months. I typically update my containers in bulk so just assumed it was getting regular updates. Thanks for asking the question as it made me realize I may not be using the correct docker container.

Before pursuing further troubleshooting let me test with another Shinobi docker that is more up-to-date. I hope to do that tomorrow evening.

algaen commented 1 year ago

checked about that issue, not sure whether it's the same issue I have expirenced last Saterday or another one as described in released a new version v2.0.28 with potential workaround / fix for the issue foudn while working with aiohttp, more details available here

I updated to v2.0.28 tonight but it did not resolve my issue - same error. See my previous comment. I will try an updated version of the Shinobi docker container tomorrow.

elad-bar commented 1 year ago

If that didn't solve the issue it basically means that the problem is with the ability of the server to get requests, Not sure what build your server is based on, for sure it is not the official one and therefore I cannot assist, Making a single request to the server for specific endpoint is not what that integration is doing (query several endpoints on load / updat, Can you pls switch to the official docker (preferably dev tag)?

algaen commented 1 year ago

If that didn't solve the issue it basically means that the problem is with the ability of the server to get requests, Not sure what build your server is based on, for sure it is not the official one and therefore I cannot assist, Making a single request to the server for specific endpoint is not what that integration is doing (query several endpoints on load / updat, Can you pls switch to the official docker (preferably dev tag)?

Upgrading to the official docker appears to have solved my problem. Thank you for the support!

elad-bar commented 1 year ago

Thanks for the update, glad to hear it solved the issue