[SOLVED] Connection Foscam camera with ipbinding leads to "We hit an issue parsing url"

Hi,

on an OH 2.5.9 I’m currently trying to connect a new foscam camera. But for some reason is has an issue when parsing the urls retrieved from the camera:

15:58:45.760 [DEBUG] [mera.internal.handler.IpCameraHandler] - File server for camera at 192.168.1.62 has started on port 54322 for all NIC's.
15:58:45.962 [DEBUG] [camera.internal.onvif.OnvifConnection] - Cameras  UTC time is : 14:58:31
15:58:45.978 [DEBUG] [camera.internal.onvif.OnvifConnection] - Cameras  UTC date is : 2020-12-5
15:58:45.978 [DEBUG] [camera.internal.onvif.OnvifConnection] - Openhabs UTC dateTime is:2020-12-05T14:58:45.978Z
15:58:46.841 [DEBUG] [camera.internal.onvif.OnvifConnection] - deviceXAddr:/onvif/device_service
15:58:46.841 [DEBUG] [camera.internal.onvif.OnvifConnection] - We hit an issue parsing url:/
15:58:46.841 [DEBUG] [camera.internal.onvif.OnvifConnection] - mediaXAddr:/onvif/device_service
15:58:46.841 [DEBUG] [camera.internal.onvif.OnvifConnection] - We hit an issue parsing url:
15:58:48.868 [DEBUG] [camera.internal.onvif.OnvifConnection] - GetStreamUri:rtsp://192.168.1.62:88/videoMain
15:58:48.931 [DEBUG] [camera.internal.onvif.OnvifConnection] - GetSnapshotUri:/cgi-bin/CGIProxy.fcgi?usr=tobias&pwd=***&cmd=snapPicture2

I first thought it might be that the password has some special characters, so I removed them, but also with a very plain password I get exactly the same error message. Interesting, when I c&p these urls into my browser it’s working fine.

The end result is, that the camera thing is in status “OFFLINE - COMMUNICATION_ERROR Connection Timeout: Check your IP and PORT are correct and the camera can be reached.”

To get a better picture it needs to be in TRACE level not DEBUG. As trace gives you the replies back from the camera, where the debug is single line logs that show what is happening.

The first message regarding We hit an issue parsing url is probably the camera does not support ONVIF events, the second time is the camera is probably not a PTZ camera. If these statements are correct then they can be ignored. If your camera is meant to be a ONVIF pan tilt and zoom camera then it will need looking at in TRACE mode to look into further.

The reasons the camera is not going ONLINE is not shown in the logs, it has not reached the point where it sends a request for a snapshot for the first time to see if the camera is reachable. The log is cut too short and does not show enough to determine the cause.

Foscam did default to using port 88 in the past, it is possible your newer camera is using port 80 ? Certainly it appears the port 88 is being used for RTSP and that may be blocking the binding which has defaulted to using that port for the snapshots and API calls. The binding has a config called port which is probably set wrong.

Thanks for your detailed reply. The camera is using port 88 I can access the web interface and the RTSP-stream on that port. While ONVIF is on port 888. I’m using the firmware version 1.13.1.7_2.94.2.58.

Happy to provide the trace, I hope that helps:

