mezz64 / pyHik

Python wrapper for Hikvision camera event stream
MIT License
183 stars 51 forks source link

New gen Hikvision WIFI-Cam not usable with pyHik? #62

Closed chris-nite closed 4 years ago

chris-nite commented 4 years ago

The problem

So far even with the help of the community it is not possible to integrate a current generation Hikvision WIFI-Cam with Home Assistant through the Hikvision-Integration. The camera itself is properly configured based on the recommendations with base/digest-Support for all authentication-methods, CGI-Integration enabled (even if not need), motion detection-functions enabled with "Notify to Surveillance Station" (with defined zones) and a proper operator-account "hassio-mgmt" with more than needed rights (for test purposes). The password itself is 16 characters long (maximum of supported length of the cam). When i restart Home Assistant i can see on the cameras webinterface, that the hassio_mgmt-Useraccount is properly connected (see attached screenshots, the IP of homeassistant is the 192.168.150.10), but there are no binary sensors getting created.

Environment

Problem-relevant configuration.yaml

binary_sensor:
- platform: hikvision
    name: hikcamfront
    host: 192.168.160.200
    port: 80
    ssl: false
    username: hassio_mgmt
    password: <PW>

Traceback/Error logs

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 446, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/response.py", line 71, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
[2020-07-18]05:11:10 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:10 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:11 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:11 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:12 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:12 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:15 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:27 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:28 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:28 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:28 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:29 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'
2020-07-18 05:11:32 ERROR (Thread-5) [pyhik.hikvision] Problem finding attribute: 'duration'

Additional information

mezz64 commented 4 years ago

Can you define debug logging for the hikvision parts (example below) and post a full log from startup?

logs:
   pyhik.hikvision: debug
   homeassistant.components.binary_sensor.hikvision: debug
chris-nite commented 4 years ago

Here you go:

2020-07-21 11:05:31 DEBUG (SyncWorker_0) [pyhik.hikvision] pyHik 0.2.7 initializing new hikvision device at: http://192.168.160.200
2020-07-21 11:05:31 DEBUG (SyncWorker_0) [pyhik.hikvision] Using Namespace: http://www.hikvision.com/ver20/XMLSchema
2020-07-21 11:05:31 DEBUG (SyncWorker_0) [pyhik.hikvision] No Events available in dictionary.
2020-07-21 11:05:57 DEBUG (Thread-5) [pyhik.hikvision] Stream Thread Started: hikcam-wifi-front.cam.local, 55b24000-6192-11b3-819c-5850ed21f09b
2020-07-21 11:05:57 DEBUG (Thread-5) [pyhik.hikvision] hikcam-wifi-front.cam.local Connection Successful.

Note: That hikvision-XML-Schema-address doesn't seem to be accessible anymore. (404) Thank you

mezz64 commented 4 years ago

It's not finding any events so either the path is incorrect or they've modified the XML namespace yet again. Can you run a curl on the expected path and post the output? Change that last flag if you're not using digest auth.

curl http://YOUR_CAM_IP/ISAPI/Event/triggers --digest
chris-nite commented 4 years ago

Okay, i did that (with login-creds ofc) and got the following output:

<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<requestURL>/ISAPI/Event/triggers</requestURL>
<statusCode>3</statusCode>
<statusString>Device Error</statusString>
<subStatusCode>deviceError</subStatusCode>
</ResponseStatus>
mezz64 commented 4 years ago

I've not seen that kind of error before, but try this path instead:

http://YOUR_CAM_IP/Event/triggers

If you get something similar, or a 404 on that one, are you 100% sure you are using a user that has administrative access? There have been others in the past with some odd behavior that turned out to be permissions related. Do you still have the original admin user account to test against?

chris-nite commented 4 years ago

Here's the output of that:

<?xml version="1.0" encoding="UTF-8"?>
<EventTriggerList version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<id>1</id>
<eventType>VMD</eventType>
<eventDescription>VMD Event trigger Information</eventDescription>
<EventTriggerNotificationList version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<EventTriggerNotification>
<id>3</id>
<notificationMethod>HTTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
</EventTriggerList>

Btw. i'll get the same exact output from my comment before with the main-admin-account. without any creds i'll get the usual "Unauthorized" so, i guess everything should be actually in place. I gave the user, which i currently test with maximum rights right from the start, so there wouldn't be any problems. i can always lock down settings, but i wanted to get this functioning first, before reducing it to minimum necessary rights. Anyway thank you very much for all your time in helping me out with this out. i greatly appreciate it. :-)

