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

Problem with integration with Annake (Hikvision) NVR N46PCK #45

Closed
slawekzz opened this issue May 26, 2023 · 24 comments
Closed

Problem with integration with Annake (Hikvision) NVR N46PCK #45

slawekzz opened this issue May 26, 2023 · 24 comments
Labels
bug Something isn't working

Comments

@slawekzz
Copy link

Hi
I have configured integration with Annake (Hikvision) NVR N46PCK but there are no entities related to cameras, alarms, motion detection. I am getting the following error in the system log. Entity information arrives but such entities are missing.

Ten błąd pochodzi z niestandardowej integracji.

Logger: custom_components.hikvision_next.notifications
Source: custom_components/hikvision_next/notifications.py:48
Integration: Hikvision NVR / IP Camera (documentation, issues)
First occurred: 12:04:26 (242 occurrences)
Last logged: 12:12:51

Cannot process incoming event Entity not found binary_sensor.n46pck1620211230ccrrj28984303wcvu_2_motiondetection
Cannot process incoming event Entity not found binary_sensor.n46pck1620211230ccrrj28984303wcvu_1_motiondetection
Cannot process incoming event Entity not found binary_sensor.n46pck1620211230ccrrj28984303wcvu_8_videoloss

@maciej-or
Copy link
Owner

The integration didn't detect events of your NVR, pls share full logs and we will see why https://github.com/maciej-or/hikvision_next#reporting-issues.
The second part (receiving notifications) works, so there is high probability it cold work

@maciej-or maciej-or added the logs needed This doesn't seem right label May 26, 2023
@slawekzz
Copy link
Author

Integration did not create entities, therefore HA cannot assign incoming events to them.

Do you expect the entire log file to be sent or only items related to Hikvision integration.

What do you mean by cold work?

@maciej-or
Copy link
Owner

it could work sorry for typo ;)
I need only entries related to integration, logs should contain a couple of http responses dumps like ISAPI/System/deviceInfo, ISAPI/ContentMgmt/InputProxy/channels and so on

@slawekzz
Copy link
Author

I can't find the specific API requests you wrote about in the log. If I ask the NVR "manually", I have answers to these queries as in the attached files. Whereas in home-assistant.log there is
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 332, in data_received
messages, upgraded, tail = self._request_parser.feed_data(data)
File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: 400, message="Bad status line 'Invalid method encountered'"
2023-05-26 12:06:06.517 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: Front_01
2023-05-26 12:06:06.523 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: Front_02
2023-05-26 12:06:06.524 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: Zachod_01
2023-05-26 12:06:06.525 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: Południe_01
2023-05-26 12:06:06.526 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 05
2023-05-26 12:06:06.526 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 06
2023-05-26 12:06:06.527 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 07
2023-05-26 12:06:06.528 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: Front_03
2023-05-26 12:06:06.528 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 09
2023-05-26 12:06:06.529 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 10
2023-05-26 12:06:06.530 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 11
2023-05-26 12:06:06.530 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 12
2023-05-26 12:06:06.531 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 13
2023-05-26 12:06:06.532 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 14
2023-05-26 12:06:06.532 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 15
2023-05-26 12:06:06.533 WARNING (MainThread) [custom_components.hikvision_next.isapi] No device identifier provided: IPCamera 16
2023-05-26 12:06:06.634 ERROR (MainThread) [aiohttp.server] Error handling request


Ten błąd pochodzi z niestandardowej integracji.

Logger: custom_components.hikvision_next.notifications
Source: custom_components/hikvision_next/notifications.py:48
Integration: Hikvision NVR / IP Camera (documentation, issues)
First occurred: 26 maja 2023 16:06:51 (153219 occurrences)
Last logged: 08:27:43

Cannot process incoming event Entity not found binary_sensor.n46pck1620211230ccrrj28984303wcvu_2_motiondetection
Cannot process incoming event Entity not found binary_sensor.n46pck1620211230ccrrj28984303wcvu_8_videoloss
Cannot process incoming event Entity not found binary_sensor.n46pck1620211230ccrrj28984303wcvu_1_motiondetection
Cannot process incoming event Entity not found binary_sensor.n46pck1620211230ccrrj28984303wcvu_4_videoloss
Cannot process incoming event Entity not found binary_sensor.n46pck1620211230ccrrj28984303wcvu_3_motiondetection


Ten błąd pochodzi z niestandardowej integracji.

Logger: custom_components.hikvision_next.isapi
Source: custom_components/hikvision_next/isapi.py:196
Integration: Hikvision NVR / IP Camera (documentation, issues)
First occurred: 29 maja 2023 12:39:44 (64 occurrences)
Last logged: 29 maja 2023 15:55:24

No device identifier provided: IPCamera 12
No device identifier provided: IPCamera 13
No device identifier provided: IPCamera 14
No device identifier provided: IPCamera 15
No device identifier provided: IPCamera 16
channels.txt
deviceinfo.txt

@maciej-or
Copy link
Owner

ok thanks, info you provided is enough, someone submitted similar issue, it's related to non hikvision devices connected to NVR
it is on TODO list, will be fixed

@slawekzz
Copy link
Author

Ok, if you need any more data or test the solution, please let me know.

@maciej-or maciej-or added bug Something isn't working and removed logs needed This doesn't seem right labels May 30, 2023
@slawekzz
Copy link
Author

