IpCamera: New IP Camera Binding

In the latest version, the same error on onvif is caused when connecting the camera directly.


And no picture from the camera.

The status of things - provisioning. In early versions of binding the status was initialized and there was a picture from the camera (though ptz did not work)

Through NVR everything works (except PTZ) as binding does not support such type of control (countur)

@toroid
I own a Hikvision and have tested it extensively direct to openhab with no NVR as I do not own one. Please delete the camera, re-add it and check your settings. Recent builds have different channels so you must delete and re-add if you do not use TEXTUAL CONFIG. The error as I have mentioned before is your camera not replying when asked about PTZ, it should not stop the camera working. The error should disable the PTZ from working, but it is not related to your picture issue. Check the setting are correct and the NVR input channel is set to 1 for cameras not connected to a NVR.

I turned off onvif on the camera (still it does not work as it should) and things immediately changed to online.


And the picture also appeared

– the latest build did not enable the schedule when using the switch on the paper UI of OH.

I was able to get my desired results with the following get request::

cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&linkage=0001&sensitivity=1&triggerInterval=15&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&area0=1023&area1=1023&area2=1023&area3=1023&area4=1023&area5=1023&area6=1023&area7=1023&area7=1023&area8=1023&area9=1023&usr=username&pwd=password

linkage param is enabling my cameras sound/siren, sensitivity is being set to medium, triggerInterval is saying only trigger every 15 secs motion is present, then the schedule^N and area^N params are enabling motion detection 24/7 as well as setting the motion area for all cells of the cameras motion grid.

I’m considering branching your git repo to try and contribute
 You let me know what I can do to help.

Thanks again for all your work.

Edit

Also, I just realized that the Motion Alarm state through OH never changes when motion is detected.

Earlier you had asked me to check the value at:: /cgi-bin/CGIProxy.fcgi?cmd=getDevState
and param motionDetectAlarms value never changed from 1 (no alarm). Now with your help and the troubleshooting that has been done, with the proper setting in my cameras configuration, that value does change from 1 to 2 (detect alarm) when motion is detected.

Am I misconfiguring OH? I also have OH configured to “Update the image during motion alarm” and the image does not update.

Thanks again!

New Build 21-06-2018 has these changes:

  • Fixed bug for All brands that was causing errors under Openhab version 2.3
  • Foscam improvements to allow user to specify their own “motion enable” command. See bindings settings for the camera, more on this below

  • Foscam updated code to be cleaner and use the same methods the other cameras use for only updating picture when movement occurs. Much easier to read and maintain.
  • Foscam now listens to both “motionDetectAlarm” and “motionDetectAlarms” so both will trigger the motion alarm.

@chaderick9
@zacofunny
@reeso3000
@Mihai_Badea
@Melkor

Since this build has changes effecting Foscam users I’ll give a shout out to the people who posted they have foscam in this thread.

Chad has posted his camera appears to be working differently as most of you have already posted the alarm is working fine. In case you find the binding is not turning the alarm back on correctly, I have added another setting in the binding that allows you to enter your own custom url in this format


/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&linkage=0001&sensitivity=1&triggerInterval=15&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&area0=1023&area1=1023&area2=1023&area3=1023&area4=1023&area5=1023&area6=1023&area7=1023&area7=1023&area8=1023&area9=1023&usr=username&pwd=password

Note there is no IP and it starts with a /.
I have done this because I do not wish for the binding to over write the detection area as many people will want to stop motion detection in areas with tree branches that move in the wind. If you leave this setting blank, it will work the way it did in previous builds.

The other change is Chad seems to be reporting his camera uses “motionDetectAlarms” and other cameras use “motionDetectAlarm”, so the binding should now accept both, but it needs to be tested.

Any problems please contact Chad as he now handles all Foscam complaints :wink: just kidding, all push requests are welcome and the binding now has the framework to allow users to make changes easily without needing to understand the workings of netty.

Hi matt1,
first of all, thank you very much for this binding! It already works great with my Foscam C1 and C1 Lite.
I have a little request: My wife sometimes plugs out the wifi repeater where one of my camera is connected to.
In the Logfile I can see every minute the following Message:

2018-06-22 10:37:56.485 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:foscam02:888
2018-06-22 10:37:59.493 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with ONVIF to the camera at foscam02, check the ONVIF_PORT is correct. Fault was java.net.ConnectException: Host not available.
2018-06-22 10:38:02.494 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at foscam02:88 check your network for issues.
....
2018-06-22 13:10:16.137 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler    URL:/cgi-bin/CGIProxy.fcgi?usr=openhab&pwd=yxenSg2zrOZ4&cmd=snapPicture2
2018-06-22 13:16:07.376 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:foscam02:888
2018-06-22 13:16:17.945 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting that it does NOT support Absolute PTZ controls via ONVIF
2018-06-22 13:16:17.947 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - Finished with PTZ with no errors, now fetching the Video URL for RTSP from the camera.

Is it possible to just report just once that the connection to the camera is lost? The thing state reflects the actual connection state.

@matt1 Hey, i had a little time to investigate. I was never be able to check getMotionDetectConfig but with your recent posts i found out that i need to check getMotionDetectConfig1 Now that i am able to fully investigate I had some test with my C2 Foscam camera. Before i connected the enable motion alarm switch to my presence rule. When i was going out of home the motionAlarm get activated but since there was nobody home i always assumed it would have worked fine. After last posts i checked and motionalarm never got triggered (changed to 2).
I used the link sent from @chaderick9 and was not working too. So i factory reset my camera and got it working and checked the getMotionDetectConfig1 parameter. I have no area, mine has different parameter. Here is the standard response of the C2 straight out of the box that is working.