10:18:45.798 [DEBUG] [mera.internal.handler.IpCameraHandler] - File server for camera at 192.168.1.61 has started on port 54322 for all NIC's.
10:18:45.813 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetSystemDateAndTime
10:18:45.829 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Body><tds:GetSystemDateAndTimeResponse><tds:SystemDateAndTime xsi:type="tt:SystemDateTime"><tt:DateTimeType>NTP</tt:DateTimeType><tt:DaylightSavings>false</tt:DaylightSavings><tt:TimeZone xsi:type="tt:TimeZone"><tt:TZ>CST-1:00:00</tt:TZ></tt:TimeZone><tt:UTCDateTime xsi:type="tt:DateTime"><tt:Time xsi:type="tt:Time"><tt:Hour>9</tt:Hour><tt:Minute>18</tt:Minute><tt:Second>39</tt:Second></tt:Time><tt:Date xsi:type="tt:Date"><tt:Year>2020</tt:Year><tt:Month>12</tt:Month><tt:Day>8</tt:Day></tt:Date></tt:UTCDateTime><tt:LocalDateTime xsi:type="tt:DateTime"><tt:Time xsi:type="tt:Time"><tt:Hour>10</tt:Hour><tt:Minute>18</tt:Minute><tt:Second>39</tt:Second></tt:Time><tt:Date xsi:type="tt:Date"><tt:Year>2020</tt:Year><tt:Month>12</tt:Month><tt:Day>8</tt:Day></tt:Date></tt:LocalDateTime></tds:SystemDateAndTime></tds:GetSystemDateAndTimeResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:18:45.829 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetCapabilities
10:18:45.829 [DEBUG] [camera.internal.onvif.OnvifConnection] - Cameras  UTC time is : 9:18:39
10:18:45.845 [DEBUG] [camera.internal.onvif.OnvifConnection] - Cameras  UTC date is : 2020-12-8
10:18:45.845 [DEBUG] [camera.internal.onvif.OnvifConnection] - Openhabs UTC dateTime is:2020-12-08T09:18:45.845Z
10:18:45.941 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><tds:GetCapabilitiesResponse><tds:Capabilities xsi:type="tt:Capabilities"><tt:Analytics xsi:type="tt:AnalyticsCapabilities"><tt:XAddr>http://192.168.1.61:888/onvif/device_service</tt:XAddr><tt:RuleSupport>true</tt:RuleSupport><tt:AnalyticsModuleSupport>true</tt:AnalyticsModuleSupport></tt:Analytics><tt:Device xsi:type="tt:DeviceCapabilities"><tt:XAddr>http://192.168.1.61:888/onvif/device_service</tt:XAddr><tt:Network xsi:type="tt:NetworkCapabilities"><tt:IPFilter>false</tt:IPFilter><tt:DynDNS>true</tt:DynDNS></tt:Network><tt:System xsi:type="tt:SystemCapabilities"><tt:DiscoveryResolve>true</tt:DiscoveryResolve><tt:DiscoveryBye>true</tt:DiscoveryBye><tt:RemoteDiscovery>false</tt:RemoteDiscovery><tt:SystemBackup>true</tt:SystemBackup><tt:SystemLogging>true</tt:SystemLogging><tt:FirmwareUpgrade>true</tt:FirmwareUpgrade><tt:SupportedVersions xsi:type="tt:OnvifVersion"><tt:Major>2</tt:Major><tt:Minor>21</tt:Minor></tt:SupportedVersions></tt:System><tt:IO xsi:type="tt:IOCapabilities"></tt:IO><tt:Security xsi:type="tt:SecurityCapabilities"><tt:TLS1.1>false</tt:TLS1.1><tt:TLS1.2>false</tt:TLS1.2><tt:OnboardKeyGeneration>false</tt:OnboardKeyGeneration><tt:AccessPolicyConfig>true</tt:AccessPolicyConfig><tt:X.509Token>false</tt:X.509Token><tt:SAMLToken>false</tt:SAMLToken><tt:KerberosToken>false</tt:KerberosToken><tt:RELToken>false</tt:RELToken></tt:Security></tt:Device><tt:Events xsi:type="tt:EventCapabilities"><tt:XAddr/><tt:WSSubscriptionPolicySupport>false</tt:WSSubscriptionPolicySupport><tt:WSPullPointSupport>false</tt:WSPullPointSupport><tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport></tt:Events><tt:Imaging xsi:type="tt:ImagingCapabilities"><tt:XAddr>http://192.168.1.61:888/onvif/device_service</tt:XAddr></tt:Imaging><tt:Media xsi:type="tt:MediaCapabilities"><tt:XAddr>http://192.168.1.61:888/onvif/device_service</tt:XAddr><tt:StreamingCapabilities xsi:type="tt:RealTimeStreamingCapabilities"><tt:RTPMulticast>false</tt:RTPMulticast><tt:RTP_TCP>true</tt:RTP_TCP><tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP></tt:StreamingCapabilities></tt:Media><tt:Extension xsi:type="tt:CapabilitiesExtension"><tt:DeviceIO xsi:type="tt:DeviceIOCapabilities"><tt:XAddr/><tt:VideoSources>1</tt:VideoSources><tt:VideoOutputs>0</tt:VideoOutputs><tt:AudioSources>0</tt:AudioSources><tt:AudioOutputs>0</tt:AudioOutputs><tt:RelayOutputs>0</tt:RelayOutputs></tt:DeviceIO></tt:Extension></tds:Capabilities></tds:GetCapabilitiesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:18:45.941 [DEBUG] [camera.internal.onvif.OnvifConnection] - deviceXAddr:/onvif/device_service
10:18:45.941 [DEBUG] [camera.internal.onvif.OnvifConnection] - We hit an issue parsing url:/
10:18:45.941 [DEBUG] [camera.internal.onvif.OnvifConnection] - mediaXAddr:/onvif/device_service
10:18:45.941 [DEBUG] [camera.internal.onvif.OnvifConnection] - We hit an issue parsing url:
10:18:45.941 [TRACE] [camera.internal.onvif.OnvifConnection] - Camera must not support PTZ, it failed to give a <tt:PTZ><tt:XAddr>:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><tds:GetCapabilitiesResponse><tds:Capabilities xsi:type="tt:Capabilities"><tt:Analytics xsi:type="tt:AnalyticsCapabilities"><tt:XAddr>http://192.168.1.61:888/onvif/device_service</tt:XAddr><tt:RuleSupport>true</tt:RuleSupport><tt:AnalyticsModuleSupport>true</tt:AnalyticsModuleSupport></tt:Analytics><tt:Device xsi:type="tt:DeviceCapabilities"><tt:XAddr>http://192.168.1.61:888/onvif/device_service</tt:XAddr><tt:Network xsi:type="tt:NetworkCapabilities"><tt:IPFilter>false</tt:IPFilter><tt:DynDNS>true</tt:DynDNS></tt:Network><tt:System xsi:type="tt:SystemCapabilities"><tt:DiscoveryResolve>true</tt:DiscoveryResolve><tt:DiscoveryBye>true</tt:DiscoveryBye><tt:RemoteDiscovery>false</tt:RemoteDiscovery><tt:SystemBackup>true</tt:SystemBackup><tt:SystemLogging>true</tt:SystemLogging><tt:FirmwareUpgrade>true</tt:FirmwareUpgrade><tt:SupportedVersions xsi:type="tt:OnvifVersion"><tt:Major>2</tt:Major><tt:Minor>21</tt:Minor></tt:SupportedVersions></tt:System><tt:IO xsi:type="tt:IOCapabilities"></tt:IO><tt:Security xsi:type="tt:SecurityCapabilities"><tt:TLS1.1>false</tt:TLS1.1><tt:TLS1.2>false</tt:TLS1.2><tt:OnboardKeyGeneration>false</tt:OnboardKeyGeneration><tt:AccessPolicyConfig>true</tt:AccessPolicyConfig><tt:X.509Token>false</tt:X.509Token><tt:SAMLToken>false</tt:SAMLToken><tt:KerberosToken>false</tt:KerberosToken><tt:RELToken>false</tt:RELToken></tt:Security></tt:Device><tt:Events xsi:type="tt:EventCapabilities"><tt:XAddr/><tt:WSSubscriptionPolicySupport>false</tt:WSSubscriptionPolicySupport><tt:WSPullPointSupport>false</tt:WSPullPointSupport><tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport></tt:Events><tt:Imaging xsi:type="tt:ImagingCapabilities"><tt:XAddr>http://192.168.1.61:888/onvif/device_service</tt:XAddr></tt:Imaging><tt:Media xsi:type="tt:MediaCapabilities"><tt:XAddr>http://192.168.1.61:888/onvif/device_service</tt:XAddr><tt:StreamingCapabilities xsi:type="tt:RealTimeStreamingCapabilities"><tt:RTPMulticast>false</tt:RTPMulticast><tt:RTP_TCP>true</tt:RTP_TCP><tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP></tt:StreamingCapabilities></tt:Media><tt:Extension xsi:type="tt:CapabilitiesExtension"><tt:DeviceIO xsi:type="tt:DeviceIOCapabilities"><tt:XAddr/><tt:VideoSources>1</tt:VideoSources><tt:VideoOutputs>0</tt:VideoOutputs><tt:AudioSources>0</tt:AudioSources><tt:AudioOutputs>0</tt:AudioOutputs><tt:RelayOutputs>0</tt:RelayOutputs></tt:DeviceIO></tt:Extension></tds:Capabilities></tds:GetCapabilitiesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:18:45.957 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetProfiles
10:18:46.362 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><trt:GetProfilesResponse><trt:Profiles xsi:type="tt:Profile" fixed="true" token="prof0"><tt:Name>prof0_name</tt:Name><tt:VideoSourceConfiguration xsi:type="tt:VideoSourceConfiguration" token="videosource_token0"><tt:Name>videosource_name0</tt:Name><tt:UseCount>1</tt:UseCount><tt:SourceToken>videosource_sourcetoken0</tt:SourceToken><Bounds xmlns="http://www.onvif.org/ver10/schema" height="1080" width="1920" y="1" x="1" xsi:type="tt:IntRectangle"></Bounds></tt:VideoSourceConfiguration><tt:AudioSourceConfiguration xsi:type="tt:AudioSourceConfiguration" token="audiosource_token0"><tt:Name>audiosource_name0</tt:Name><tt:UseCount>4</tt:UseCount><tt:SourceToken>audiosource_sourcetoken0</tt:SourceToken></tt:AudioSourceConfiguration><tt:VideoEncoderConfiguration xsi:type="tt:VideoEncoderConfiguration" token="videoencoder_token0"><tt:Name>videoencoder_name0</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>H264</tt:Encoding><tt:Resolution xsi:type="tt:VideoResolution"><tt:Width>1920</tt:Width><tt:Height>1080</tt:Height></tt:Resolution><tt:Quality>3</tt:Quality><tt:RateControl xsi:type="tt:VideoRateControl"><tt:FrameRateLimit>15</tt:FrameRateLimit><tt:EncodingInterval>1</tt:EncodingInterval><tt:BitrateLimit>1024</tt:BitrateLimit></tt:RateControl><tt:H264 xsi:type="tt:H264Configuration"><tt:GovLength>30</tt:GovLength><tt:H264Profile>Baseline</tt:H264Profile></tt:H264><tt:Multicast xsi:type="tt:MulticastConfiguration"><tt:Address xsi:type="tt:IPAddress"><tt:Type>IPv4</tt:Type><tt:IPv4Address>192.168.1.61</tt:IPv4Address></tt:Address><tt:Port>88</tt:Port><tt:TTL>10</tt:TTL><tt:AutoStart>true</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT0S</tt:SessionTimeout></tt:VideoEncoderConfiguration><tt:AudioEncoderConfiguration xsi:type="tt:AudioEncoderConfiguration" token="audioencoder_token0"><tt:Name>audioencoder_name0</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>G711</tt:Encoding><tt:Bitrate>16</tt:Bitrate><tt:SampleRate>8000</tt:SampleRate><tt:Multicast xsi:type="tt:MulticastConfiguration"><tt:Address xsi:type="tt:IPAddress"><tt:Type>IPv4</tt:Type><tt:IPv4Address>192.168.1.61</tt:IPv4Address></tt:Address><tt:Port>88</tt:Port><tt:TTL>0</tt:TTL><tt:AutoStart>true</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT0H0M0.030S</tt:SessionTimeout></tt:AudioEncoderConfiguration></trt:Profiles><trt:Profiles xsi:type="tt:Profile" fixed="true" token="prof1"><tt:Name>prof1_name</tt:Name><tt:VideoSourceConfiguration xsi:type="tt:VideoSourceConfiguration" token="videosource_token0"><tt:Name>videosource_name0</tt:Name><tt:UseCount>1</tt:UseCount><tt:SourceToken>videosource_sourcetoken0</tt:SourceToken><Bounds xmlns="http://www.onvif.org/ver10/schema" height="1080" width="1920" y="1" x="1" xsi:type="tt:IntRectangle"></Bounds></tt:VideoSourceConfiguration><tt:AudioSourceConfiguration xsi:type="tt:AudioSourceConfiguration" token="audiosource_token0"><tt:Name>audiosource_name0</tt:Name><tt:UseCount>4</tt:UseCount><tt:SourceToken>audiosource_sourcetoken0</tt:SourceToken></tt:AudioSourceConfiguration><tt:VideoEncoderConfiguration xsi:type="tt:VideoEncoderConfiguration" token="videoencoder_token1"><tt:Name>videoencoder_name1</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>H264</tt:Encoding><tt:Resolution xsi:type="tt:VideoResolution"><tt:Width>1280</tt:Width><tt:Height>720</tt:Height></tt:Resolution><tt:Quality>3</tt:Quality><tt:RateControl xsi:type="tt:VideoRateControl"><tt:FrameRateLimit>11</tt:FrameRateLimit><tt:EncodingInterval>1</tt:EncodingInterval><tt:BitrateLimit>512</tt:BitrateLimit></tt:RateControl><tt:H264 xsi:type="tt:H264Configuration"><tt:GovLength>22</tt:GovLength><tt:H264Profile>Baseline</tt:H264Profile></tt:H264><tt:Multicast xsi:type="tt:MulticastConfiguration"><tt:Address xsi:type="tt:IPAddress"><tt:Type>IPv4</tt:Type><tt:IPv4Address>192.168.1.61</tt:IPv4Address></tt:Address><tt:Port>88</tt:Port><tt:TTL>10</tt:TTL><tt:AutoStart>true</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT0S</tt:SessionTimeout></tt:VideoEncoderConfiguration><tt:AudioEncoderConfiguration xsi:type="tt:AudioEncoderConfiguration" token="audioencoder_token0"><tt:Name>audioencoder_name0</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>G711</tt:Encoding><tt:Bitrate>16</tt:Bitrate><tt:SampleRate>8000</tt:SampleRate><tt:Multicast xsi:type="tt:MulticastConfiguration"><tt:Address xsi:type="tt:IPAddress"><tt:Type>IPv4</tt:Type><tt:IPv4Address>192.168.1.61</tt:IPv4Address></tt:Address><tt:Port>88</tt:Port><tt:TTL>0</tt:TTL><tt:AutoStart>true</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT0H0M0.030S</tt:SessionTimeout></tt:AudioEncoderConfiguration></trt:Profiles></trt:GetProfilesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:18:46.379 [TRACE] [camera.internal.onvif.OnvifConnection] - String was found:prof0
10:18:46.379 [TRACE] [camera.internal.onvif.OnvifConnection] - String was found:prof1
10:18:46.379 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetSnapshotUri
10:18:46.379 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetStreamUri
10:18:46.395 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetEventProperties
10:18:46.395 [TRACE] [camera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetServiceCapabilities
10:18:46.410 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding"><SOAP-ENV:Code><SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value></SOAP-ENV:Code><SOAP-ENV:Reason><SOAP-ENV:Text xml:lang="en">HTTP Error: 401 Unauthorized</SOAP-ENV:Text></SOAP-ENV:Reason></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:18:46.410 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><SOAP-ENV:Fault SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding"><SOAP-ENV:Code><SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value></SOAP-ENV:Code><SOAP-ENV:Reason><SOAP-ENV:Text xml:lang="en">HTTP Error: 401 Unauthorized</SOAP-ENV:Text></SOAP-ENV:Reason></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:18:46.460 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><trt:GetSnapshotUriResponse><trt:MediaUri xsi:type="tt:MediaUri"><tt:Uri>http://192.168.1.61:88/cgi-bin/CGIProxy.fcgi?usr=tobias&amp;pwd=***&amp;cmd=snapPicture2</tt:Uri><tt:InvalidAfterConnect>false</tt:InvalidAfterConnect><tt:InvalidAfterReboot>false</tt:InvalidAfterReboot><tt:Timeout>PT0H0M0.005S</tt:Timeout></trt:MediaUri></trt:GetSnapshotUriResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:18:46.460 [DEBUG] [camera.internal.onvif.OnvifConnection] - GetSnapshotUri:/cgi-bin/CGIProxy.fcgi?usr=tobias&amp;pwd=***&amp;cmd=snapPicture2
10:18:46.460 [TRACE] [camera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body><trt:GetStreamUriResponse><trt:MediaUri xsi:type="tt:MediaUri"><tt:Uri>rtsp://192.168.1.61:88/videoMain</tt:Uri><tt:InvalidAfterConnect>false</tt:InvalidAfterConnect><tt:InvalidAfterReboot>false</tt:InvalidAfterReboot><tt:Timeout>PT0S</tt:Timeout></trt:MediaUri></trt:GetStreamUriResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
10:18:46.460 [DEBUG] [camera.internal.onvif.OnvifConnection] - GetStreamUri:rtsp://192.168.1.61:88/videoMain
10:18:47.060 [DEBUG] [camera.internal.onvif.OnvifConnection] - Camera is not reachable on ONVIF port:888 or the port may be wrong.
10:18:50.850 [INFO ] [ome.event.ThingStatusInfoChangedEvent] - 'ipcamera:onvif:192168162' changed from OFFLINE (CONFIGURATION_ERROR): Camera failed to report a valid Snaphot and/or RTSP URL. See readme on how to use the SNAPSHOT_URL_OVERRIDE feature. to OFFLINE (COMMUNICATION_ERROR): Connection Timeout: Check your IP and PORT are correct and the camera can be reached.

I can also access the snapshot url in any browser.

This line is the reason:
Camera is not reachable on ONVIF port:888 or the port may be wrong.

That seems to be occuring when the camera asks for GetEventProperties which seems to reinforce that the camera has a bug or is missing the implementation of ONVIF events.

I think the solution / work around for this will be simple. Give the binding the wrong ONVIF PORT deliberately and provide the rtsp and snapshot urls manually to the binding. That should get you working with no downsides.

Thanks, actually the issue was different. I haven’t set in the advanced settings the port to 88. So only setting the ONVIF to 888 wasn’t enough.

Now it can retrieve the snapshot and rtsp.

The only thing is missing now is that I get motion detection alerts in the native foscam app, but the corresponding item in openhab is always null. Will need to dig deeper into that if the events are correctly sent from the camera.

Are U setting up as onvif or foscam thing type?

In the meantime I tried both. The above approach was ONVIF, now also tried with foscam thing, which works that the thing is online, but still the motion alarm is not set to ON, whilte it’s configured to be activated:

openhab> smarthome:status FoscamCameraWithAPI_MotionAlarmONOFF
ON
openhab> smarthome:status FoscamCameraWithAPI_MotionAlarm
OFF

While the TRACE log even looks like it’s getting a motionDetectAlarm back (the value changes from 1 to 2).

Example no motion:

14:42:46.541 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.61:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=tobias&pwd=********
14:42:46.635 [TRACE] [mera.internal.handler.IpCameraHandler] - HTTP Result back from camera is  :<CGI_Result>
<result>0</result>
<IOAlarm>0</IOAlarm>
<motionDetectAlarm>1</motionDetectAlarm>
<soundAlarm>0</soundAlarm>
<record>0</record>
<sdState>0</sdState>
<sdFreeSpace>0k</sdFreeSpace>
<sdTotalSpace>0k</sdTotalSpace>
<ntpState>1</ntpState>
<ddnsState>0</ddnsState>
<url></url>
<upnpState>0</upnpState>
<isWifiConnected>0</isWifiConnected>
<wifiConnectedAP></wifiConnectedAP>
<infraLedState>0</infraLedState>
<humanDetectAlarmState>0</humanDetectAlarmState>
</CGI_Result>
:
14:42:46.635 [DEBUG] [mera.internal.handler.IpCameraHandler] - End of FOSCAM handler reached, so closing the channel to the camera now

Example with motion:

14:44:06.616 [TRACE] [mera.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.61:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=tobias&pwd=2siurhghl
14:44:06.679 [TRACE] [mera.internal.handler.IpCameraHandler] - HTTP Result back from camera is  :<CGI_Result>
<result>0</result>
<IOAlarm>0</IOAlarm>
<motionDetectAlarm>2</motionDetectAlarm>
<soundAlarm>0</soundAlarm>
<record>0</record>
<sdState>0</sdState>
<sdFreeSpace>0k</sdFreeSpace>
<sdTotalSpace>0k</sdTotalSpace>
<ntpState>1</ntpState>
<ddnsState>0</ddnsState>
<url></url>
<upnpState>0</upnpState>
<isWifiConnected>0</isWifiConnected>
<wifiConnectedAP></wifiConnectedAP>
<infraLedState>0</infraLedState>
<humanDetectAlarmState>0</humanDetectAlarmState>
</CGI_Result>
:
14:44:06.694 [DEBUG] [mera.internal.handler.IpCameraHandler] - End of FOSCAM handler reached, so closing the channel to the camera now

This leaves me now very optimistic, that the motion detection is working, there’s even an api to get it, just needs to be reflected correctly into openhab now :slight_smile:

So removed now everything and started from scratch. It’s a shame for myself, but it’s working now fine as a foscam thing. :see_no_evil:

1 Like

I believe I’m having a similar issue with my FOSCAM 9803 and 9831 cameras. I had both of them working fine in OH2. Now that I’ve migrated to OH3 I can get motion detection working using the ONVIF capabilities of the cameras. However it doesn’t persist a restart of OH. Here are the details:

  • I’ve installed the cameras by adding the camera things manually using the “FOSCAM with API” thing
  • Other than setting the Username, Password, and Server port settings, I’ve left everything as default
  • ffmpeg is installed using “apt”
  • Video feeds work fine
  • I’ve set up the motion detection settings on the camera’s setup pages with detection area and schedule
  • ONVIF port is 888 on camera and OH settings

Here’s some excerpt from the logs on initial setup. Everything seems OK:

2021-01-27 08:57:49.015 [DEBUG] [era.internal.handler.IpCameraHandler] - File server for camera at 192.168.50.83 has started on port 8063 for all NIC's.
2021-01-27 08:57:49.021 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetSystemDateAndTime
2021-01-27 08:57:49.441 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:chan="http://schemas.microsoft.com/ws/2005/02/duplex" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xmime="http://tempuri.org/xmime.xsd" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"><SOAP-ENV:Body><tds:GetSystemDateAndTimeResponse><tds:SystemDateAndTime xsi:type="tt:SystemDateTime"><tt:DateTimeType>NTP</tt:DateTimeType><tt:DaylightSavings>true</tt:DaylightSavings><tt:TimeZone xsi:type="tt:TimeZone"><tt:TZ>CST5:00:00DST1:00:00,M1.1.0/2,M12.5.0/2</tt:TZ></tt:TimeZone><tt:UTCDateTime xsi:type="tt:DateTime"><tt:Time xsi:type="tt:Time"><tt:Hour>12</tt:Hour><tt:Minute>57</tt:Minute><tt:Second>47</tt:Second></tt:Time><tt:Date xsi:type="tt:Date"><tt:Year>2021</tt:Year><tt:Month>1</tt:Month><tt:Day>27</tt:Day></tt:Date></tt:UTCDateTime><tt:LocalDateTime xsi:type="tt:DateTime"><tt:Time xsi:type="tt:Time"><tt:Hour>8</tt:Hour><tt:Minute>57</tt:Minute><tt:Second>47</tt:Second></tt:Time><tt:Date xsi:type="tt:Date"><tt:Year>2021</tt:Year><tt:Month>1</tt:Month><tt:Day>27</tt:Day></tt:Date></tt:LocalDateTime></tds:SystemDateAndTime></tds:GetSystemDateAndTimeResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

Other that this little blip, which doesn’t seem to be concerning:

2021-01-27 08:57:49.826 [DEBUG] [amera.internal.onvif.OnvifConnection] - deviceXAddr:/onvif/device_service
2021-01-27 08:57:49.827 [DEBUG] [amera.internal.onvif.OnvifConnection] - We hit an issue parsing url:/
2021-01-27 08:57:49.827 [DEBUG] [amera.internal.onvif.OnvifConnection] - mediaXAddr:/onvif/device_service
2021-01-27 08:57:49.827 [DEBUG] [amera.internal.onvif.OnvifConnection] - ptzXAddr:/onvif/device_service
2021-01-27 08:57:49.828 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetProfiles
2021-01-27 08:57:50.313 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="UTF-8"?>

After a bit more initialization I just get a continuous stream of this:
2021-01-27 08:57:53.117 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.50.83:88/cgi-bin/CGIProxy.fcgi?usr=openhab&pwd=OpenHAB3&cmd=snapPicture2

However, motion detection doesn’t work, even though “enableMotionAlarm” is ON (by default). In order to get motion detection to work, I have to do this:

  1. Turn “enableMotionAlarm” OFF, then back ON

  2. This starts showing up in the logs:

    2021-01-27 09:21:31.355 [DEBUG] [era.internal.handler.IpCameraHandler] - End of FOSCAM handler reached, so closing the channel to the camera now
    2021-01-27 09:21:31.355 [DEBUG] [era.internal.handler.IpCameraHandler] - Reply is chunked.
    2021-01-27 09:21:31.355 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is :

The XML data seems to indicate that the motion alarm is enabled: <motionDetectAlarm>1</motionDetectAlarm>

But the motion detection STILL doesn’t work. The reason is that the detection area and schedule have been reset in the settings of the cameras. Finally, if I go in and change these settings in the camera setup, motion detection will work.

But, if and when I restart OH, I have to repeat the above process. I’ve even put the “enableMotionAlarm” in persistance as “restoreOnStartup”, but that doesn’t seem to help.

Any thoughts?

Thanks again for the great work and help!

EDIT: Additional info: If I try to add the cameras using the auto-discover, it discovers them as “ONVIF”, not “FOSCAM with API”. Should I use the autodiscover instead of the “FOSCAM with API”? I can’t find any definitive documentation whether these cameras have an API but it seems to me that they should.

Can you send me some TRACE level log of when the discovery scan is done then please? If the binding can not determine the brand it will fall back to just using onvif thing type.

When setup as onvif thing type it will use ONVIF methods to capture the alarms.
When setup as foscam thing type it will not use ONVIF, but instead use the API to fetch the alarms.

This way if a bug exists there is a way to work around an issue.

That is concerning if you setup as onvif thing type as it is failing to find the X address for ONVIF events. It appears you camera does not have ONVIF events implemented, you could confirm this by trying to see events with the ‘ONVIF device manager’ program. If it works in that program, then contact me about fault finding it further… If you setup with foscam that blip means nothing as the API is used as mentioned above.

Have you read the required setup steps for Foscam in the documentation? It mentions what extra step you need to do to have the detection area and schedule get setup correctly.

Then your camera has a working API in it otherwise that would not work.

Hi Matt,

Thanks for the info and reply. Here is the trace output from the Thing “scan”:

2021-02-03 13:12:46.725 [TRACE] [camera.internal.onvif.OnvifDiscovery] - Device replied to discovery with:DatagramPacket(/192.168.50.84:3702 => /0.0.0.0:54917, PooledUnsafeDirectByteBuf(ridx: 0, widx: 2048, cap: 2048))
2021-02-03 13:12:46.726 [INFO ] [camera.internal.onvif.OnvifDiscovery] - Possible ONVIF camera found at:192.168.50.84
2021-02-03 13:12:46.731 [TRACE] [camera.internal.onvif.OnvifDiscovery] - Device replied to discovery with:DatagramPacket(/192.168.50.83:3702 => /0.0.0.0:54917, PooledUnsafeDirectByteBuf(ridx: 0, widx: 2048, cap: 2048))
2021-02-03 13:12:46.732 [INFO ] [camera.internal.onvif.OnvifDiscovery] - Possible ONVIF camera found at:192.168.50.83

In regards to following the instructions for the FOSCAM cameras, when I put the following URL into my browser:

http://192.168.50.84:88/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig1&usr=openhab&pwd=XXXXX

This is all that is returned:
<CGI_Result>
-3
</CGI_Result>

FYI, the cameras are:

192.168.50.83:88 is a FOSCAM 9821
192.168.50.84:88 is a FOSCAM 9803

The HTTP port 88 was the default for both. As well, the ONVIF port default was 888.

Thanks again for the help.

Thank you I made a PR to fix discovery for Foscam. Did you work out the motion detection?

Great Matt, thanks. Well, I kinda have the motion detection worked out. It works if I do the following:

  1. Switch enableMotionAlarm OFF, then back ON
  2. Go into the web configurator for the camera and reselect the detection area and schedule

The problem is, I have to do that each time there is a restart of OpenHAB.

This same configuration worked fine in OpenHAB 2. It’s only since I’ve moved to OH3 that I’ve experienced this issue.

I’ve re-read your instructions regarding customMotionAlarmUrl and I’ve tried a few times since to enter the URL you give for retrieving the customMotionAlarmUrl, but it doesn’t return anything resembling a usable URL I know as well that I didn’t do any of that when I had it working in OH2.

This is one area of the Foscam API that I do not like as AFAIK you have to include the area in pixels and schedule and there is no way to simply say “turn on with my last used settings”.

Can you leave it turned on and reboot and it still works?

No it does not give you the url, you have to use the Foscam API documentation hand in hand with what it returns and build a suitable url up following its guidance.

Do you have the thing file that you used? The code for foscam has not changed in a very long time as I do not have a camera to test with so I do not play with the code.

Also I have looked at other home automation platforms and they do not offer the ability to turn it on and off.

@jrussell05
EDIT: Can you see if there is a way to turn it on and off via the ONVIF device manager program? That may be a way to implement it and extend features for other brands.

That means your user/pass is wrong or your not using an admin user that is allowed access to that. Special characters and even a space can cause issues when in a URL, you may need to change a password to get it working which this should not happen in the binding as it should encode the URL correctly to handle these cases so the TRACE logs of the binding could show you the way to enter the password in.

Can you try this URL in the config of the camera replacing the usr and pwd of course?

/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&usr=xxx&pwd=yyy

OK, so I have success with getting an XML return of the getMotionConfig cmd. Not sure exactly what I was doing wrong with the config string before, maybe it was something do with the usr/pwd combo.

Here’s the situation now: I’ve entered the appropriate customMotionAlarmUrl in the Thing configuration. However, on a restart of OH3, motion detection still doesn’t seem to be enabled, even though enableMotionAlarm is ON.

If I cycle enableMotionAlarm ON, then OFF, motion detection starts working. Because I’ve entered the new customMotionAlarmUrl in the config, I don’t have to go into the web config of the camera and enter the settings.

After I cycle the enableMotionAlarm switch, this starts showing up the in the logs:

2021-02-14 13:29:55.684 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is    :<CGI_Result>
    <result>0</result>
    <IOAlarm>0</IOAlarm>
    <motionDetectAlarm>1</motionDetectAlarm>
    <soundAlarm>0</soundAlarm>
    <record>0</record>
    <sdState>0</sdState>
    <sdFreeSpace>0k</sdFreeSpace>
    <sdTotalSpace>0k</sdTotalSpace>
    <ntpState>1</ntpState>
    <ddnsState>0</ddnsState>
    <url>http%3A%2F%2Fhf4107.myfoscam.org%3A88</url>
    <upnpState>0</upnpState>
    <isWifiConnected>0</isWifiConnected>
    <wifiConnectedAP></wifiConnectedAP>
    <infraLedState>1</infraLedState>
</CGI_Result>

Matt, in regards to using ONVIF configurator to enable or get motion detection settings, it doesn’t appear possible with the Foscam cameras I have.

Also, for those who are reading, the API documentation I found and used to create the URL for the customMotionAlarmURL for the Foscam cameras was here:

Foscam API Doc

Here was my Thing config from OH2. The only interesting thing that I can see is that the ONVIF port was actually incorrect (80 instead of 888), yet, as I said, everything seemed to work better.

"ipcamera:foscam:11bc37bb": {
    "class": "org.eclipse.smarthome.core.thing.internal.ThingImpl",
    "value": {
      "label": "Garage FOSCAM 9803 Camera",
      "channels": [
....
      ],
      "configuration": {
        "properties": {
          "mjpegOptions": "-q:v 5 -r 2 -vf scale\u003d640:-2 -update 1",
          "ipAddress": "192.168.50.84",
          "updateImageWhen": "0",
          "onvifPort": 80,
          "gifPreroll": 0,
          "ffmpegLocation": "/usr/bin/ffmpeg",
          "serverPort": 8062,
          "ffmpegOutput": "/etc/openhab2/html/camera1/",
          "ipWhitelist": "(127.0.0.1)(192.168.50.48)(192.168.50.70)",
          "mp4OutOptions": "-c:v copy -c:a copy",
          "pollTime": 1000,
          "password": "XXXXXX",
          "port": 88,
          "ptzContinuous": false,
          "onvifMediaProfile": 0,
          "hlsOutOptions": "-strict -2 -f lavfi -i aevalsrc\u003d0 -acodec aac -vcodec copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4",
          "gifOutOptions": "-r 2 -filter_complex scale\u003d-2:360:flags\u003dlanczos,setpts\u003d0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse",
          "username": "XXX"
        }
      },
      "properties": {},
      "uid": {
        "segments": [
          "ipcamera",
          "foscam",
          "11bc37bb"
        ]
      },
      "thingTypeUID": {
        "segments": [
          "ipcamera",
          "foscam"
        ]
      },
      "location": "Garage"
    }
  },

ok I found and fixed an issue cause by the framework no sending REFRESH anymore in V3. Try this build here. To use you need to uninstall the merged binding and then drop all the jar files unzipped into the addons folder. This build should have working discovery and also the alarm should keep getting polled every 8 seconds.

Index of /openhab/IpCameraBinding/ (pcmus.com)