slawekzz commented Jun 15, 2023

After upgrading to 1.0.6, I was asked to configure the integration again. I deleted the current integration and redid it again. I received an "Unexpected error" error

Unexpected exception 'list' object has no attribute 'get'

@msp1974
Copy link
Contributor

msp1974 commented Jun 15, 2023

Can you provide output of this endpoint.

/ISAPI/System/capabilities

@slawekzz
Copy link
Author

capabilities.txt

@msp1974
Copy link
Contributor

msp1974 commented Jun 17, 2023

Hmm I cant see anything obvious. I am assuming that you get this error when you are adding the integration? Can you enable debug logging and provide the log output.

@slawekzz
Copy link
Author

Yes, I get this error when adding integrations. There is only one error in the log.

ERROR (MainThread) [custom_components.hikvision_next.config_flow] Unexpected exception All connection attempts failed

@slawekzz
Copy link
Author

Logger: custom_components.hikvision_next.config_flow
Source: custom_components/hikvision_next/config_flow.py:97
Integration: hikvision_next (documentation, issues)
First occurred: 13:23:40 (3 occurrences)
Last logged: 13:25:34

Unexpected exception 'list' object has no attribute 'get'

@slawekzz
Copy link
Author

I downgraded to 1.0.5. The reintegration was successful. I upgraded to 1.0.6 and got the following error:
Logger: homeassistant.config_entries
Source: config_entries.py:1247
First occurred: 14:10:42 (3 occurrences)
Last logged: 15:06:23

Config entry 'Network Video Recorder' for hikvision_next integration not ready yet: Unknown error connecting to http://192.168.101.240. Cannot initialize hikvision_next. Error is 'list' object has no attribute 'get'; Retrying in background

The HA and NVR are on a subnet with a /23 mask, but I don't think that's a problem.
HA 192.168.100.x/23
NVR 192.168.101.x/23
I've never had a problem with communication between hosts

@maciej-or
Copy link
Owner

Thanks for details, I'm sure it is detecting capabilities issue. There are inconsistencies in responses from different devices.

@maciej-or
Copy link
Owner

@slawekzz pls check if release v1.0.7 solves your problem

@slawekzz
Copy link
Author

It's still the same error
Config entry 'Network Video Recorder' for hikvision_next integration not ready yet: Unknown error connecting to http://192.168.101.240. Cannot initialize hikvision_next. Error is 'list' object has no attribute 'get'; Retrying in background

@msp1974
Copy link
Contributor

msp1974 commented Jun 29, 2023

Can you enable debug logging and post the log then. I wonder if this is related to the HDD sensor.

Add this to your configuration.yaml. reboot HA.

logger:
    logs:
        custom_components.hikvision_next: debug

@slawekzz
Copy link
Author

hikdebbug.log

@msp1974
Copy link
Contributor

msp1974 commented Jun 30, 2023

That's great. Yes it is an issue with loading the HDD info. Seems the structure of the data is not as expected. Are you able to replace some code in the isapi.py file with the below to see if this resolves it?

In isapi.py as line 475 you will see the get_storage_devices function. Can you replace with this, reboot and see if that works. You will have needed to ensure you are on v1.07 first. If this works, I'll ask @maciej-or to update it.

async def get_storage_devices(self):
        """Get HDD storage devices."""
        storage_list = []
        storage_info = (
            (await self.isapi.ContentMgmt.Storage(method=GET))
            .get("storage", {})
            .get("hddList", {})
        )

        if not isinstance(storage_info, list):
            storage_info = [storage_info]

        _LOGGER.debug(
            "%s/ISAPI/ContentMgmt/Storage %s", self.isapi.host, storage_info
        )

        for storage in storage_info:
            storage = storage.get("hdd")
            if not isinstance(storage, list):
                storage = [storage]
            if storage:
                for hdd in storage:
                    storage_list.append(
                        HDDInfo(
                            id=int(hdd.get("id")),
                            name=hdd.get("hddName"),
                            type=hdd.get("hddType"),
                            status=hdd.get("status"),
                            capacity=int(hdd.get("capacity")),
                            freespace=int(hdd.get("freeSpace")),
                            property=hdd.get("property"),
                        )
                    )

        return storage_list

@slawekzz
Copy link
Author

Yes, I have version 1.0.7. In the isapi.py file for me it is line 538. I replaced the indicated function with the one you sent and now everything works fine. Thank you.

@msp1974
Copy link
Contributor

msp1974 commented Jun 30, 2023

Great. @maciej-or can you update this function or do you want me to send a PR? I think this is the cause for a number who are getting the same error in start up.

@maciej-or
Copy link
Owner

I will update, thanks!

@slawekzz
Copy link
Author

slawekzz commented Jul 5, 2023

I got an error after upgrading to 1.0.8
Logger: homeassistant.setup
Source: setup.py:215
First occurred: 08:13:52 (1 occurrences)
Last logged: 08:13:52

Setup failed for custom integration hikvision_next: Unable to import component: cannot import name 'async_get_registry' from 'homeassistant.helpers.entity_registry' (/usr/src/homeassistant/homeassistant/helpers/entity_registry.py)

@slawekzz
Copy link
Author

slawekzz commented Jul 5, 2023

In version 1.0.9 it is ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants