IpCamera: New IP Camera Binding

I will try to re-config the binding based on your configuration and report later. Thanks for your supports!

Hi Uli. Thank you!
After hours of struggling with the camera binding, finally I get it to work! Now I can see HLS streams of the camera in Sitemap. The point is, the password is the Secret Code that printed behind of camera, not the password that I’ve set in the Imou software. I don’t know why maybe it’s my mistake, but at least it worked. :slight_smile:

Now I’m trying to get the camera’s alarms. I want to get a message from openHAB if the camera detects a motion when I’m away from home, but I don’t know how to start :smiley:

Hey guys,
Is it possible to show the stream on an Echo Show (or the Alexa App for that matter)?
I tried adding the Endpoint.Camera metadata to the camera group (which is detected as camera by the Echo), but the Alexa app tells me that live video is not supported.
Any ideas on how this would need to be set up (if it’s possible)?

Oh, @downloadme4free I just use the Telegram binding for notifications.

Regards
mancer

You may want to open your own thread on this. I only own google home products and since they allow you to cast HLS streams it is easily done with just about any camera and the binding. What formats Alexa allows I have no idea but would not be surprised if they only work with a limited number of cameras that probably pay to be Alexa compatible. You would need to look at what the Alexa binding offers as this is a question about that binding and not the camera binding, hence why you should open a new thread.

IMHO we really should be moving towards using a tablet and openHABs features like the new main UI and HABot so we invest in opensource solutions that keep things local, private and wont get discontinued to force you to buy the newer model. But the cheap cloud based hubs are just so tempting I know :slight_smile:
HABot - UIs | openHAB

1 Like

I’ve now spent hours figuring out how a virtual switch is triggered when motion is detected. I have an Instar camera, have already scoured the forum and the instar wiki, unfortunately it is mainly about executing commands using MQTT, but not about receiving commands. Has anyone set this up and can help me? … and it doesn’t necessarily have to be MQTT, my goal is just that i can process a movement in openHAB. Thank you in advance!

Following the IpCamera Binding, maybe your Instar camera does support ONVIF so you can try ONVIF thing type

I’m using openHAB’s sendBroadcastNotification function and it does good job :slightly_smiling_face: Thank you!
I was only can’t get the motion alarm from my camera, but now I can since I simply changed the camera thing type from “dahua” to “onvif”

What firmware version and model camera? It needs to be a recent firmware for it to work.

@downloadme4free and @matt1 thanks for your answers.

I have already integrated the camera into openHAB via ONVIF, the firmware is up-to-date (Ver. 4.1.2.48).
The alarm server of the camea has already been activated - “POST request” and “Attach alarm trigger” are also activated.

I assume that I have to enter the REST API call under alarm server address, but what do I have to enter for the server path? I also think that a request parameter will also be necessary.

According to the Instar forum, i should now try to receive the POST request via the REST API from openHAB in order to be able to process the trigger, but i can’t get any further here - do i do that with “curl -X POST” or with the HTTP-binding or is it maybe something completely different?

Here is the link to the INSTAR forum, the post was unfortunately written in German, the answer too:

The alarm server is what is used however the binding sets this up automatically for you as it uses a different method using the cameras serverPort. If you setup as onvif thing type it will use the onvif events which do not work as nice and you lose other features the camera has when used with the api.
Can you send some trace level logs when the camera connects? Use the pause and unpause button to trigger it to reconnect.

2 Likes

thanks @matt1 i have now been able to verify the problem.

I have openHAB running in a Docker. The binding takes the “main network address” during the automatic configuration (channels etc.), which was in a different subnet for me through the Docker container. I have now selected the correct address in the openHAB network settings and everything worked right away.

I would like to take this opportunity to thank you for the work on this binding, great job!

1 Like

Hi matt1, my camera is an Imou IPC-A22E, it can be recognized by binding as a Dahua camera. I have defined it in the .things file as bellow:

