IpCamera: New IP Camera Binding

camera
ip-cam
onvif
Tags: #<Tag:0x00007fd30f496490> #<Tag:0x00007fd30f496350> #<Tag:0x00007fd30f4961e8>

(Mihai Badea) #301

My bad, I didn’t bother to explain in detail…
That response from the camera is given as an example and, yes, the motion and audio alarm are enabled in that case.
The problem is that the binding does not update the enableMotionAlarm and enableAudioAlarm when those are updated outside openHAB (e.g. from the camera web-interface and phone app).
As the binding periodically pulls getDevState from the camera I think that the response could be used to updated the alarm channels.


(Skinah) #302

That is how the binding has done it for a long time. Can you look at the logs to see if the binding actually gets a response from the camera as chad is reporting a similar bug which I am looking into only the logs show no response before the connection gets closed.


(_) #303

Hello to All,

Is it possible to add fro Hikvision Alarm output trigering?


(Mihai Badea) #304

Here’s some lines from the TRACE log:

28-Jun-2018 06:46:59.109 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:1    URL:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXXX
28-Jun-2018 06:46:59.110 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - ---- Closing CommonCameraHandler.       URL:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXXX
28-Jun-2018 06:47:00.051 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.200.198,   URL:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXXX
28-Jun-2018 06:47:00.054 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - ++++ CommonCameraHandler created.       URL:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXXX ... 3 channels tracked (some of these may be closed).
28-Jun-2018 06:47:00.060 [TRACE] [enhab.binding.ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for     GET:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXXX
28-Jun-2018 06:47:00.060 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Have re-opened the old channel:2        GET:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXXX
28-Jun-2018 06:47:00.377 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 200 OK
Content-Type: text/plain
Transfer-Encoding: chunked
Date: Thu, 28 Jun 2018 03:46:58 GMT
Server: lighttpd/1.4.35
28-Jun-2018 06:47:00.378 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:2    URL:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXXX
28-Jun-2018 06:47:01.392 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:1    URL:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXXX
28-Jun-2018 06:47:01.392 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - ---- Closing CommonCameraHandler.       URL:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXXX

As I saw the response HTTP/1.1 200 OK I thought that you don’t log anymore the actual response form the camera…


(Skinah) #305

New build 28-06-2018 has following changes:

  • Bug fix for all brands of cameras.
  • Foscam possible fix for missing messages.

@Mihai_Badea
@chaderick9
I was able to reproduce missing messages and this build has a fix in it. All messages should be seen in TRACE logging so if it is missing then there is still an issue.

Sure, take a look at the API and if it is possible test it out with a browser and if you work out what needs to be added just post a message and I can take a look.

The link to where it can be downloaded is found in the first post of this thread, it is zipped.


(Mihai Badea) #306

Version 2.3.0.201806281013 displays the response from the camera:

28-Jun-2018 13:57:17.967 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent
28-Jun-2018 13:57:17.988 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 200 OK
Content-Type: text/plain
Transfer-Encoding: chunked
Date: Thu, 28 Jun 2018 10:57:15 GMT
Server: lighttpd/1.4.35
28-Jun-2018 13:57:17.989 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Channel marked as closing, channel:3    URL:/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXXX&pwd=XXXXXXXXX
28-Jun-2018 13:57:17.989 [TRACE] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 528, cap: 528/528, unwrapped: PooledUnsafeDirectByteBuf(ridx: 670, widx: 675, cap: 1024)), decoderResult: success)
28-Jun-2018 13:57:17.990 [DEBUG] [g.openhab.binding.ipcamera.handler.IpCameraHandler] - Chunked message recieved is:<CGI_Result>
    <result>0</result>
    <IOAlarm>0</IOAlarm>
    <motionDetectAlarm>1</motionDetectAlarm>
    <soundAlarm>1</soundAlarm>
    <record>0</record>
    <sdState>0</sdState>
    <sdFreeSpace>0k</sdFreeSpace>
    <sdTotalSpace>0k</sdTotalSpace>
    <ntpState>1</ntpState>
    <ddnsState>0</ddnsState>
    <url>XXXXXXXXX</url>
    <upnpState>0</upnpState>
    <isWifiConnected>1</isWifiConnected>
    <wifiConnectedAP>XXXXXXXXX</wifiConnectedAP>
    <infraLedState>0</infraLedState>
</CGI_Result>

However, after initialization of the thing, the channels enableMotionAlarm and enableAudioAlarm ore OFF.
As you can see from the camera’s response, they are enabled…


(_) #307

@matt1

please confirm if below data are sufficient

To trigger XML block to be sent

/ISAPI/System/IO/outputs//trigger

ex. http://192.168.2.64/IO/outputs/1/trigger/

IOPortData XML Block

<IOPortData xmlns=“http://www.isapi.org/ver20/XMLSchema”>
<outputState> <!-- req, xs:string, “high,low” --> </outputState>
</IOPortData>

to get status:
/ISAPI/System/IO/outputs/ID/status

ex. http://192.168.2.64/IO/outputs/1/status/

answer:

<IOPortStatusxmlns="http://www.hikvision.com/ver10/XMLSchema"version="1.0">
<ioPortID>1</ioPortID>
<ioPortType>output</ioPortType>
<ioState>inactive</ioState>
</IOPortStatus>

also inputs:
/ISAPI/System/IO/inputs/ID/status

ex. http://192.168.2.64/IO/inputs/1/status/