<CGI_Result>
    <result>0</result>
    <isEnable>1</isEnable>
    <linkage>12</linkage>
    <snapInterval>2</snapInterval>
    <triggerInterval>10</triggerInterval>
    <isMovAlarmEnable>1</isMovAlarmEnable>
    <isPirAlarmEnable>1</isPirAlarmEnable>
    <schedule0>281474976710655</schedule0>
    <schedule1>281474976710655</schedule1>
    <schedule2>281474976710655</schedule2>
    <schedule3>281474976710655</schedule3>
    <schedule4>281474976710655</schedule4>
    <schedule5>281474976710655</schedule5>
    <schedule6>281474976710655</schedule6>
    <x1>0</x1>
    <y1>0</y1>
    <width1>10000</width1>
    <height1>10000</height1>
    <threshold1>50</threshold1>
    <sensitivity1>0</sensitivity1>
    <valid1>1</valid1>
    <x2>10000</x2>
    <y2>10000</y2>
    <width2>0</width2>
    <height2>0</height2>
    <threshold2>50</threshold2>
    <sensitivity2>0</sensitivity2>
    <valid2>0</valid2>
    <x3>10000</x3>
    <y3>10000</y3>
    <width3>0</width3>
    <height3>0</height3>
    <threshold3>50</threshold3>
    <sensitivity3>0</sensitivity3>
    <valid3>0</valid3>
</CGI_Result>

This change is working great. Thanks for that addition

My formatting on my last comment was misleading. The camera does not use “motionDetectAlarms”, it is the same as the other cameras and uses, “motionDetectAlarm”

I am still not getting motion triggered notifications for some reason though, despite the motionDetectAlarm value changing from 1 to 2.

Capture

I will turn on logging and try and figure things out.

EDIT
logging enabled I am not getting much of anything while motion is being detected


New build 25-06-2018 only has minor logging changes for Ozzy and Foscam changes for Chad


@OzZy_HH
It looks like that log output may be from an old build as the newer ones have less output. I just made a change that all ONVIF errors are now only warnings. What this means is you can set your log output to ERROR and you will then only see errors and get what you are after, just don’t forget if you ever have issues to step the log back up to TRACE before asking for help. How to change the log level is found in the very first post of this thread.

@Melkor
Download the PDF from this link and on the very last page is an example url for your camera type using the getMotionDetectConfig1 format. Use that example in the binding and it may be that simple.

@chaderick9

OK I reversed the changes in newer builds.

What you need to look for is “HTTP Result back from camera is” and then in TRACE you will see the reply back from the camera. Your log output stopped too short, it should have been in the next 10+ lines of the log. Because the binding is now async comms, the binding can be asking multiple things of the camera before a reply comes back. I added a line that tells you when the foscam handler is closing the connection to the camera, it is possible the entire message is not reaching the handler in a single packet and it gets closed before the full message comes in. Your camera does not send a length header so I have an idea what may be causing it and I put a change in that may resolve it, hopefully without causing issues for foscam users that have no problems.

Hello!
I installed this binding using “DAHUA” ip camera 
 It works well but It is very Slow to update The image.
And what does ths log mean?

2018-06-26 00:14:53.203 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - !!!! Alertstream was not running, Cleaning channels and then going to re-start it now.


cam2

Can you define slow? I see you have it set to update every second, is it not doing that? Cameras need a key frame to generate a snapshot from so the video settings can effect the snapshot ability.

That warning should happen when first connecting as it means the alarm checking was not running. If it continues in the logs then it will be an issue to look at. Dahua and hikvision both have the ability to open a single stream and keep it open so the camera can inform openhab a alarm is going off. If the stream is not staying open that warning occurs.

yes !

Do you mean this settings?

Thank you for the feedback it is greatly valued as I have not heard how it works on Dahua yet. I’m sorry but I am still unclear if your picture updates every second? If you think there is an issue then please create some trace log output and I can take a look. As I don’t own Dahua cameras I am very limited to what I can do without log files to show what is going on. First post of this thread explains how to change to trace log output.

The I frame setting try reducing that or play with all settings on that page. The hikvision cameras I have actually send 3 requests for a snapshot before the first request actually gets a picture. The compression also takes time on high resolution cameras so the binding needs to ask multiple times and that may not be happening on your camera, can’t tell without log output.

guys, how u r getting the jar file from latest build of this binding?

http://www.pcmus.com/openhab/IpCameraBinding/

Hi @matt1
Thank you for your interest.
yes you are right but unfortunately, my log viewer has stooped,I am trying to fix it

@matt1

Testing latest 2.3.0.201806250815

On my two Foscams C1 almost everything seems to work properly. Almost

What’s not working is pulling the state of enableMotionAlarm and enableAudioAlarm from the camera.
If I disable motion or audio alarm from the camera interface or app the channels are not updated.
the response from the camera is:

$ curl "http://192.168.200.199:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXX&pwd=XXXXXXX"
<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>XXXXXXXXXXXXXXXXXXXXXXXXXXXX</url>
    <upnpState>0</upnpState>
    <isWifiConnected>1</isWifiConnected>
    <wifiConnectedAP>XXXXXXX</wifiConnectedAP>
    <infraLedState>0</infraLedState>
</CGI_Result>

The API states that if the alarms are disabled those two should report as 0. If the alarms are enabled and not occurring 1 is the value. Value of 2 for when the alarm is detected
 Perhaps check for a newer firmware for your camera.