Thing ipcamera:dahua:Livingroom_Imou @ "Livingroom" [ 
  ipAddress="192.168.0.214", 
  username="admin", 
  password="password_here",
  port=37777,
  onvifPort=80,
  pollTime=2000,
  onvifMediaProfile=1,
  ffmpegInput="rtsp://192.168.0.214:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif",
  serverPort=54321
]

And in the .items file:

// IMOU IP CAMERA
Switch CameraMotionAlarm "Motion detected" <camera> { channel="ipcamera:dahua:Livingroom_Imou:motionAlarm" }
Switch CameraLineCrossingAlarm "Line crossing alarm" <camera> { channel="ipcamera:dahua:Livingroom_Imou:lineCrossingAlarm" }
Switch CameraLCellMotionAlarm "Cell motion alarm" <camera> { channel="ipcamera:dahua:Livingroom_Imou:cellMotionAlarm" }
Switch CameraEnableMotionAlarm "Enable motion" <switch> { channel="ipcamera:dahua:Livingroom_Imou:enableMotionAlarm" }
Switch CameraEnableLineCrossing "Enable line crossing" <switch> { channel="ipcamera:dahua:Livingroom_Imou:enableLineCrossingAlarm" }

String CameraLastMotionType "Last motion type" <camera> { channel="ipcamera:dahua:Livingroom_Imou:lastMotionType" }
String CameraHlsStreamUrl "Livingroom camera" { channel="ipcamera:dahua:Livingroom_Imou:hlsUrl", ga="Camera" [ protocols="hls" ] }
String CameraImageUrl "Livingroom camera" { channel="ipcamera:dahua:Livingroom_Imou:imageUrl" }
String CameraMjpegUrl "Mjpeg Url" { channel="ipcamera:dahua:Livingroom_Imou:mjpegUrl" }
Switch CameraStartHLS { channel="ipcamera:dahua:Livingroom_Imou:startStream" }
Number CameraRecordingGif "GIF recording" { channel="ipcamera:dahua:Livingroom_Imou:recordingGif" }
Number CameraRecordingMp4 "MP4 recording" { channel="ipcamera:dahua:Livingroom_Imou:recordingMp4" }

If I define it as an “onvif” thing then the camera is working as I expected. I can have “motionAlarm”, can “recordingGif”, can get HLS stream…

But if I define it as a “dahua” (like quoted above) then nothing work
openHAB log is like bellow (sorry for the mess):