answer:

<IOPortStatus xmlns="http://www.hikvision.com/ver10/XMLSchema" version="1.0">
<ioPortID>1</ioPortID>
<ioPortType>input</ioPortType>
<ioState>inactive</ioState>
</IOPortStatus>


(Skinah) #308

OK we got closer, I just uploaded another build marked take2 this one should work since the log showed the full reply.


(Mihai Badea) #309

take2 appears to be working all right.
enableMotionAlarm and enableAudioAlarm get updated properly from the camera(s).
Also the motionAlarm is working as expected.
Can’t test right now the audio part, but I suppose it will work OK.


(Chad D) #310

YOU ROCK!

2018-06-28 09:15:42.241 [vent.ItemStateChangedEvent] - ipcamera_FOSCAM_frontPorchIP_motionAlarm changed from OFF to ON

2018-06-28 09:15:42.793 [vent.ItemStateChangedEvent] - ipcamera_FOSCAM_frontPorchIP_image changed from raw type (image/jpeg): 37857 bytes to raw type (image/jpeg): 42789 bytes

2018-06-28 09:15:47.945 [vent.ItemStateChangedEvent] - ipcamera_FOSCAM_frontPorchIP_image changed from raw type (image/jpeg): 42789 bytes to raw type (image/jpeg): 42886 bytes

2018-06-28 09:15:53.069 [vent.ItemStateChangedEvent] - ipcamera_FOSCAM_frontPorchIP_image changed from raw type (image/jpeg): 42886 bytes to raw type (image/jpeg): 42867 bytes

2018-06-28 09:15:58.222 [vent.ItemStateChangedEvent] - ipcamera_FOSCAM_frontPorchIP_image changed from raw type (image/jpeg): 42867 bytes to raw type (image/jpeg): 42685 bytes

2018-06-28 09:16:02.247 [vent.ItemStateChangedEvent] - ipcamera_FOSCAM_frontPorchIP_motionAlarm changed from ON to OFF

motionAlarm is now triggering with the latest “take2” build.

Thanks so much for your work on this!


(_) #311

Hello,

i’m not sure that onvif is off by default in all hikvision cam. Onvif deice menager is connecting with cam without any issue.

I have Hikvision with previouse firmware 5.45 (newest 5.5 is not avalible for this cam model) and such option is not existing.

but any way i have some issue.

In Paper IU image and motion status are working but Basic UI (.sitemap) is not showing any picture.

Do you know what can be the reason ?


(_) #312

OK issue resolved :slightly_smiling_face:
.items
Image ipcamera_2 {channel=“ipcamera:HIKVISION:73141ac9:image”}
.sitemap
Default item=ipcamera_2


(Sergey) #313

@Kristo ONVIF in binding for hik cameras is only used for PTZ control.
If you have a camera that does not have ptz (absolute) then onvif on the camera can be turned off and everything will work.
Binding uses the hikvision api
I can not binding on onvif and when it is enabled on the camera no pictures.
As soon as ONVIF turn off the picture appears.


(_) #314

@toroid
Thanks for explanation, i just checked if picture with my settings will disappears when Onvif device manage will make life streaming but it’s working parallel


(Martin Engelhard) #315

With the new version motiondetection also works on foscam FI9831W !


(Greg) #316

From what I tell in this thread everyone is having problems getting cameras integrated with Openhab. I’ve given up getting my 4 + year old Hikvision cameras to work because I can’t upgrade the firmware. Can anyone recommend a camera that they know works well with Openhab?


(_) #317

@TexasGreg

Which firmware you have in those cams?


(Skinah) #318

@Kristo

Can you send me the output of this please? My camera does not have those outputs so I can not test myself.

 http://192.168.2.64/ISAPI/System/IO/outputs/101

Also you dont need to disable ONVIF as you found it works either way, but if you don’t have PTZ features on your camera then give the binding the wrong port number and it will connect faster, I do this when I am developing and testing the http code.

@TexasGreg
Sorry I cant comment on what other peoples experiences are and I have never tried getting cameras running any other ways other than this binding. Forums are usually full of people asking for help, and the people that are working simply do not post as they have a working setup… See the first post of this thread for the cameras that I use and test each build with and a number of users have posted models in this thread. If you do buy new cameras than please make sure it can have it’s firmware updated, security flaws are found from time to time and you will want to get those as well as any bug fixes.


(_) #319

output:

<ResponseStatus xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<requestURL>/ISAPI/System/IO/outputs/101</requestURL>
<statusCode>4</statusCode>
<statusString>Invalid Operation</statusString>
<subStatusCode>invalidOperation</subStatusCode>
</ResponseStatus>

why you are putting ID = 101?

without ID
/ISAPI/System/IO/outputs

response is:

<IOOutputPortList xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<IOOutputPort xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>1</id>
<PowerOnState>
<defaultState>low</defaultState>
<outputState>pulse</outputState>
<pulseDuration>5000</pulseDuration>
</PowerOnState>
<name/>
</IOOutputPort>
</IOOutputPortList>

with proper ID ex ID =1

response:
<IOOutputPort xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
<id>1</id>
<PowerOnState>
<defaultState>low</defaultState>
<outputState>pulse</outputState>
<pulseDuration>5000</pulseDuration>
</PowerOnState>
<name/>
</IOOutputPort>


(Greg) #320

The cameras are DS-2CD2032-I and the firmware is V5.1.0 build 131202