chris-nite commented 4 years ago

As far as i can see it ISAPI V2.4 is the current version and should be in all G3-models of Hikvision (which is mine). Unfortunately i was not able to track down some good documentation about it, to find out where the differences are...

mezz64 commented 4 years ago

ok, now we're getting somewhere. It would seem that rather than return a connection error on the first endpoint like the old cameras they are now issuing that device error response. We can work around that.

In the interest of getting ahead of the next potential problem, can you run a curl on the event stream endpoint when a motion event is being tripped and supply the output?

I'd expect the first one to work, but please try both and let me know what the outputs are.

curl --digest -N http://YOUR_CAM_IP/Event/notification/alertStream
or
curl --digest -N http://YOUR_CAM_IP/ISAPI/Event/notification/alertStream
chris-nite commented 4 years ago

Okay here's the output for the first curl-cmd (Event/notification/alertStream). My Field- and Linedetection-Functions were going off for a little bit. (including object detection human)

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:12+02:00</dateTime>
<activePostCount>0</activePostCount>
<channelName></channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 1170

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:18+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>fielddetection</eventType>
<eventState>active</eventState>
<eventDescription>fielddetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>1</regionID>
<sensitivityLevel>50</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>434</positionX>
<positionY>661</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>600</positionX>
<positionY>574</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>477</positionX>
<positionY>557</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>340</positionX>
<positionY>606</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
<detectionTarget>human</detectionTarget>
</DetectionRegionEntry>
</DetectionRegionList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 970

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:19+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>linedetection</eventType>
<eventState>active</eventState>
<eventDescription>linedetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>1</regionID>
<sensitivityLevel>50</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>416</positionX>
<positionY>667</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>588</positionX>
<positionY>586</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
<detectionTarget>human</detectionTarget>
</DetectionRegionEntry>
</DetectionRegionList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:19+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:19+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:19+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:20+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:20+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:20+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:21+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:21+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:22+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:23+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 613

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:23+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 522

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:23+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>fielddetection</eventType>
<eventState>inactive</eventState>
<eventDescription>fielddetection alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 520

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:30:24+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>linedetection</eventType>
<eventState>inactive</eventState>
<eventDescription>linedetection alarm</eventDescription>
</EventNotificationAlert>

and the second one /ISAPI/Event/notification/alertStream

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:38:29+02:00</dateTime>
<activePostCount>0</activePostCount>
<channelName></channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 512

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:38:39+02:00</dateTime>
<activePostCount>0</activePostCount>
<channelName></channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 512

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:38:49+02:00</dateTime>
<activePostCount>0</activePostCount>
<channelName></channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 970

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.160.200</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>58:50:ed:21:f0:9b</macAddress>
<channelID>1</channelID>
<dateTime>2020-07-23T18:38:55+02:00</dateTime>
<activePostCount>1</activePostCount>
<channelName></channelName>
<eventType>linedetection</eventType>
<eventState>active</eventState>
<eventDescription>linedetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>1</regionID>
<sensitivityLevel>50</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>416</positionX>
<positionY>667</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>588</positionX>
<positionY>586</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
<detectionTarget>human</detectionTarget>
</DetectionRegionEntry>
</DetectionRegionList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 520
mezz64 commented 4 years ago

I just pushed some changes to a new "newcamfix" branch of the library that I think should take care of the issue. I can't test on my own so please give it a shot and let me know if it works.

https://github.com/mezz64/pyHik/tree/newcamfix

chris-nite commented 4 years ago

Thank you mezz64, can you maybe give me some instructions, how i can test out your newcamfix-branch on my local home assistant server? Do i just need to insert the pyhik folder in custom-components, or do i need to swap out main files from hassio? Thanks in advance!

mezz64 commented 4 years ago

You need to find the pyhik package folder in hass.io and swap out the 'hikvision.py' file. I'm not that familiar with the file structure they use but I'd expect it's something like this: '/usr/lib/python3.8/site-packages/pyhik'

wraggzeh commented 4 years ago

Hi mezz64,

I seem to be having the same issues with my ACUSENSE Cameras. Model: DS-2CD2386G2-I

I have tried running your "newcamfix" branch to no avail.