2021-07-28 20:48:25.596 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'ipcamera:dahua:Livingroom_Imou' changed from UNINITIALIZED (DISABLED) to INITIALIZING
==> /var/log/openhab/openhab.log <==
2021-07-28 20:48:25.606 [DEBUG] [era.internal.handler.IpCameraHandler] - File server for camera at 192.168.0.214 has started on port 54321 for all NIC's.
2021-07-28 20:48:25.610 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetSystemDateAndTime
2021-07-28 20:48:25.638 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="utf-8" standalone="yes" ?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:sc="http://www.w3.org/2003/05/soap-encoding" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl"><s:Header></s:Header><s:Body><tds:GetSystemDateAndTimeResponse><tds:SystemDateAndTime><tt:DateTimeType>Manual</tt:DateTimeType><tt:DaylightSavings>false</tt:DaylightSavings><tt:TimeZone><tt:TZ>GMT+07:00</tt:TZ></tt:TimeZone><tt:UTCDateTime><tt:Time><tt:Hour>13</tt:Hour><tt:Minute>48</tt:Minute><tt:Second>24</tt:Second></tt:Time><tt:Date><tt:Year>2021</tt:Year><tt:Month>7</tt:Month><tt:Day>28</tt:Day></tt:Date></tt:UTCDateTime></tds:SystemDateAndTime></tds:GetSystemDateAndTimeResponse></s:Body></s:Envelope>
2021-07-28 20:48:25.639 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetCapabilities
2021-07-28 20:48:25.646 [DEBUG] [amera.internal.onvif.OnvifConnection] - Cameras  UTC dateTime is:2021-7-28T13:48:24
2021-07-28 20:48:25.647 [DEBUG] [amera.internal.onvif.OnvifConnection] - Openhabs UTC dateTime is:2021-07-28T13:48:25.647Z
2021-07-28 20:48:25.687 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="utf-8" standalone="yes" ?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:sc="http://www.w3.org/2003/05/soap-encoding" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl"><s:Body><tds:GetCapabilitiesResponse><tds:Capabilities><tt:Device><tt:XAddr>http://192.168.0.214/onvif/device_service</tt:XAddr><tt:Network><tt:IPFilter>false</tt:IPFilter><tt:IPVersion6>false</tt:IPVersion6><tt:DynDNS>false</tt:DynDNS><tt:Extension><tt:Dot11Configuration>false</tt:Dot11Configuration></tt:Extension></tt:Network><tt:System><tt:DiscoveryResolve>false</tt:DiscoveryResolve><tt:DiscoveryBye>true</tt:DiscoveryBye><tt:RemoteDiscovery>false</tt:RemoteDiscovery><tt:SystemBackup>false</tt:SystemBackup><tt:SystemLogging>false</tt:SystemLogging><tt:FirmwareUpgrade>false</tt:FirmwareUpgrade><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>00</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>10</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>30</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>40</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>42</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>16</tt:Major><tt:Minor>12</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>18</tt:Major><tt:Minor>06</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>18</tt:Major><tt:Minor>12</tt:Minor></tt:SupportedVersions><tt:Extension><tt:HttpFirmwareUpgrade>false</tt:HttpFirmwareUpgrade><tt:HttpSystemBackup>false</tt:HttpSystemBackup><tt:HttpSystemLogging>false</tt:HttpSystemLogging><tt:HttpSupportInformation>false</tt:HttpSupportInformation></tt:Extension></tt:System><tt:IO><tt:InputConnectors>0</tt:InputConnectors><tt:RelayOutputs>0</tt:RelayOutputs></tt:IO><tt:Security><tt:TLS1.1>false</tt:TLS1.1><tt:TLS1.2>false</tt:TLS1.2><tt:OnboardKeyGeneration>false</tt:OnboardKeyGeneration><tt:AccessPolicyConfig>false</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:Extension><tt:TLS1.0>false</tt:TLS1.0><tt:Extension><tt:Dot1X>false</tt:Dot1X><tt:SupportedEAPMethod>0</tt:SupportedEAPMethod><tt:RemoteUserHandling>false</tt:RemoteUserHandling></tt:Extension></tt:Extension></tt:Security></tt:Device><tt:Events><tt:XAddr>http://192.168.0.214/onvif/event_service</tt:XAddr><tt:WSSubscriptionPolicySupport>true</tt:WSSubscriptionPolicySupport><tt:WSPullPointSupport>true</tt:WSPullPointSupport><tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport></tt:Events><tt:Imaging><tt:XAddr>http://192.168.0.214/onvif/imaging_service</tt:XAddr></tt:Imaging><tt:Media><tt:XAddr>http://192.168.0.214/onvif/media_service</tt:XAddr><tt:StreamingCapabilities><tt:RTPMulticast>false</tt:RTPMulticast><tt:RTP_TCP>true</tt:RTP_TCP><tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP></tt:StreamingCapabilities><tt:Extension><tt:ProfileCapabilities><tt:MaximumNumberOfProfiles>6</tt:MaximumNumberOfProfiles></tt:ProfileCapabilities></tt:Extension></tt:Media><tt:Extension><tt:DeviceIO><tt:XAddr>http://192.168.0.214/onvif/deviceIO_service</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:SerialPorts>0</tt:SerialPorts><tt:DigitalInputs>0</tt:DigitalInputs></tt:DeviceIO></tt:Extension></tds:Capabilities></tds:GetCapabilitiesResponse></s:Body></s:Envelope>
2021-07-28 20:48:25.689 [DEBUG] [amera.internal.onvif.OnvifConnection] - deviceXAddr:/onvif/device_service
2021-07-28 20:48:25.690 [DEBUG] [amera.internal.onvif.OnvifConnection] - eventsXAddr:/onvif/event_service
2021-07-28 20:48:25.691 [DEBUG] [amera.internal.onvif.OnvifConnection] - mediaXAddr:/onvif/media_service
2021-07-28 20:48:25.692 [DEBUG] [amera.internal.onvif.OnvifConnection] - We hit an issue parsing url:
2021-07-28 20:48:25.693 [TRACE] [amera.internal.onvif.OnvifConnection] - Camera must not support PTZ, it failed to give a <tt:PTZ><tt:XAddr>:<?xml version="1.0" encoding="utf-8" standalone="yes" ?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:sc="http://www.w3.org/2003/05/soap-encoding" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl"><s:Body><tds:GetCapabilitiesResponse><tds:Capabilities><tt:Device><tt:XAddr>http://192.168.0.214/onvif/device_service</tt:XAddr><tt:Network><tt:IPFilter>false</tt:IPFilter><tt:IPVersion6>false</tt:IPVersion6><tt:DynDNS>false</tt:DynDNS><tt:Extension><tt:Dot11Configuration>false</tt:Dot11Configuration></tt:Extension></tt:Network><tt:System><tt:DiscoveryResolve>false</tt:DiscoveryResolve><tt:DiscoveryBye>true</tt:DiscoveryBye><tt:RemoteDiscovery>false</tt:RemoteDiscovery><tt:SystemBackup>false</tt:SystemBackup><tt:SystemLogging>false</tt:SystemLogging><tt:FirmwareUpgrade>false</tt:FirmwareUpgrade><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>00</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>10</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>20</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>30</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>40</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>2</tt:Major><tt:Minor>42</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>16</tt:Major><tt:Minor>12</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>18</tt:Major><tt:Minor>06</tt:Minor></tt:SupportedVersions><tt:SupportedVersions><tt:Major>18</tt:Major><tt:Minor>12</tt:Minor></tt:SupportedVersions><tt:Extension><tt:HttpFirmwareUpgrade>false</tt:HttpFirmwareUpgrade><tt:HttpSystemBackup>false</tt:HttpSystemBackup><tt:HttpSystemLogging>false</tt:HttpSystemLogging><tt:HttpSupportInformation>false</tt:HttpSupportInformation></tt:Extension></tt:System><tt:IO><tt:InputConnectors>0</tt:InputConnectors><tt:RelayOutputs>0</tt:RelayOutputs></tt:IO><tt:Security><tt:TLS1.1>false</tt:TLS1.1><tt:TLS1.2>false</tt:TLS1.2><tt:OnboardKeyGeneration>false</tt:OnboardKeyGeneration><tt:AccessPolicyConfig>false</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:Extension><tt:TLS1.0>false</tt:TLS1.0><tt:Extension><tt:Dot1X>false</tt:Dot1X><tt:SupportedEAPMethod>0</tt:SupportedEAPMethod><tt:RemoteUserHandling>false</tt:RemoteUserHandling></tt:Extension></tt:Extension></tt:Security></tt:Device><tt:Events><tt:XAddr>http://192.168.0.214/onvif/event_service</tt:XAddr><tt:WSSubscriptionPolicySupport>true</tt:WSSubscriptionPolicySupport><tt:WSPullPointSupport>true</tt:WSPullPointSupport><tt:WSPausableSubscriptionManagerInterfaceSupport>false</tt:WSPausableSubscriptionManagerInterfaceSupport></tt:Events><tt:Imaging><tt:XAddr>http://192.168.0.214/onvif/imaging_service</tt:XAddr></tt:Imaging><tt:Media><tt:XAddr>http://192.168.0.214/onvif/media_service</tt:XAddr><tt:StreamingCapabilities><tt:RTPMulticast>false</tt:RTPMulticast><tt:RTP_TCP>true</tt:RTP_TCP><tt:RTP_RTSP_TCP>true</tt:RTP_RTSP_TCP></tt:StreamingCapabilities><tt:Extension><tt:ProfileCapabilities><tt:MaximumNumberOfProfiles>6</tt:MaximumNumberOfProfiles></tt:ProfileCapabilities></tt:Extension></tt:Media><tt:Extension><tt:DeviceIO><tt:XAddr>http://192.168.0.214/onvif/deviceIO_service</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:SerialPorts>0</tt:SerialPorts><tt:DigitalInputs>0</tt:DigitalInputs></tt:DeviceIO></tt:Extension></tds:Capabilities></tds:GetCapabilitiesResponse></s:Body></s:Envelope>
2021-07-28 20:48:25.695 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetProfiles
2021-07-28 20:48:25.750 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="utf-8" standalone="yes" ?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:sc="http://www.w3.org/2003/05/soap-encoding" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema"><s:Body><trt:GetProfilesResponse><trt:Profiles token="Profile000" fixed="true"><tt:Name>Profile000</tt:Name><tt:VideoSourceConfiguration token="VideoSource000"><tt:Name>VideoSource000</tt:Name><tt:UseCount>2</tt:UseCount><tt:SourceToken>VideoSource000</tt:SourceToken><tt:Bounds x="0" y="0" width="1920" height="1080"></tt:Bounds></tt:VideoSourceConfiguration><tt:VideoEncoderConfiguration token="VideoEncoder000"><tt:Name>VideoEncoder000</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>H265</tt:Encoding><tt:Resolution><tt:Width>1920</tt:Width><tt:Height>1080</tt:Height></tt:Resolution><tt:Quality>6.000000</tt:Quality><tt:RateControl><tt:FrameRateLimit>25</tt:FrameRateLimit><tt:EncodingInterval>1</tt:EncodingInterval><tt:BitrateLimit>4096</tt:BitrateLimit></tt:RateControl><tt:H265><tt:GovLength>50</tt:GovLength><tt:H265Profile>Main</tt:H265Profile></tt:H265><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.2.4</tt:IPv4Address></tt:Address><tt:Port>40000</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:VideoEncoderConfiguration><tt:MetadataConfiguration token="Metadata000" CompressionType="None" GeoLocation="false"><tt:Name>Metadata000</tt:Name><tt:UseCount>1</tt:UseCount><tt:PTZStatus><tt:Status>false</tt:Status><tt:Position>false</tt:Position></tt:PTZStatus><tt:Events><tt:Filter><wsnt:TopicExpression Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tns1="http://www.onvif.org/ver10/topics">tns1:Media/ConfigurationChanged</wsnt:TopicExpression></tt:Filter></tt:Events><tt:Analytics>true</tt:Analytics><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.2.4</tt:IPv4Address></tt:Address><tt:Port>40000</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:MetadataConfiguration></trt:Profiles><trt:Profiles token="Profile001" fixed="true"><tt:Name>Profile001</tt:Name><tt:VideoSourceConfiguration token="VideoSource000"><tt:Name>VideoSource000</tt:Name><tt:UseCount>2</tt:UseCount><tt:SourceToken>VideoSource000</tt:SourceToken><tt:Bounds x="0" y="0" width="1920" height="1080"></tt:Bounds></tt:VideoSourceConfiguration><tt:VideoEncoderConfiguration token="VideoEncoder001"><tt:Name>VideoEncoder001</tt:Name><tt:UseCount>1</tt:UseCount><tt:Encoding>JPEG</tt:Encoding><tt:Resolution><tt:Width>640</tt:Width><tt:Height>480</tt:Height></tt:Resolution><tt:Quality>4.000000</tt:Quality><tt:RateControl><tt:FrameRateLimit>15</tt:FrameRateLimit><tt:EncodingInterval>1</tt:EncodingInterval><tt:BitrateLimit>6144</tt:BitrateLimit></tt:RateControl><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.2.4</tt:IPv4Address></tt:Address><tt:Port>40016</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:VideoEncoderConfiguration><tt:MetadataConfiguration token="Metadata001" CompressionType="None" GeoLocation="false"><tt:Name>Metadata001</tt:Name><tt:UseCount>1</tt:UseCount><tt:PTZStatus><tt:Status>false</tt:Status><tt:Position>false</tt:Position></tt:PTZStatus><tt:Events><tt:Filter><wsnt:TopicExpression Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tns1="http://www.onvif.org/ver10/topics">tns1:Media/ConfigurationChanged</wsnt:TopicExpression></tt:Filter></tt:Events><tt:Analytics>true</tt:Analytics><tt:Multicast><tt:Address><tt:Type>IPv4</tt:Type><tt:IPv4Address>224.1.2.4</tt:IPv4Address></tt:Address><tt:Port>40016</tt:Port><tt:TTL>64</tt:TTL><tt:AutoStart>false</tt:AutoStart></tt:Multicast><tt:SessionTimeout>PT60S</tt:SessionTimeout></tt:MetadataConfiguration></trt:Profiles></trt:GetProfilesResponse></s:Body></s:Envelope>
2021-07-28 20:48:25.751 [TRACE] [amera.internal.onvif.OnvifConnection] - String was found:Profile000
2021-07-28 20:48:25.752 [TRACE] [amera.internal.onvif.OnvifConnection] - String was found:Profile001
2021-07-28 20:48:25.754 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetSnapshotUri
2021-07-28 20:48:25.757 [TRACE] [amera.internal.onvif.OnvifConnection] - Sending ONVIF request:GetStreamUri
2021-07-28 20:48:25.818 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="utf-8" standalone="yes" ?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:sc="http://www.w3.org/2003/05/soap-encoding" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"><s:Body><s:Fault><s:Code><s:Value>s:Sender</s:Value><s:Subcode><s:Value>ter:ActionNotSupported</s:Value><s:Subcode><s:Value>ter:NotImplemented</s:Value></s:Subcode></s:Subcode></s:Code><s:Reason><s:Text xml:lang="en">This optional method is not implemented</s:Text></s:Reason></s:Fault></s:Body></s:Envelope>
2021-07-28 20:48:25.846 [TRACE] [amera.internal.onvif.OnvifConnection] - Onvif reply is:<?xml version="1.0" encoding="utf-8" standalone="yes" ?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:sc="http://www.w3.org/2003/05/soap-encoding" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:tt="http://www.onvif.org/ver10/schema"><s:Body><trt:GetStreamUriResponse><trt:MediaUri><tt:Uri>rtsp://192.168.0.214:554/cam/realmonitor?channel=1&amp;subtype=0&amp;unicast=true&amp;proto=Onvif</tt:Uri><tt:InvalidAfterConnect>true</tt:InvalidAfterConnect><tt:InvalidAfterReboot>true</tt:InvalidAfterReboot><tt:Timeout>PT0S</tt:Timeout></trt:MediaUri></trt:GetStreamUriResponse></s:Body></s:Envelope>
2021-07-28 20:48:25.847 [DEBUG] [amera.internal.onvif.OnvifConnection] - GetStreamUri:rtsp://192.168.0.214:554/cam/realmonitor?channel=1&amp;subtype=0&amp;unicast=true&amp;proto=Onvif
==> /var/log/openhab/events.log <==
2021-07-28 20:48:29.621 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'ipcamera:dahua:Livingroom_Imou' changed from INITIALIZING to ONLINE
==> /var/log/openhab/openhab.log <==
2021-07-28 20:48:29.621 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.214:37777/cgi-bin/snapshot.cgi?channel=1
2021-07-28 20:48:30.622 [INFO ] [era.internal.handler.IpCameraHandler] - The alarm stream was not running for camera 192.168.0.214, re-starting it now
2021-07-28 20:48:30.628 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.214:37777/cgi-bin/snapshot.cgi?channel=1
2021-07-28 20:48:30.631 [TRACE] [era.internal.handler.IpCameraHandler] - Sending camera: GET: http://192.168.0.214:37777/cgi-bin/eventManager.cgi?action=attach&codes=[All]

