Announcement

Collapse
No announcement yet.

HikVision camera plugin for motion alerts - C# example

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Please see my post here and tell me what you think: https://forums.homeseer.com/showpost...1&postcount=19

    I'm trying to simplify HS development. Will definitely be incorporating the work done in this thread.

    Comment


      #17
      Originally posted by alexdresko View Post
      Please see my post here and tell me what you think: https://forums.homeseer.com/showpost...1&postcount=19

      I'm trying to simplify HS development. Will definitely be incorporating the work done in this thread.
      Noob here. I get the following error when I attempt to install the vsix:

      2/27/2017 7:30:35 AM - Install Error : Microsoft.VisualStudio.ExtensionManager.MissingReferencesExc eption: This extension cannot be installed because the following references are missing:
      - NuGet Package Manager for Visual Studio 2015

      Thoughts? Tried Google, failed

      Comment


        #18
        Originally posted by jon102034050 View Post
        Noob here. I get the following error when I attempt to install the vsix:

        2/27/2017 7:30:35 AM - Install Error : Microsoft.VisualStudio.ExtensionManager.MissingReferencesExc eption: This extension cannot be installed because the following references are missing:
        - NuGet Package Manager for Visual Studio 2015

        Thoughts? Tried Google, failed
        https://github.com/alexdresko/HSPI/issues/33

        Comment


          #19
          Originally posted by jon102034050 View Post
          Noob here. I get the following error when I attempt to install the vsix:

          2/27/2017 7:30:35 AM - Install Error : Microsoft.VisualStudio.ExtensionManager.MissingReferencesExc eption: This extension cannot be installed because the following references are missing:
          - NuGet Package Manager for Visual Studio 2015

          Thoughts? Tried Google, failed
          Tons of updates just now. The code from this thread has been incorporated into the framework and templates! See https://forums.homeseer.com/showpost...2&postcount=24

          Comment


            #20
            Holy crap, I actually got this to work.... Thanks for putting in the effort on this!

            Comment


              #21

              Comment


                #22
                The exe that you would put in the Homeseer directory is HSPI_HikAlarmCheck.exe, not HSPI_HikAlarmCheck.vshost.exe. You can also start running the plugin directly from Visual Studio in order to test/debug.

                Comment


                  #23
                  i cant wait for my c# class.. hah... but its far out..
                  HW - i5 4570T @2.9ghz runs @11w | 8gb ram | 128gb ssd OS - Win10 x64

                  HS - HS3 Pro Edition 3.0.0.435

                  Plugins - BLRF 2.0.94.0 | Concord 4 3.1.13.10 | HSBuddy 3.9.605.5 | HSTouch Server 3.0.0.68 | RFXCOM 30.0.0.36 | X10 3.0.0.36 | Z-Wave 3.0.1.190

                  Hardware - EdgePort/4 DB9 Serial | RFXCOM 433MHz USB Transceiver | Superbus 2000 for Concord 4 | TI103 X-10 Interface | WGL Designs W800 RF | Z-Net Z-Wave Interface

                  Comment


                    #24

                    Comment


                      #25
                      If the status is unknown, then the plugin is not connecting to the camera. This could be a user name or password issue. I assume that the cameras and the S6 Pro are on the same subnet. I use a Zotac Zbox CI232 mini PC running Windows 10 for my installation so I don't know the specifics of the S6 Pro.

                      It's probably easier to test by executing the plugin on your Surface Pro and have it remotely connect to the S6. The executable accepts a command line argument to specify the address of the server (server=XXX.XXX.XXX.XXX). From the Visual Studio environment, right click on the HSPI_HikAlarmCheck project (not the solution) and select Properties. In the new window, select Debug in the list on the left. In the Start Options, Command line arguments, enter "server=192.168.0.100" and set to the IP address for your S6. You may want to delete the plugin on the S6 and restart. From the menu select Debug, and Start Debugging. You should get a new window that will display some logging information that will indicate that the plugin has connected. From the HS3 web interface, go to Plug-Ins, Manage and you should see a new category for Remote Plug-Ins with HikAlarmCheck listed.

                      When you add a camera, the window on the Surface Pro will display some debug information that the plugin is generating.
                      • If it can't connect to a camera within about 20 seconds, it will display a message about a connection failure.
                      • If there is a user name or password failure, you will get a message about every 2 seconds indicating a connection and then an attempt to reconnect.
                      • If there have been too many connection failures, then my Hikvision cameras will lockout connections for 30 minutes.
                      • If the connection is successful, then it will indicate a connection and then an Inactive state.


                      To actually get a camera to detect motion, this has to be configured from the Hikvision web interface. This is under Advanced Configuration and Basic/Smart Event. For example, enable motion detection and then check the box under the linkage method for Trigger Channel.

                      Comment


                        #26
                        Thank you very much for the quick response. I will apply what you have provided along with more details on my local configuration as needed.

                        Comment


                          #27
                          I muddled through the debug test and I think I have identified the issue.

                          All cameras are on the same subnet.
                          All POE devices are supported by a dedicated POE switch.
                          Standard network drops are on a separate switch.
                          Both switches are connected to the main router.

                          Because I have needed to use port forwarding to access each camera, I have assigned each with an IP:Port address. It looks like including the port address as part of the IP when adding each camera is problematic.

                          Please note debug result.

                          Hik Alarm Check Plugin

                          Connecting to Homeseer at 192.168.1.11:10400 ...
                          connection to homeseer successful.

                          Camera: RefId: 513, IpAddress: 192.168.1.212:82, Username: XXXX, Password: XXXX
                          2017-03-10 18:53:32.781 IpAddress: 192.168.1.212:82, Unexpected Exception : System.FormatException: An invalid IP address was specified. ---> System.Net.Sockets.SocketException: An invalid argument was supplied
                          --- End of inner exception stack trace ---

                          There was additional debug info, each with the same invalid ip format exception.

                          Please let me know if I am on track or whether I should be looking elsewhere.

                          Thanks
                          Dave

                          Comment


                            #28
                            Please note, I used port forwarding because I was having some challenges accessing the Surveillance Station application on my QNAP unit. I believe I have resolved those issues so, as a test, I will change the ip on one camera, and delete out all other cameras that are defined in the plugin.

                            More data to follow.

                            Comment


                              #29
                              Ok..

                              I changed the IP on the 192.168.1.212 camera to 80.

                              On the S6 Pro, in the Hik plugin, I:
                              - deleted all cameras other than 192.168.1.212
                              - removed the port identifier on 192.168.1.212

                              Next, I
                              - stopped the HS3 app,
                              - deleted and readded the Hik.exe to the Homeseer directory on the S6 Pro
                              - restarted the app.

                              On the Surface Pro, I reran the debug. It successfully connected to the 192.168.1.212 camera but, there seems to be some legacy config because it is still looking for other cameras.

                              Of note, the cameras still have an unknown status in the device manager.

                              Comment


                                #30
                                Configuration data is stored in the HikAlarmCheck.ini file which is in the Config subdirectory of the HS3 application. So something like: C:\Program Files (x86)\HomeSeer HS3\Config\HikAlarmCheck.ini.

                                In the InitIO() method, it loops through the devices and looks for the ones that were created from this plugin. It then pulls the ipAddress, username, and password from the ini file based on the reference id.

                                So it shouldn't matter if there are old entries in the ini file. What matters is the devices that are part of the HS3 interface.

                                After the debug message "Connected to camera", you should get a debug message "Inactive".

                                My understanding is that this HikVision protocol is generic but maybe there are variants. The message processing is performed in HikAlarmThread.cs, method ProcessBuffer(). If it can't process the data, it should print a debug message. The two camera types that I have tested are DS-2CD3335-I and DS-2CD2432F-IW.

                                You could log more information in the ProcessBuffer() method or use WireShark to look at the raw TCP packets.

                                Comment

                                Working...
                                X