IpCamera: New IP Camera Binding

camera
ip-cam
onvif
Tags: #<Tag:0x00007fd30f1d1ef8> #<Tag:0x00007fd30f1d1d40> #<Tag:0x00007fd30f1d1bd8>

(Skinah) #141

You can watch the log in realtime by running this in linux if you SSH in.

tail -f /var/log/openhab2/openhab.log

CTRL + C will stop the output.

The other way would be to delete the log file and it will then get re-created when openhab trys to write to the file. You then have a fresh file that is much smaller.


(Arsalan Alli) #142

@matt1 " http://172.29.8.70/MotionDetection/1" link shows a blank page for a brief period and then displays “This site can not be reached”
and still the state of “Enable/Disable motion alarm” and “Motion alarm” is not changing…

Something else I noticed in your log output is the camera did reply and it appeared that your camera gave corrupted output.

So should test it with another camera !?

another thing i noted is that when i disable the motion alarm it re-enables itself again even if “motion detection” is disabled in the camera…


(Sergey) #143

I tried to access from the browser link.

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>172.18.2.13</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>94:e1:ac:11:cd:86</macAddress>
<channelID>1</channelID>
<dateTime>2018-05-22T12:21:19+03:00</dateTime>
<activePostCount>0</activePostCount>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
<channelName>Cam-1</channelName>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 513

<EventNotificationAlert version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<ipAddress>172.18.2.13</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>94:e1:ac:11:cd:86</macAddress>
<channelID>1</channelID>
<dateTime>2018-05-22T12:21:29+03:00</dateTime>
<activePostCount>0</activePostCount>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
<channelName>Cam-1</channelName>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 513


(Skinah) #144

@toroid
That is helpful and shows the same as your log does. Your camera responds to both URLs with XML output.

The binding is waiting for this to change the alarm.

<eventType>VMD</eventType>
<eventState>active</eventState>

Until the binding sees this, the alarm state will not change. Maybe it is a setting that needs to change on the camera? I don’t know.

@gman Are you able to test the latest build and flip the test switch whilst movement is occurring on the camera please?


(Arsalan Alli) #145

@matt1

With Digest Auth it is 100% normal and ok to see every second request to the camera to be a 401 unauthorized error, if you read the logs you will see the binding detects this and sends the request a second time with the special encyption NONCE key and then you see a 200 OK reply.

Why it is continuously generating the Debug log messages!! should’t it generate the logs only in case of motion or image updation !!! and i cant seem to disable “Enable/disable alarm” button.
image


(Sergey) #146

@matt When the motion alarm is triggered, the following entry appears:

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>172.18.2.13</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>94:e1:ac:11:cd:86</macAddress>
<channelID>1</channelID>
<dateTime>2018-05-22T13:04:35+03:00</dateTime>
<activePostCount>16</activePostCount>
<eventType>VMD</eventType>
<eventState>active</eventState>
<eventDescription>Motion alarm</eventDescription>
<DetectionRegionList>
</DetectionRegionList>
<channelName>Cam-1</channelName>
</EventNotificationAlert>
--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 513

(Skinah) #147

If you want a lower level of logs then set it to INFO and not DEBUG using the same method you changed it to debug with. Debug is for watching everything that is going on to find issues aka finding bugs, debug.

@toroid
Excellent news, so does the binding change when it sees this? What was stopping it from showing up before? It seems safe to make this automatic in the next build.


(Arsalan Alli) #148

http://192.168.1.108/ISAPI/Event/notification/alertStream
http://192.168.1.108/Event/notification/alertStream

I used the same links to check my output. and it is showing same as @toroid’s


(Sergey) #149

@matt1 I switched the test code off to on and back and I finally worked motion alarm :slight_smile: in the log the following entries:

:
2018-05-22 13:16:56.909 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:172.18.2.13
2018-05-22 13:16:56.918 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/ISAPI/Event/notification/alertStream:
2018-05-22 13:16:56.925 [DEBUG] [ipcamera.internal.MyNettyAuthHandler] - 401: This reply from the camera is normal if it needs Basic or Digest auth details.
2018-05-22 13:16:56.928 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to connect with new request for camera at IP:172.18.2.13
2018-05-22 13:16:56.936 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - + The request is going to be GET:/ISAPI/Event/notification/alertStream:
2018-05-22 13:16:56.944 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 200 OK
MIME-Version: 1.0
Connection: close
Content-Type: multipart/mixed; boundary=boundary
2018-05-22 13:16:56.948 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 632, cap: 632/632, unwrapped: PooledUnsafeDirectByteBuf(ridx: 739, widx: 739, cap: 1024)), decoderResult: success)
2018-05-22 13:16:56.951 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is :--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 549

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>172.18.2.13</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>94:e1:ac:11:cd:86</macAddress>
<channelID>1</channelID>
<dateTime>2018-05-22T13:16:56+03:00</dateTime>
<activePostCount>1</activePostCount>
<eventType>VMD</eventType>
<eventState>active</eventState>
<eventDescription>Motion alarm</eventDescription>
<DetectionRegionList>
</DetectionRegionList>
<channelName>Cam-1</channelName>
</EventNotificationAlert>
:

(Arsalan Alli) #150

I switched the test code off to on and back and I finally worked motion alarm :slight_smile: in the log the following entries

Same thing happened with me. when i kept toggling the new code button fast enough, it detected the motion and state of motion alarm button changed.
but this state is not reverting back.
image