So, is the camera doesn’t work with the binding, or I’m missing something?

37777 is a very weird port number for the camera to be serving snapshots TO the binding on. I’m guessing it should be port 80 and that you got mixed up with the serverPort that openHAB will serve the file OUT to any requests. That would stop things working if you set the wrong port.

I noticed that the camera appeared not to respond to GetSnapshotUri ONVIF request, so you may need to manually supply the snapshot url unless the log was not complete…

Then it is highly likely the camera does NOT contain the Dahua API and setting it up as ONVIF instead is the correct thing to do. A trace log from when the camera is scanned and detected by discovery may be helpful if it is getting wrongly detected as dahua. Hopefully it does have the API in it and it is just a matter of you giving the wrong port number instead of leaving it on the default value.

1 Like

Thank you for the reply! :slight_smile:
I disabled the camera textual definition and used scan features from openHAB, the log is look like this:

2021-07-29 21:35:11.987 [TRACE] [camera.internal.onvif.OnvifDiscovery] - Device replied to discovery with:<?xml version="1.0" encoding="utf-8" standalone="yes" ?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:sc="http://www.w3.org/2003/05/soap-encoding" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl"><s:Header><a:MessageID>uuid:5b55c21f-bb9a-4564-bbd0-6ba0f2a659e1</a:MessageID><a:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</a:To><a:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</a:Action><a:RelatesTo>uuid:6825ec96-57f5-4400-8583-6b6212427bf2</a:RelatesTo></s:Header><s:Body><d:ProbeMatches><d:ProbeMatch><a:EndpointReference><a:Address>uuid:2c406ded-92cc-4807-9a4d-024364d336c8</a:Address></a:EndpointReference><d:Types>dn:NetworkVideoTransmitter tds:Device</d:Types><d:Scopes>onvif://www.onvif.org/location/country/china onvif://www.onvif.org/name/Lechange onvif://www.onvif.org/hardware/IPC-A22E onvif://www.onvif.org/Profile/Streaming onvif://www.onvif.org/type/Network_Video_Transmitter onvif://www.onvif.org/extension/unique_identifier/1 odm:name:Imou%20Ranger%202</d:Scopes><d:XAddrs>http://192.168.0.214/onvif/device_service</d:XAddrs><d:MetadataVersion>1</d:MetadataVersion></d:ProbeMatch></d:ProbeMatches></s:Body></s:Envelope>
2021-07-29 21:35:11.993 [INFO ] [camera.internal.onvif.OnvifDiscovery] - Camera found at xAddr:http://192.168.0.214/onvif/device_service
2021-07-29 21:35:11.997 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'ipcamera:dahua:1921680214' to inbox.
==> /var/log/openhab/events.log <==
2021-07-29 21:35:11.997 [INFO ] [openhab.event.InboxAddedEvent       ] - Discovery Result with UID 'ipcamera:dahua:1921680214' has been added.

