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

"Input 1" switch for each camera is disable after update to version 1.1.0 #263

Closed
lebretr opened this issue Nov 27, 2024 · 4 comments
Closed
Labels
bug Something isn't working waiting for release Done and waiting for the next release

Comments

@lebretr
Copy link
Contributor

lebretr commented Nov 27, 2024

Hi,

After update, the "input 1" switch are disable

Previously, for my 2cd2346g2 camera, I had:

  • switch.ds_2cd2346g2_isu_sl20220518aawrj97621006_1_1_io
  • binary_sensor.ds_2cd2t86g2_isu_sl20230808aawrae5480155_1_1_io

Now I have only:

  • binary_sensor.ds_2cd2t86g2_isu_sl20230808aawrae5480155_1_io

Same thing for my 2 other cameras.

I tried to debug isapy.py and I think the pb is that:

  • I suppose when you have a nvr, you have only one "IO input" function on channel 0
  • In my case, I have 3 camera without NVR and so I have one "IO input" function for each camera, on channel 1 and port 1

I think (but I'm not sure) we should change this (line ~ 261 in get_event function):
from

            channel_id = 0
            io_port = 0
            is_proxy = False

            if event_id == EVENT_IO:
                io_port = int(event_trigger.get("inputIOPortID", 0))
                if not io_port:
                    io_port = int(event_trigger.get("dynInputIOPortID", 0))
                    is_proxy = io_port > 0
            else:
                channel_id = int(event_trigger.get("videoInputChannelID", 0))
                if not channel_id:
                    channel_id = int(event_trigger.get("dynVideoInputChannelID", 0))
                    is_proxy = channel_id > 0

to

            channel_id = 0
            io_port = 0
            is_proxy = False

            if event_id == EVENT_IO:
                io_port = int(event_trigger.get("inputIOPortID", 0))
                if not io_port:
                    io_port = int(event_trigger.get("dynInputIOPortID", 0))
                    is_proxy = io_port > 0
            
            if not self.device_info.is_nvr or event_id != EVENT_IO:
                channel_id = int(event_trigger.get("videoInputChannelID", 0))
                if not channel_id:
                    channel_id = int(event_trigger.get("dynVideoInputChannelID", 0))
                    is_proxy = channel_id > 0
@maciej-or
Copy link
Owner

Hi, I think before was wrong because IO events weren't detected properly as proxy (from devices connected by NVR) for example issue #206.
Standalone cameras have only own IO events so entities id are built according to {serial_no}_{input_port)_io
Don't you receive alarms for these events after update?

@lebretr
Copy link
Contributor Author

lebretr commented Nov 27, 2024

After more investigation, I think the pb is not in isapy.py but in switch.py.

You manage The IO input event at the device level, not at the camera level, but you create swithes for each "device.events_info" only if the device is a NVR

    if device.device_info.is_nvr:
        for event in device.events_info:
            entities.append(EventSwitch(0, event, events_coordinator))

@lebretr
Copy link
Contributor Author

lebretr commented Nov 27, 2024

I commented the "if line" and I tested directly on my HA with this:

    # if device.device_info.is_nvr:
    for event in device.events_info:
        entities.append(EventSwitch(0, event, events_coordinator))

The input switch is enable again and works again: When I active the switch in HA, I see that the alarm entry is active in Hikvision web console and the input sensor is active in H.A.

@maciej-or
Copy link
Owner

You are right, should be similar as I changed for binary_sensor:
https://github.com/maciej-or/hikvision_next/blob/main/custom_components/hikvision_next/binary_sensor.py#L32

@maciej-or maciej-or added the bug Something isn't working label Nov 27, 2024
lebretr added a commit to lebretr/hikvision_next that referenced this issue Nov 27, 2024
@maciej-or maciej-or added the waiting for release Done and waiting for the next release label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for release Done and waiting for the next release
Projects
None yet
Development

No branches or pull requests

2 participants