Add support for multi-channel thermal cameras without NVR #239
+424
−187
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.