It neither not working with the detected thing by the binding nor the thing defined in the textual config file, with thing type “dahua”
As I know Imou is a consumer brand name of Dahua. Port number 37777 was detected by Dahua configuration tool. There’s no difference between port 80 or 37777 as I tried both of them in the configuration
Imou IPC-A22E

I also tried to find out camera’s URLs, but only one URL that working was RTSP.

From your logs it shows the camera replies that GetSnapshotUri is not supported. To be called ONVIF compatible it MUST have this implemented, so I can only conclude your camera either has a bug or is not fully ONVIF complient.

Good news is that this will not stop the camera working if you supply the url manually to the binding. When you setup as dahua, it will use a HARD CODED url so if your camera does not follow the Dahua API it would be normal for that url to not work.

When setup as onvif thing type, the discovery MUST work for the camera to work and your camera fails to reply. Since your camera appears to not be PTZ moveable, you can set it up as a ‘generic’ thing type and supply only the RTSP url and that should get you working.

You can always try the ONVIF DEVICE MANAGER program and see if that detects a snapshot, it will also confirm what port is correct. If the camera is behind a NVR it may be blocking it from working and that may be the reason.

1 Like

@matt1: thank you for the awesome binding and your great support :slight_smile:

Hello, does anyone have a Python (Jython) script running? I would like to implement the GIF creation, but it doesn’t work.

