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

Add support for multi-channel thermal cameras without NVR #239

Closed
wants to merge 3 commits into from

Conversation

sebastian-enz
Copy link
Contributor

This pull request enhances the Hikvision integration in Home Assistant to support thermal cameras that have multiple channels but are not NVRs (Network Video Recorders). These devices require special handling because they present multiple channels without the typical NVR configuration.

Changes Made:

Updated AnalogCamera and IPCamera Classes:

Added a new attribute channel_id to the AnalogCamera and IPCamera data classes in isapi.py. This attribute maps the correct channel_id for each camera, which is essential for devices with multiple channels.

Modified get_cameras Method in isapi.py:

Rewrote the logic for devices that are not identified as NVRs to fetch all available channels.
The method now retrieves the list of streaming channels and extracts unique channel_ids.
For each channel, it creates a corresponding camera instance (IPCamera), ensuring each channel is correctly represented.

Adjusted Event Handling in isapi.py:

Updated the get_device_event_capabilities method to correctly handle events based on the new channel_id mapping.
Modified the get_event_url method to build the correct ISAPI URL for events, taking into account the proper channel_id.

Updated trigger_sensor Method in notifications.py:

Adjusted the logic to construct the unique_id for entities by including the channel_id when there are multiple channels.
This ensures that events are correctly associated with the corresponding camera entity in Home Assistant.

How It Works:

Camera Detection:

The integration now checks for multiple channels even if the device is not an NVR.
It fetches the list of streaming channels from the device via the ISAPI interface.
For each detected channel, it creates a camera entity with a unique serial_no and channel_id.

Event Handling:

Events are now correctly mapped to their respective channels using the channel_id.
The event URLs and unique identifiers are constructed to reflect the correct channel, ensuring accurate event detection and handling.

What This Achieves:

Enhanced Device Support:

Users with multi-channel thermal cameras (without NVRs) can now fully integrate their devices with Home Assistant.
Each channel of the camera is recognized as a separate entity, allowing for individual configuration and control.

Accurate Event Mapping:

Events triggered on specific channels are accurately reflected in Home Assistant, improving reliability and user experience.
This ensures that automation and notification systems can respond correctly to events from different channels.

@maciej-or maciej-or changed the base branch from main to dev November 9, 2024 13:17
@maciej-or
Copy link
Owner

maciej-or commented Nov 9, 2024

please merge into current dev branch, I did some refactoring to separate isapi from the integration code. I think xml logs are redundant if we have the same in json
pls add tests as well, ask if you need help

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 this pull request may close these issues.

None yet

2 participants