Gathered a couple of outputs for you below.

Give me a shout if you want me to grab anything further! Thanks in advance!

Logs:

2020-08-30 18:22:09 DEBUG (SyncWorker_1) [pyhik.hikvision] pyHik 0.2.4 initializing new hikvision device at: http://10.0.70.253
2020-08-30 18:22:09 DEBUG (SyncWorker_1) [pyhik.hikvision] Using Namespace: http://www.hikvision.com/ver20/XMLSchema
2020-08-30 18:22:09 DEBUG (SyncWorker_1) [pyhik.hikvision] No Events available in dictionary.
2020-08-30 18:22:14 DEBUG (Thread-2) [pyhik.hikvision] Stream Thread Started: cam01, 0f54c000-440e-11b5-8402-849a40b17cae
2020-08-30 18:22:14 DEBUG (Thread-2) [pyhik.hikvision] cam01 Connection Successful.

curl --digest -N http://YOUR_CAM_IP/ISAPI/Event/notification/alertStream

--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:13+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:23+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:33+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:43+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 974

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:44+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>linedetection</eventType>
<eventState>active</eventState>
<eventDescription>linedetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>2</regionID>
<sensitivityLevel>50</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>774</positionX>
<positionY>936</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>295</positionX>
<positionY>204</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
<detectionTarget>human</detectionTarget>
</DetectionRegionEntry>
</DetectionRegionList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 617

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:46+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 1174

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:47+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>fielddetection</eventType>
<eventState>active</eventState>
<eventDescription>fielddetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>1</regionID>
<sensitivityLevel>35</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>233</positionX>
<positionY>170</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>488</positionX>
<positionY>131</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>984</positionX>
<positionY>664</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>360</positionX>
<positionY>989</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
<detectionTarget>human</detectionTarget>
</DetectionRegionEntry>
</DetectionRegionList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 617

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:47+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 617

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:47+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 617

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:47+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 524

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:49+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>linedetection</eventType>
<eventState>inactive</eventState>
<eventDescription>linedetection alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 526

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:51+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>fielddetection</eventType>
<eventState>inactive</eventState>
<eventDescription>fielddetection alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:28:01+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>

curl --digest -N http://YOUR_CAM_IP/Event/notification/alertStream

Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:01+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:11+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:21+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:31+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:42+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 974

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:45+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>linedetection</eventType>
<eventState>active</eventState>
<eventDescription>linedetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>2</regionID>
<sensitivityLevel>50</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>774</positionX>
<positionY>936</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>295</positionX>
<positionY>204</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
<detectionTarget>human</detectionTarget>
</DetectionRegionEntry>
</DetectionRegionList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 617

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:46+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 1174

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:46+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>fielddetection</eventType>
<eventState>active</eventState>
<eventDescription>fielddetection alarm</eventDescription>
<DetectionRegionList>
<DetectionRegionEntry>
<regionID>1</regionID>
<sensitivityLevel>35</sensitivityLevel>
<RegionCoordinatesList>
<RegionCoordinates>
<positionX>233</positionX>
<positionY>170</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>488</positionX>
<positionY>131</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>984</positionX>
<positionY>664</positionY>
</RegionCoordinates>
<RegionCoordinates>
<positionX>360</positionX>
<positionY>989</positionY>
</RegionCoordinates>
</RegionCoordinatesList>
<detectionTarget>human</detectionTarget>
</DetectionRegionEntry>
</DetectionRegionList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 617

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:47+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 617

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:47+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 617

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:47+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>duration</eventType>
<eventState>active</eventState>
<eventDescription>duration alarm</eventDescription>
<DurationList>
<Duration>
<relationEvent>fielddetection</relationEvent>
</Duration>
</DurationList>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 524

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:49+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>linedetection</eventType>
<eventState>inactive</eventState>
<eventDescription>linedetection alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 526

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:27:51+01:00</dateTime>
<activePostCount>1</activePostCount>
<channelName>Driveway</channelName>
<eventType>fielddetection</eventType>
<eventState>inactive</eventState>
<eventDescription>fielddetection alarm</eventDescription>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 516

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>10.0.70.252</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>84:9a:40:b1:7c:ae</macAddress>
<channelID>1</channelID>
<dateTime>2020-08-30T18:28:01+01:00</dateTime>
<activePostCount>0</activePostCount>
<channelName>Driveway</channelName>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
mezz64 commented 4 years ago

