IPcamera binding and Motion Detect does not work as expected

I am using on a windows PC the OH 4.1.2 with a foscam and the IPcamera binding. The mobile foscam app is working and detects motion without problem. In OH I have a video stream but the motion detection is not working at all.

The thing URL setup for motion is:

Create your own custom enable Motion Alarm settings by entering a custom URL
/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&linkage=646&snapInterval=1&sensitivity=2&triggerInterval=0&schedule0=281474976645119&schedule1=281474976645119&schedule2=281474976645119&schedule3=281474976645119&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976645119&area0=120&area1=120&area2=120&area3=120&area4=120&area5=120&area6=120&area7=120&area7=120&area8=120&area9=120&usr=***&pwd=***

The camera channel “Enable Motion Alarm” is OFF and when manually switch it to ON it goes automatically back to OFF after about 7s. The channel “Motion Alarm” remains always OFF.

The event log shows:

 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'IP_Kamera_OG__Foscam_Camera_with_API_Enable_Motion_Alarm' updated to OFF
 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'IP_Kamera_OG__Foscam_Camera_with_API_Enable_Motion_Alarm' changed from ON to OFF
 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'IP_Kamera_OG__Foscam_Camera_with_API_LED_Controls' updated to 0

And the OH-Log:

 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.178.44:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=***&pwd=***
[TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:<CGI_Result>
    <result>0</result>
    <IOAlarm>0</IOAlarm>
    <motionDetectAlarm>0</motionDetectAlarm>
    <humanDetectAlarmState>1</humanDetectAlarmState>
    <soundAlarm>0</soundAlarm>
    <record>0</record>
    <sdState>0</sdState>
    <sdFreeSpace>0k</sdFreeSpace>
    <sdTotalSpace>0k</sdTotalSpace>
    <ntpState>1</ntpState>
    <url></url>
    <isWifiConnected>0</isWifiConnected>
    <wifiConnectedAP></wifiConnectedAP>
    <infraLedState>0</infraLedState>
    <carDetectAlarmState>0</carDetectAlarmState>
    <petDetectAlarmState>0</petDetectAlarmState>
    <crossLineDetectAlarmState>0</crossLineDetectAlarmState>
</CGI_Result>
:

Can someone help pls?

Your camera has human and other newer alarms that are not yet added into the foscam support of the binding. It is easy to add them so thank you for posting your cameras output.

The motion alarm enable channel is for turning the detection feature on and off. It will only work if you setup the url as per the readme, but this is not needed if you turn it on with the cameras app and leave it turned on. There is a separate channel without the enable word in it that shows if the alarm is on or off.

Thanks for your reply. I do not fully understand what it means. In my app the detection is set to ON and the app gets the human detection. On the other hand I set the URL in OH like this:

[quote="Norick, post:1, topic:155697"]
`/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&...
[/quote]

which should also activate the human detection - correct?

The channel “Motion Alarm” says “Motion has been detected” and is in my case always OFF. So you mean you have to change your binding in order it works and/or can I do a workaround to fix it?

Thanks

This according to the source code means the motion alarm is disabled. It goes to a value of 1 and 2 when it is enabled.

No idea, you need to read the api to know what the url does, I am not tech support and won’t spend hours reading documents for cameras I do not own. If there is a bug then I am happy to help out. The car, pet and also human alarms can be added and I can look at doing this in around a weeks time. They won’t work till I make a newer build.

This makes sense whten the “motionDetectAlarm” is 0! In the api docu for setting the URL they say:

isEnable -> Is enable motion detect alarm

In my URL I set:

`/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&...

Now I am not sure if the binding reads that URL correct or the API in this case does something wrong or I missunderstood this parameter. What is your opinion about this point?

When reading out the CGI for the getMotionDetectConfig I get this:

<CGI_Result>
    <result>0</result>
    <isEnable>1</isEnable>
    <linkage>646</linkage>
    <snapInterval>1</snapInterval>
    <sensitivity>2</sensitivity>
    <triggerInterval>0</triggerInterval>
    <isMovAlarmEnable>1</isMovAlarmEnable>
    <isPirAlarmEnable>0</isPirAlarmEnable>
    <schedule0>281474976645119</schedule0>
    <schedule1>281474976645119</schedule1>
    <schedule2>281474976645119</schedule2>
    <schedule3>281474976645119</schedule3>
    <schedule4>281474976710655</schedule4>
    <schedule5>281474976710655</schedule5>
    <schedule6>281474976645119</schedule6>
    <area0>120</area0>
    <area1>120</area1>
    <area2>120</area2>
    <area3>120</area3>
    <area4>120</area4>
    <area5>120</area5>
    <area6>120</area6>
    <area7>120</area7>
    <area8>120</area8>
    <area9>120</area9>
    <humanEnable>1</humanEnable>
    <carEnable>0</carEnable>
    <petEnable>0</petEnable>
    <crossLineEnable>0</crossLineEnable>
    <OnlyDtPed>0</OnlyDtPed>
    <isEnableLine0>0</isEnableLine0>
    <line0Direction>0</line0Direction>
    <line0StartX>0</line0StartX>
    <line0StartY>0</line0StartY>
    <line0EndX>0</line0EndX>
    <line0EndY>0</line0EndY>
    <isEnableLine1>0</isEnableLine1>
    <line1Direction>0</line1Direction>
    <line1StartX>0</line1StartX>
    <line1StartY>0</line1StartY>
    <line1EndX>0</line1EndX>
    <line1EndY>0</line1EndY>
    <isEnableLine2>0</isEnableLine2>
    <line2Direction>0</line2Direction>
    <line2StartX>0</line2StartX>
    <line2StartY>0</line2StartY>
    <line2EndX>0</line2EndX>
    <line2EndY>0</line2EndY>
    <isEnableLine3>0</isEnableLine3>
    <line3Direction>0</line3Direction>
    <line3StartX>0</line3StartX>
    <line3StartY>0</line3StartY>
    <line3EndX>0</line3EndX>
    <line3EndY>0</line3EndY>
</CGI_Result>

Here the second entry is:

<isEnable>1</isEnable>

which tells me the detection is ON - correct?

But the OH trace log gives me:

<motionDetectAlarm>0</motionDetectAlarm>

Do you have an idea why the binding says 0 here even when I set it?

Thank you

Is it possible that the IP binding is not working and therefore the binding returns 0???

Not possible, the binding just gives to the log EXACTLY what the camera returns. Of course I have no idea if FOSCAM has changed the cgi or if it is a bug in the camera, only their support would be able to answer such questions.

The documentation is here

It however appears older than your camera as it does not have the line crossing, human, pet or car alarms that yours has.

I have implemented the new alarms in a special build here, if you can test them, I can then raise a PR to get these changes merged. Since they are not documented I assumed the same is true that a value of 2 means the alarm is active and 1 means it is not in the alarm state.

http://pcmus.com/openhab/IpCameraBinding/ipcamera-FOSCAM.zip

So the big question is what the camera returns. Therefore I have this latest foscam API docu:

[type or paste code here](https://alarmforum.de/attachment.php?aid=2467)

Motion Isenable is therefore “1” and disabled a “0” in my opinion. I understood that in your binding it is different. I will test your version and let you know if I can see a difference or not.

Thanks

Just for clarification: You check the CGI flag “humanDetectAlarmState” if a motion has been detected?

Is this correct? If yes, what is the default value when NOT detected and what is the value when motion is detected?

Correct, you should now have access to a new channel, i think it is called humanAlarm and this should tell you when the camera sees a human. Animal, car and line crossing are also now added. The line crossing is a very good alarm to use that can prevent false positives and its much better then dumb motion detection.

2 = motion
1 = no motion
0 = alarm disabled

None of the CGI / API documentations that I can find list what they should actually be, so this is why I am asking if you mind testing that it is correct? thanks…

I am actually surprised that Foscam seems to have updated the CGI as they have been following a trend of removing the CGI features from models in years past. Hopefully they are changing their mind and adding them as most of their competition has been adding more A.I object detection alarms. Please contact Foscam and ask them questions as I can only guess as I do not work for them and only have access to the same documents like you do.