getActions("ipcamera", "ipcamera:instar:webcam").recordGIF("ipcamera",5)

I assume it’s because of the getActions command.

Thats my script:

from core.rules import rule
from core.triggers import when
from core.actions import Things

@rule("ipcam_gifcreation_test")
@when("Item dummy_switch changed")

def create_gif(event):
  if items["dummy_switch"] == ON:
    ipcamgif = Things.getActions("ipcamera", "ipcamera:instar:webcam")
    ipcamgif.getActions("ipcamera", "ipcamera:instar:webcam").recordGIF("ipcamera",5)

Error:

14:48:30.744 [WARN ] [jsr223.jython] - Traceback (most recent call last):
File "/openhab/conf/automation/lib/python/core/log.py", line 96, in wrapper return function(*args, **kwargs)
File "/openhab/conf/automation/lib/python/core/rules.py", line 108, in execute self.callback(inputs.get('event'))
File "<script>", line 11, in create_gif
AttributeError: 'org.openhab.binding.ipcamera.internal.IpCameraActi' object has no attribute 'getActions'

Unfortunately, i’m not quite fit in Jython yet, so it would be great if someone could help me, thank you very much!

I am now one step further, now i get the following error:

18:58:46.750 [WARN ] [nhab.binding.ipcamera.internal.Ffmpeg] - An error occured trying to process the messages from FFmpeg.
18:58:46.721 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'webcam_GIFRecording' changed from -5 to 0
18:58:46.750 [WARN ] [nhab.binding.ipcamera.internal.Ffmpeg] - An error occured trying to process the messages from FFmpeg.
18:58:47.561 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'webcam_GIFRecording' changed from 0 to -5
18:58:47.566 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'webcam_GIFHistoryLength' changed from 6 to 7

My script now looks like this:

from core.rules import rule
from core.triggers import when
from core.actions import Things

@rule("ipcam_gifcreation_test_2")
@when("Item dummy_switch changed")

def create_gif(event):
  if items["dummy_switch"] == ON:
    ipcamgif = Things.getActions("ipcamera", "ipcamera:instar:webcam")
    ipcamgif.recordGIF("ipcamera",5)

I do get all the alarms including people and car detection, which reduces the amount of false alarms dramatically. I haven’t yet set up any rules based on that but I linked a timestamp item in addition to the alarm item so I can see when I got the last alarm.

I’m using the ipcamera binding with two Foscam cameras. Working fine in OH 3.1, but I would like to rotate the picture by 90° clockwise. I found that the option -vf transpose=1 should to that thing, so I thought adding it to the snapshot options would help me.
But as soon as I add it no snapshots are created anymore. Also the debug log for org.openhab.binding.ipcamera doesn’t give any error message regarding the snapshot creation.
Is anyone familiar with ffmpeg and has an idea how to and where addign which option to ideally get all images converted? I’m only using the GIF creation (storing recording/sending mails) and ImageLow (displaying in a sitemap).