@wraggzeh are those logs from the newcamfix branch? What is the output from this endpoint with your cam?

curl http://YOUR_CAM_IP/ISAPI/Event/triggers --digest
wraggzeh commented 4 years ago

@mezz64 Yeah, those logs are from the newcamfix branch. Output below:

<requestURL>/ISAPI/Event/triggers</requestURL>
<statusCode>3</statusCode>
<statusString>Device Error</statusString>
<subStatusCode>deviceError</subStatusCode>
</ResponseStatus>
mbedk commented 4 years ago

I have the same issue with new acusense cameras. Any updates to this?

mezz64 commented 4 years ago

Sorry guys, I haven't had much free time as of late. Hoping to find some this month. I'll post here once I make some updates.

mbedk commented 4 years ago

@mezz64 Let me know if I can support you in any way. Would love to be able to use the events from these new cameras in HA.

giovanidevisch commented 4 years ago

I have the same problem. HIKVISION DS-2CD2386G2-I Acusense. How can i help?

mezz64 commented 4 years ago

@wraggzeh @mbedk @giovanidevisch Please test out the latest commit on the newcamfix branch to see if it fixes the issue. I refactored things to track a namespace for each endpoint. https://github.com/mezz64/pyHik/tree/newcamfix

wraggzeh commented 4 years ago

Hi @mezz64 -- I have tried the newcamfix branch, but it still doesn't seem to be adding any Binary Sensors into Hassio unfortunately.

I have added the debug logs from Hassio below, but if you need any further logs from the camera itself, please give me a shout.

2020-10-24 08:58:06 DEBUG (SyncWorker_3) [pyhik.hikvision] pyHik 0.2.7 initializing new hikvision device at: http://10.0.70.252
2020-10-24 08:58:06 DEBUG (SyncWorker_3) [pyhik.hikvision] Device info namespace: http://www.hikvision.com/ver20/XMLSchema
2020-10-24 08:58:06 DEBUG (SyncWorker_3) [pyhik.hikvision] No Events available in dictionary.
2020-10-24 08:58:06 DEBUG (SyncWorker_3) [pyhik.hikvision] Device motion namespace: http://www.hikvision.com/ver20/XMLSchema
2020-10-24 08:58:07 DEBUG (Thread-5) [pyhik.hikvision] Stream Thread Started: cam01, 0f54c000-440e-11b5-8402-849a40b17cae
2020-10-24 08:58:07 DEBUG (Thread-5) [pyhik.hikvision] cam01 Connection Successful.
2020-10-24 08:58:17 DEBUG (Thread-5) [pyhik.hikvision] Device alerts namespace: http://www.hikvision.com/ver20/XMLSchema
mezz64 commented 4 years ago

@wraggzeh Please check it again. I oversimplified a bit on the trigger namespace check and it was missing the error response the new cams output. Hopefully the new commit fixes that.

wraggzeh commented 4 years ago

@mezz64 I can't see a new commit to the newcamfix branch after the one 12hrs ago.

mezz64 commented 4 years ago

@wraggzeh Sorry, I forgot to push it. Take a look now.

wraggzeh commented 4 years ago

@mezz64 No problem - got it. Unfortunately still nothing in Hassio.

2020-10-24 18:36:06 DEBUG (SyncWorker_4) [pyhik.hikvision] pyHik 0.2.7 initializing new hikvision device at: http://10.0.70.252
2020-10-24 18:36:06 DEBUG (SyncWorker_4) [pyhik.hikvision] Device info namespace: http://www.hikvision.com/ver20/XMLSchema
2020-10-24 18:36:06 DEBUG (SyncWorker_4) [pyhik.hikvision] No Events available in dictionary.
2020-10-24 18:36:06 DEBUG (SyncWorker_4) [pyhik.hikvision] Device motion namespace: http://www.hikvision.com/ver20/XMLSchema
2020-10-24 18:36:06 DEBUG (Thread-3) [pyhik.hikvision] Stream Thread Started: cam01, 0f54c000-440e-11b5-8402-849a40b17cae
2020-10-24 18:36:06 DEBUG (Thread-3) [pyhik.hikvision] cam01 Connection Successful.
2020-10-24 18:36:16 DEBUG (Thread-3) [pyhik.hikvision] Device alerts namespace: http://www.hikvision.com/ver20/XMLSchema
mezz64 commented 4 years ago