strange thing i noticed in logs is that when i toggle the new code button once in a while it goes to check ISAPI/Event/notification/alertStream.


Rest of the time (without testcode button toggling) it just checks GET:/MotionDetection/1:


(Skinah) #151

OK I have done another build with HikAuto on the end, this one should not need to have the test button pushed as it will now poll the camera. I also made another slight change which should not break anything as it will speed up polling with HIK.

@ArsalanAlli
http://172.29.8.70/MotionDetection/1
if the above url does not work for you maybe try this one
/ISAPI/Event/schedules/motionDetections
Try it in a browser and what you are looking for is

<enabled>true</enabled>

Without finding a working way to see if the motion alarm is turned on or off, the binding will also not be able to turn it on and off. HIK uses a very big pain in the butt way that requires you to fetch the XML, you edit it and then send it back to the camera to change the settings. This is why I could not start adding the support Sergey is asking for until I reached this point.

There is an API linked in the first post for hikvision, go through the links and see if you can find one that works. Often they have more than 1 url that does the same thing.


(Arsalan Alli) #152

Below is the output of

/ISAPI/Event/schedules/motionDetections

<?xml version="1.0" encoding="UTF-8" ?> 
- <MotionDetectionScheduleList version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
- <Schedule version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
  <id>VMD_video1</id> 
  <eventType>VMD</eventType> 
  <videoInputChannelID>1</videoInputChannelID> 
- <TimeBlockList size="8">
- <TimeBlock>
  <dayOfWeek>1</dayOfWeek> 
- <TimeRange>
  <beginTime>00:00</beginTime> 
  <endTime>24:00</endTime> 
  </TimeRange>
  </TimeBlock>
- <TimeBlock>
  <dayOfWeek>2</dayOfWeek> 
- <TimeRange>
  <beginTime>00:00</beginTime> 
  <endTime>24:00</endTime> 
  </TimeRange>
  </TimeBlock>
- <TimeBlock>
  <dayOfWeek>3</dayOfWeek> 
- <TimeRange>
  <beginTime>00:00</beginTime> 
  <endTime>24:00</endTime> 
  </TimeRange>
  </TimeBlock>
- <TimeBlock>
  <dayOfWeek>4</dayOfWeek> 
- <TimeRange>
  <beginTime>00:00</beginTime> 
  <endTime>24:00</endTime> 
  </TimeRange>
  </TimeBlock>
- <TimeBlock>
  <dayOfWeek>5</dayOfWeek> 
- <TimeRange>
  <beginTime>00:00</beginTime> 
  <endTime>24:00</endTime> 
  </TimeRange>
  </TimeBlock>
- <TimeBlock>
  <dayOfWeek>6</dayOfWeek> 
- <TimeRange>
  <beginTime>00:00</beginTime> 
  <endTime>24:00</endTime> 
  </TimeRange>
  </TimeBlock>
- <TimeBlock>
  <dayOfWeek>7</dayOfWeek> 
- <TimeRange>
  <beginTime>00:00</beginTime> 
  <endTime>24:00</endTime> 
  </TimeRange>
  </TimeBlock>
  </TimeBlockList>
  </Schedule>
  </MotionDetectionScheduleList>

i just figured it out that during the first few seconds of “test new button- ON” motion is detected and it changes the state of motion alarm… but does not change its state afterwards.

There is an API linked in the first post for hikvision

That link is not working. getting 404 error.


(Sergey) #153

http://down.dipol.com.pl/Cctv/-Hikvision-/isapi/HIKVISION%20ISAPI_2.6-IPMD%20Service.pdf - work link


(Arsalan Alli) #154

OK I have done another build with HikAuto on the end

@matt1 HIKAuto build is detecting motion and changing the state of “Motion Alarm” to ON but it is not changing the state back to OFF when there is no motion.


(Skinah) #155

what does the vmd show as when there is no motion if you use a browser or the logs to check?
Something like this?

<eventState>inactive</eventState>

(Sergey) #156

Motion detector places a record in xml only when it is active.
When there is no write activity from vmd in xml are missing


(Arsalan Alli) #157

Motion detector places a record in xml only when it is active.
When there is no write activity from vmd in xml are missing

Exactly what i am facing…there is no xml motion detection record when there is no motion. only this

<MotionDetection version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<id>1</id>
<enabled>true</enabled>
<regionType>grid</regionType>
<Grid>
<rowGranularity>18</rowGranularity>
<columnGranularity>22</columnGranularity>
</Grid>
<MotionDetectionRegionList>
<sensitivityLevel>4</sensitivityLevel>
</MotionDetectionRegionList>
</MotionDetection>

(Sergey) #158

@ArsalanAlli record of motion is detected you appear to be on the links above


(Arsalan Alli) #159
<MotionDetection version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<id>1</id>
<enabled>true</enabled>
<regionType>grid</regionType>
<Grid>
<rowGranularity>18</rowGranularity>
<columnGranularity>22</columnGranularity>
</Grid>
<MotionDetectionRegionList>
<sensitivityLevel>4</sensitivityLevel>
</MotionDetectionRegionList>
</MotionDetection>

@toroid my above output is when there is no motion. it is showing in debug logs when there is no motion.


(Sergey) #160

http://192.168.1.108/MotionDetection/1 - This is the setting output of the motion detector, not the event

Look at the links above that I have given - there are event