@wraggzeh Ok, I just pushed another commit with a bunch of debug log lines to try to get a better idea of what is happening. Please try again and post your log output.

wraggzeh commented 4 years ago

@mezz64 Logs below - appreciate you doing this.

2020-10-24 18:54:05 DEBUG (SyncWorker_21) [pyhik.hikvision] pyHik 0.2.7 initializing new hikvision device at: http://10.0.70.252
2020-10-24 18:54:05 DEBUG (SyncWorker_21) [pyhik.hikvision] Device info namespace: http://www.hikvision.com/ver20/XMLSchema
2020-10-24 18:54:05 DEBUG (SyncWorker_21) [pyhik.hikvision] TRIGGERS - Starting to look...
2020-10-24 18:54:05 DEBUG (SyncWorker_21) [pyhik.hikvision] TRIGGERS - First request completed
2020-10-24 18:54:05 DEBUG (SyncWorker_21) [pyhik.hikvision] No Events available in dictionary.
2020-10-24 18:54:05 DEBUG (SyncWorker_21) [pyhik.hikvision] Device motion namespace: http://www.hikvision.com/ver20/XMLSchema
2020-10-24 18:54:06 DEBUG (Thread-3) [pyhik.hikvision] Stream Thread Started: cam01, 0f54c000-440e-11b5-8402-849a40b17cae
2020-10-24 18:54:06 DEBUG (Thread-3) [pyhik.hikvision] cam01 Connection Successful.
2020-10-24 18:54:16 DEBUG (Thread-3) [pyhik.hikvision] Device alerts namespace: http://www.hikvision.com/ver20/XMLSchema
mezz64 commented 4 years ago

@wraggzeh No problem, finally have some time to get this squashed, thanks for testing.

I think i've narrowed it down to the response code. Can you run a curl like this and post the output. The -i is the important part so I can see the response code. It seems like it isn't a 200 like I expected.

curl -i -u USERNAME http://CAM_IP/ISAPI/Event/triggers --digest
wraggzeh commented 4 years ago

@mezz64 No problem, logs below:

HTTP/1.1 401 Unauthorized
Date: Sat, 24 Oct 2020 19:20:27 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 178
Content-Type: text/html
Connection: close
WWW-Authenticate: Digest qop="auth", realm="IP Camera(D7334)", nonce="4e6d45344f47466d4e444d364e574d775a5445775a5463364d5441754d4334324d4334784d444d3d", stale="FALSE"
WWW-Authenticate: Basic realm="IP Camera(D7334)"

HTTP/1.1 500 Internal Server Error
Date: Sat, 24 Oct 2020 19:20:27 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 295
Connection: close
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8"?><ResponseStatus version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<requestURL>/ISAPI/Event/triggers</requestURL>
<statusCode>3</statusCode>
<statusString>Device Error</statusString>
<subStatusCode>deviceError</subStatusCode>
</ResponseStatus>
mezz64 commented 4 years ago

@wraggzeh Thanks. I just pushed another commit to change the response code check. Give it a try and let me know how it goes.

wraggzeh commented 4 years ago

@mezz64 Its getting further now! So I can see the Motion Detection Binary Sensor, but not the Line Cross ones. Images/Logs attached.

image

image

image

2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] pyHik 0.2.7 initializing new hikvision device at: http://10.0.70.252
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] Device info namespace: http://www.hikvision.com/ver20/XMLSchema
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] TRIGGERS - Starting to look...
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] Trying alternate triggers URL.
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] TRIGGERS - Starting to look...
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] TRIGGERS - First request completed
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] TRIGGERS - Processing XML...
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] TRIGGERS - Fetching namespace...
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] TRIGGERS - Namespace found: http://www.hikvision.com/ver10/XMLSchema
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] Device triggers namespace: http://www.hikvision.com/ver10/XMLSchema
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] Processed 0f54c000-440e-11b5-8402-849a40b17cae as CAM Device.
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] Found events: {'VMD': [1]}
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] Initialized Dictionary: {'Motion': [[False, 1, 0, datetime.datetime(2020, 10, 24, 19, 43, 35, 548171)]]}
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] Device motion namespace: http://www.hikvision.com/ver20/XMLSchema
2020-10-24 19:43:35 DEBUG (SyncWorker_8) [pyhik.hikvision] Added update callback to <bound method HikvisionBinarySensor._update_callback of <Entity cam01 Motion: off>> on 0f54c000-440e-11b5-8402-849a40b17cae.Motion.1
2020-10-24 19:43:36 DEBUG (Thread-5) [pyhik.hikvision] Stream Thread Started: cam01, 0f54c000-440e-11b5-8402-849a40b17cae
2020-10-24 19:43:36 DEBUG (Thread-5) [pyhik.hikvision] cam01 Connection Successful.
2020-10-24 19:43:46 DEBUG (Thread-5) [pyhik.hikvision] Device alerts namespace: http://www.hikvision.com/ver20/XMLSchema
mezz64 commented 4 years ago

@wraggzeh Are you sure you have the line crossing alerts set to alert the notification center?

Can you post the output of your triggers xml:

curl -i -u USERNAME http://CAM_IP/Event/triggers --digest
wraggzeh commented 4 years ago

@mezz64 Yeah, its definitely on to Notify Surveillance Centre (Screenshot below)

image

HTTP/1.1 401 Unauthorized
Date: Sat, 24 Oct 2020 19:54:05 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 261
Content-Type: text/html
Connection: close
WWW-Authenticate: Digest qop="auth", realm="IP Camera(D7334)", nonce="4d6a4e684d6d5979597a55364e574d795932526d4e6d51364d5441754d4334324d4334784d444d3d", stale="FALSE"
WWW-Authenticate: Basic realm="IP Camera(D7334)"

HTTP/1.1 200 OK
Date: Sat, 24 Oct 2020 19:54:05 GMT
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 1406
Connection: close
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8"?>
<EventTriggerList version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<id>1</id>
<eventType>VMD</eventType>
<eventDescription>VMD Event trigger Information</eventDescription>
<EventTriggerNotificationList version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<EventTriggerNotification>
<id>2</id>
<notificationMethod>record</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
<EventTriggerNotification>
<id>3</id>
<notificationMethod>HTTP</notificationMethod>
<notificationRecurrence>beginning</notificationRecurrence>
</EventTriggerNotification>
</EventTriggerNotificationList>
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
<EventTrigger version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
</EventTrigger>
</EventTriggerList>
mezz64 commented 4 years ago

@wraggzeh That's odd, only the VMD trigger is showing up in the list returned by the camera. Are your settings for linkage any different between the motion detection and the line detection?

wraggzeh commented 4 years ago

@mezz64 The only thing that was different was the fact that the Line Cross linked into a trigger recording. This was outdated for me, so I have deleted that link, but the output from the curl was exactly the same.

Could the Line Cross information be in a different location?

mezz64 commented 4 years ago

So it would seem per the api docs available that the non ISAPI endpoint that works on you camera only supports listing basic events: image

It's possible there is a new endpoint that lists all of them, but I haven't been able to locate any updated API documentation as of yet that would list them. One thing worth a shot, how do you have authentication defined on the camera? I did see some mentions that the ISAPI endpoint only works when the cam authentication is set to digest/basic.

Since this does currently provide partial functionality, i'm probably going to merge in as it stands later today and start the process of getting things updated in HASS. If a new endpoint can't be located the other option is to allow the user to provide an event list that can be parsed against everything in the alertStream. That will require a bunch of changes in pyHik and the HASS component though so it's not something i'll be able to get to quickly.

mezz64 commented 4 years ago

@wraggzeh In addition to the auth method, also try creating a new user on the camera using an operator role and selecting the appropriate roles if you are currently testing with the default admin account.

It seems like the ISAPI endpoint should be there, it's just picky about allowing access.

mbedk commented 4 years ago

I've read that people with Synology NAS devices using the Surveillance Station package are able to use the new smart events. https://www.synology.com/da-dk/releaseNote/SurveillanceStation

wraggzeh commented 4 years ago

@mezz64 Not a problem - I appreciate the work nonetheless. I will use the basic events for the time being.

I tried another account but this made no difference unfortunately. The authentication was already set to digest/basic - but I did change it back to digest as a test to no avail.

mezz64 commented 4 years ago

I'll open a new issue to track capturing events without processing the trigger endpoint and close this one to keep things separated. Thanks for all the testing help @wraggzeh.

rgaufman commented 3 months ago

What does "duration alarm" mean?