IpCamera: New IP Camera Binding

So, I have been using this binding for quite some time now, for motion events. I have Dahuas and Hikvisions, and different types of motion work just great. (Mostly using line, area and motion).

However, would like to enhance this now, to also store (atleast) one picture of the actual motion event, and present it in basic UI.
I have my test Dahua set-up as follows;

POLL_CAMERA_MS=10000,
SERVER_PORT=50004,
IMAGE_UPDATE_EVENTS=2,
UPDATE_IMAGE=true,

I read in the oh log, that the image is pulled from the camera on motion, but item image channel is not updated. Should it not do this? Or do I have to do this from a rule? Obviously this is why my picture in basic ui is never updated.
I have read the docs many times now, and I suspect it is too many options for meā€¦ :slight_smile: Most examples seems to be about having the image update continuously, something that Iā€™m not interested in.
Not even sure if I should use the image channel for this purpose, but I think I should.

I do not have each camera in my sitemap, only the camera group.
Group item=gCameras

And for this test cam, items;

Image  FrontCamImage            "Framsidekamera"               (gCameras)                {channel="ipcamera:DAHUA:frontside_cam:image"}
    Switch FrontCamUpdateImage      "Framsida Ta ny bild"          (gCameras)                {channel="ipcamera:DAHUA:frontside_cam:updateImageNow"}
    Switch FrontCamCrossing         "Framsida linje"               (gPersist,gCameras)       {channel="ipcamera:DAHUA:frontside_cam:lineCrossingAlarm"}
    Switch FrontCamMotion           "Framsidekamera rƶrelse"       (gPersist,gCameras)       {channel="ipcamera:DAHUA:frontside_cam:motionAlarm"}
    Switch FrontCamFaceDet          "Framsidekamera ansiktesdet"   (gPersist,gCameras)       {channel="ipcamera:DAHUA:frontside_cam:faceDetected"}
    Switch FrontCamIntrusion        "Framsidekamera omrƄde"        (gPersist,gCameras)       {channel="ipcamera:DAHUA:frontside_cam:fieldDetectionAlarm"}
    String FrontsideCamLastEvt      "Framsidekamera senaste"       (gCameras)                {channel="ipcamera:DAHUA:frontside_cam:lastMotionType"}
    Dimmer FrontsideCamIR           "Framsidekamera IR ljus"       (gCameras)                {channel="ipcamera:DAHUA:frontside_cam:enableLED"}
    DateTime FrontsideCamLastMotion "Framsidekamera tidpunkt [%1$tH:%1$tM %1$tY-%1$tm-%1$td]"  (gCameras)
    Switch FrontsideCamMotionEnable "Framsidekamera rƶrelsedetektering" (gCameras)           {channel="ipcamera:DAHUA:frontside_cam:enableMotionAlarm"}

What am I doing wrong?
Sorry for the very basic question, but I think I have turned blind to the solution nowā€¦

Hi, would you mind sharing model number and firmware version of your Dahua cameras?

Thanks!

Model number IPC HFW4433F-ZSA, China version. Donā€™t know the fw version, but they are about 8 month old. I never dare to update China versionsā€¦

Also, as I have been studying ipcam-binding logs for a while now, both my Hikā€™s (different models and fw), spams the log with these messages;

17:13:18.215 [TRACE] [ding.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 562, cap: 562/562, unwrapped: PooledUnsafeDirectByteBuf(ridx: 562, widx: 562, cap: 8192)), decoderResult: success)
17:13:18.216 [TRACE] [ding.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is  :--boundary
Content-Type: application/xml; charset="UTF-8"
Content-Length: 479

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>10.1.200.19</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>bc:ad:28:3b:88:73</macAddress>
<channelID>1</channelID>
<dateTime>2020-05-14T17:24:28+01:00</dateTime>
<activePostCount>0</activePostCount>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
</EventNotificationAlert>
:

About 5 every second from one of the cameras. The other one seems to send less frequent.

I looked in the camera settings if it is possible to disable video loss alarms, but I canā€™t find a setting that I connect with this event.

Could it be that this needs to be ackā€™d from the binding somehow? If I reboot the cameras while binding/oh is running, they stop with this for a while, but if I e.g. restart ipcamera binding, it seems to come back.
Not a very big deal unless one is studying the log, I guess.

New build 2020-05-16 has these changes which include BREAKING CHANGES.

  • Channel controlMotionAlarm is now changed to ffmpegMotionControl the operation is the same so just do a find and replace and everything will work the same. If you were not using the ffmpeg motion detection you wont notice the change.
  • ffmpegMotionControl should now work on all brands of cameras hence the renaming to prevent confusion with cameras built in motion alarm controls. Idea is that if you want a particular sensitivity on your cameras motion to stop and start recordings, you can use a secondary motion detection that is more sensitive to skip the order of the cameras in a group view.
  • ffmpeg motion detection was broken in builds for the past few weeks, this version fixes and improves the feature.
  • Bug fixes for the image channel @vespaman these should help you.

Try using IMAGE_UPDATE_EVENTS=2, UPDATE_IMAGE=false,

Currently if you turn on the update image channel now to ON it will update the image every poll period, If you have the channel OFF it will only update it on the start of a motion event. If using ffmpeg to generate the snapshots the control needs to be on.

Also I would recommend looking at the GIF feature, you could trigger this when motion occurs and then display the GIF in your Habpanel or sitemap. A picture that moves and keeps looping showing the last motion.

Thank you @matt1 the last version works just out of the box! Iā€™ll take a look at the GIF way now, as per your recommendation (did not want to make things even more complicated before getting the basics to work)!

Cheers,
Micael

Glad it works and u find it useful.
Regarding your other post the video loss messages are normal can not be turned off and are simply how the camera tells devices that there are no alarms at all occurring. You can use debug log mode to watch what occurs without getting the replies back from the camera.

1 Like

@matt1 I installed the binding a week ago and it runs perfect on multiple cameras. Have played with GIF notifications to telegram and now ended up with recording 10sec MP4 files as notification.

In this process it seems that MP4 recording does not work for cameras with NO AUDIO stream. For these cameras the binding creates an empty mp4 file. I traced the error back to the use of ffmpeg option ā€œ-acodec copyā€ and replaced it by option ā€œ-anā€ in case of missing audio. Looking at the very detailed readme file (thanks for this good description!) the ffmpeg use in the binding has similar problems in the HLS part of the binding where you use ā€œ-acodec aacā€ as fallback solution for both cameras with/without audio stream. This works in my case as well.

Please fix this in the mp4 recording routine or allow for external setting of ffmpeg parameters as in case of the HLS routine. Hope this helps to fix the (as I understood experimental) feature of mp4 recording, it is great replacement of GIF notifications for me. Thanks a lot for all your effort!

1 Like

Thanks for the heads up that no audio cameras have issue, will look at that soon. The main hold up on finishing this feature is I wish to use the HLS stream as a source for the preroll footage so you can have footage from before the triggering event, just like the gif can do. This may mean all the footage will have to share the HLS settings so there is no glitch when the recording passes from the preroll into realtime. I will probably also add a new config to store the recordings in a separate folder so the HLS can be in volatile ram and the recordings to disk.

This is the reason it is labelled as experimental as things are likely to change, but it is useful in the meantime for people to provide feedback on how it should work. It should be reliable already as itā€™s using proven code and ffmpeg for the heavy lifting.

Agree with you, PREROLL would be a cool additional feature for MP4 recording! However, as this is available for GIF there are some problems with network traffic in case of preroll already. Continuously polling data from all ipcams makes network health degenerate quite soon, at least if you have more than one ipcam as in my setting. If this can be reduced by using more condensed HLS compared to the current snapshot solution, I would be in favor of this. Think of use cases with multiple cameras this preroll might become a bottleneck for the network, memory and cpu at the end.

Hence, maybe more interesting features would be to include more camera-side functionalities into the binding. Given your future work statement on onvif motion detection, maybe there is more to think of indirectly getting video files from a NVR/FTP/other server solutions on which the camera pushes the videos with low-latency motion detection instead of introducing the continuous pull-solution to overcome latency issues with openhab.

Ideal solution:
cam --pushā€“> ftp-server --pullā€“> openhab (triggered by onvif motion event on the cam)

This might be preferred over continuous pull with snapshots and local/remote filesystem at the end of the pipeline:
cam --pullā€“> openhab --pushā€“> filesystem

What do you think can there be a lightweight solution that uses onvif motion detection as trigger for the push of the camera or do we need costly pull solutions for preroll? At least some cameras allow pushing to ftp servers, but in general this is not true, hence maybe poll solution might cost more but at the same time fit all ipcams?

@MrTBone

I am using a script that calls the last video from my Synology nas and use Telegram to send it to me

just add your own user@synology, your token and message ID, CAMERA name

#!/bin/bash
#
# File to retreive a video from synology server
#

# Set de directory and the selected camera
VIDEODIR='/volume1/surveillance/'
CAMERA='Ingang/'

#determine date and what time of day it
DATUM=$(date +%Y%m%d)
HOUR=$(date +%H)
AMPM='AM'
# this is needed because if locale doesn't use AM-PM for times
# from 12 onwards it is PM
if [[ ${HOUR} -gt '11' ]]
then
  AMPM='PM'
fi

echo "Datumformaat Synology:  ${DATUM}${AMPM}"
# Built the full path
FULLPATH="${VIDEODIR}${CAMERA}${DATUM}${AMPM}/"

# Do a directory check on the remote server
if ssh user@synology  "[ ! -d ${FULLPATH} ]"
then
   echo 'The directory for this time frame is not available yet.' >&2
   exit 1
fi

# Check if there are videos available
FCOUNT=$(ssh user@sysnology ls -f ${FULLPATH}*.mp4 | wc -l)
echo ${FCOUNT}
if [[ ${FCOUNT} -eq 0 ]]
then
   echo 'There is no video available at this moment.' >&2
   exit 1
else
   echo "There are ${FCOUNT} video(s) in this directory."
   echo "Will only show the last one."
fi

# Get the filename of the last video
FILENAME=$(ssh user@synology ls ${FULLPATH} | tail -1)
if [[ ${?} -ne 0 ]]
then
  echo "Something went wrong" >&2
  exit 1
else
echo "${FILENAME}"
fi
SNAPVIDEO="/var/tmp/${FILENAME}"
#copy the video to a local folder
scp user@synology:${FULLPATH}${FILENAME} ${SNAPVIDEO}

#next must make script to send to telegram
# Set the Telegram token
TOKEN="hfhhfhfhhffhhfhfhhfhfhf"

# Set the receiver
RECEIVER="123456789"
SILENT='true'

# Send Telegram message with multiple images
curl -s -X POST "https://api.telegram.org/bot${TOKEN}/sendMediaGroup" -F chat_id="${RECEIVER}" -F media='[{"type":"video","media":"attach://video_1","caption":"Video postbezorging."}]' -F video_1="@$SNAPVIDEO" -F disable_notification="${SILENT}"

# Remove video from /var/tmp
rm $SNAPVIDEO

exit 0

1 Like

Not that I am aware of and I do it with 3-4 cameras at 1 sec poll rate, have done so for years. In regards to running a HLS stream non stop, then that is up to each user to determine if they wish to do that. Just as the GIF feature allows you to not use a preroll and to take the footage on demand, the same reason is why I coded the recording feature to take the footage on demand from RTSP. Both methods could be presented for the user to choose.

Sorry I really only code what I will use myself or I feel is lacking from Openhab that can be done in other automation platforms. Things like changing white balance I really have no drive to add as I donā€™t see the use case being common enough.

Not all cameras support FTP and that sounds like a nightmare to code due to every different brand of camera using a different filename structure. The ā€œFTP uploadā€ binding is worth looking at as it does something similar.

No see above reply due to filenaming issues between brands. I only wish to code features that are consistent between all brands of cameras and that work ā€˜out of the boxā€™. Not saying I will ever reach that goal, but it is what I am aiming for.

BINGO.
Also the cost of polling is not as high as you think, (and the binding can work in ways without any polling) especially if you use JPG compression to reduce size a snapshot can be 200kBytes or even half that and still have a decent picture.
This could be an issue on older PI devices that share the network on the same limited bus as a USB ssd, not that I have ever heard of it happening or crunched real life numbers to know how close it would come.

Hi,

i have a cheap chinese PTZ camera that i wanted to use with the binding.

All it says is Foyu and FO-A02.

All i got right was to get the image from the camera and the PTZ values (with openhab)

It works perfect with the ICsee APP on my phone and the CMS5 (free) software.

If i use the ONVIF Device Manager then it opens the camera, shows a image, but with the refresh it says ā€œNo Signalā€.

The stream works if i use qt and open the link.

in the ICsee APP i can see:

Device Version: R80X20-PQ
Software: V5.00R02.0030695.10010.244306.0000000
Release Date: 2019-08-28 11:02

I understand that i should have a bought a camera that is described aboveā€¦ but jaā€¦ this cameras are expensive here :frowning:
So i install the binding with the lastest JAR files.

ā€œONVIFā€ Generic IP camera with ONVIF support.

The port of the camera that accepts HTTP.
80
ONVIF_PORT:
8899

I used nmap to figure out the ports:
[07:24:19] openhabian@openhab:~$ nmap 192.168.0.188
Starting Nmap 7.70 ( https://nmap.org ) at 2020-05-18 07:24 SAST
Nmap scan report for 192.168.0.188
Host is up (0.0041s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
80/tcp open http
554/tcp open rtsp
8899/tcp open ospf-lite

Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds
[07:24:25] openhabian@openhab:~$

the logfile looks like this:

2020-05-17 16:22:34.412 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.0.188:8899
2020-05-17 16:22:34.431 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - We sucessfully connected to a ONVIF SERVICE:/onvif/device_service
2020-05-17 16:22:34.481 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - We got an ONVIF ptz response:<?xml version="1.0" encoding="UTF-8"?>``
2020-05-17 16:22:34.484 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - ptzNodeToken=000
2020-05-17 16:22:34.491 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - We got an ONVIF ptz response:<?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:xs="http://www.w3.org/2000/10/XMLSchema" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:ns1="http://www.w3.org/2005/05/xmlmime" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:ns7="http://docs.oasis-open.org/wsrf/r-2" xmlns:ns2="http://docs.oasis-open.org/wsrf/bf-2" xmlns:dndl="http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding" xmlns:dnrd="http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:ns10="http://www.onvif.org/ver10/replay/wsdl" xmlns:ns11="http://www.onvif.org/ver10/search/wsdl" xmlns:ns13="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" xmlns:ns14="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:ns15="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:ns16="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:ns17="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:ns18="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:ns19="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding" xmlns:ns20="http://www.onvif.org/ver10/events/wsdl/PullPointBinding" xmlns:ns21="http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding" xmlns:ns22="http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:ns3="http://www.onvif.org/ver10/analyticsdevice/wsdl" xmlns:ns4="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:ns5="http://www.onvif.org/ver10/display/wsdl" xmlns:ns8="http://www.onvif.org/ver10/receiver/wsdl" xmlns:ns9="http://www.onvif.org/ver10/recording/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:trt2="http://www.onvif.org/ver20/media/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tnsn="http://www.eventextension.com/2011/event/topics"><SOAP-ENV:Body><tptz:GetStatusResponse><tptz:PTZStatus><tt:Position><tt:PanTilt y="0" x="0"></tt:PanTilt><tt:Zoom x="0"></tt:Zoom></tt:Position><tt:MoveStatus><tt:PanTilt>IDLE</tt:PanTilt><tt:Zoom>IDLE</tt:Zoom></tt:MoveStatus><tt:UtcTime>1970-01-01T00:00:00Z</tt:UtcTime></tptz:PTZStatus></tptz:GetStatusResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
2020-05-17 16:22:34.493 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - Process new PTZ location now
2020-05-17 16:22:34.495 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - Pan is updating to:50 and the cam value is 0.0
2020-05-17 16:22:34.496 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - We got an ONVIF ptz response:<?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:xs="http://www.w3.org/2000/10/XMLSchema" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:ns1="http://www.w3.org/2005/05/xmlmime" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:ns7="http://docs.oasis-open.org/wsrf/r-2" xmlns:ns2="http://docs.oasis-open.org/wsrf/bf-2" xmlns:dndl="http://www.onvif.org/ver10/network/wsdl/DiscoveryLookupBinding" xmlns:dnrd="http://www.onvif.org/ver10/network/wsdl/RemoteDiscoveryBinding" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:ns10="http://www.onvif.org/ver10/replay/wsdl" xmlns:ns11="http://www.onvif.org/ver10/search/wsdl" xmlns:ns13="http://www.onvif.org/ver20/analytics/wsdl/RuleEngineBinding" xmlns:ns14="http://www.onvif.org/ver20/analytics/wsdl/AnalyticsEngineBinding" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:ns15="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:ns16="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:ns17="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:ns18="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:ns19="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding" xmlns:ns20="http://www.onvif.org/ver10/events/wsdl/PullPointBinding" xmlns:ns21="http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding" xmlns:ns22="http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:ns3="http://www.onvif.org/ver10/analyticsdevice/wsdl" xmlns:ns4="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:ns5="http://www.onvif.org/ver10/display/wsdl" xmlns:ns8="http://www.onvif.org/ver10/receiver/wsdl" xmlns:ns9="http://www.onvif.org/ver10/recording/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:trt2="http://www.onvif.org/ver20/media/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tnsn="http://www.eventextension.com/2011/event/topics"><SOAP-ENV:Body><tptz:GetConfigurationsResponse><tptz:PTZConfiguration token="000"><tt:Name>PTZ_000</tt:Name><tt:UseCount>2</tt:UseCount><tt:NodeToken>000</tt:NodeToken><tt:DefaultRelativePanTiltTranslationSpace>http://www.onvif.org/ver10/tptz/PanTiltSpaces/TranslationGenericSpace</tt:DefaultRelativePanTiltTranslationSpace><tt:DefaultRelativeZoomTranslationSpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace</tt:DefaultRelativeZoomTranslationSpace><tt:DefaultContinuousPanTiltVelocitySpace>http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace</tt:DefaultContinuousPanTiltVelocitySpace><tt:DefaultContinuousZoomVelocitySpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace</tt:DefaultContinuousZoomVelocitySpace><tt:DefaultPTZSpeed><tt:PanTilt space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace" y="1" x="1"></tt:PanTilt><tt:Zoom space="http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace" x="1"></tt:Zoom></tt:DefaultPTZSpeed><tt:DefaultPTZTimeout>PT1S</tt:DefaultPTZTimeout><tt:PanTiltLimits><tt:Range><tt:URI>http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace</tt:URI><tt:XRange><tt:Min>-1</tt:Min><tt:Max>1</tt:Max></tt:XRange><tt:YRange><tt:Min>-1</tt:Min><tt:Max>1</tt:Max></tt:YRange></tt:Range></tt:PanTiltLimits><tt:ZoomLimits><tt:Range><tt:URI>http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace</tt:URI><tt:XRange><tt:Min>-1</tt:Min><tt:Max>1</tt:Max></tt:XRange></tt:Range></tt:ZoomLimits></tptz:PTZConfiguration></tptz:GetConfigurationsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
2020-05-17 16:22:34.497 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - Tilt is updating to:50 and the cam value is 0.0
2020-05-17 16:22:34.500 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - ptzConfigToken=000
2020-05-17 16:22:34.501 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - Zoom is updating to:0 and the cam value is 0.0
2020-05-17 16:22:34.511 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - We got an ONVIF ptz response:<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:.............tt:Name>126</tt:Name></tptz:Preset></tptz:GetPresetsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
2020-05-17 16:22:34.514 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - String was found:0
2020-05-17 16:22:34.516 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - String was found:1
2020-05-17 16:22:34.517 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - We got an ONVIF ptz response:<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:......</SOAP-ENV:Envelope>
2020-05-17 16:22:34.518 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - String was found:2
2020-05-17 16:22:34.520 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - String was found:3
2020-05-17 16:22:34.522 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - String was found:4

so i tried to move the camer with the created item from the PaperUI:

 2020-05-17 16:23:50.491 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to move with new PTZ Absolute move.
 2020-05-17 16:23:50.501 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - We got a ONVIF PTZ ERROR 400:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Text xml:lang="en">Validation constraint violation: tag name or namespace mismatch in element 'Speed'</SOAP-ENV:Text>
2020-05-18 07:01:34.489 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to move with new PTZ Absolute move.
<SOAP-ENV:Text xml:lang="en">Validation constraint violation: tag name or namespace mismatch in element 'Speed'</SOAP-ENV:Text>

I then tried to wireshark the traffic between my Laptop and the camera to see the commands, but somehow i cant not figure it out like no clear text:

So on the one hand the camera works with 2 different apps (iCsee and CMS5) but it doesnt work with the ONVIF device manager (not propperly with video and move; but i could change the IP of camera).

where can i start looking ? are the commands stored in jar file?

I would really like to help the project in any possible way, because i think itā€™s great and there are plenty of challengs because of different camera types and so on.

regards
stefan

Edit: I could figure it out in wireshark and now i can sniff this:

....................{ "AliveInterval" : 30, "ChannelNum" : 1, "DeviceType " : "IPC", "ExtraChannel" : 0, "Ret" : 100, "SessionID" : "0x00000001" }
................|...{ "Name" : "SystemInfo", "Ret" : 100, "SessionID" : "0x00000001", "SystemInfo" : { "AlarmInChannel" : 0, "AlarmOutChannel" : 0, "AudioInChannel" : 1, "BuildTime" : "2019-08-28 11:02:47", "CombineSwitch" : 0, "DeviceModel" : "R80X20-PQ", "DeviceRunTime" : "0x00000ebe", "DigChannel" : 0, "EncryptVersion" : "Unknown", "ExtraChannel" : 0, "HardWare" : "XM530_R80X20-PQ_8M", "HardWareVersion" : "1.01", "SerialNo" : "e1936345ebd25995", "SoftWareVersion" : "V5.00.R02.00030695.10010.244306.0000000", "TalkInChannel" : 1, "TalkOutChannel" : 1, "UpdataTime" : "", "UpdataType" : "0x00000000", "VideoInChannel" : 1, "VideoOutChannel" : 1 } }
................:...{ "Name" : "", "Ret" : 100, "SessionID" : "0x00000001" }.................|...{ "Name" : "SystemInfo", "Ret" : 100, "SessionID" : "0x00000001", "SystemInfo" : { "AlarmInChannel" : 0, "AlarmOutChannel" : 0, "AudioInChannel" : 1, "BuildTime" : "2019-08-28 11:02:47", "CombineSwitch" : 0, "DeviceModel" : "R80X20-PQ", "DeviceRunTime" : "0x00000ebe", "DigChannel" : 0, "EncryptVersion" : "Unknown", "ExtraChannel" : 0, "HardWare" : "XM530_R80X20-PQ_8M", "HardWareVersion" : "1.01", "SerialNo" : "e1936345ebd25995", "SoftWareVersion" : "V5.00.R02.00030695.10010.244306.0000000", "TalkInChannel" : 1, "TalkOutChannel" : 1, "UpdataTime" : "", "UpdataType" : "0x00000000", "VideoInChannel" : 1, "VideoOutChannel" : 1 } }
..............Q....{ "Name" : "SystemFunction", "Ret" : 100, "SessionID" : "0x00000001", "SystemFunction" : { "AlarmFunction" : { "AlarmConfig" : true, "BlindDetect" : true, "HumanDection" : true, "HumanPedDetection" : true, "LossDetect" : true, "MotionDetect" : true, "NetAbort" : true, "NetAlarm" : true, "NetIpConflict" : true, "NewVideoAnalyze" : false, "PEAInHumanPed" : true, "StorageFailure" : true, "StorageLowSpace" : true, "StorageNotExist" : true, "VideoAnalyze" : false }, "CommFunction" : { "CommRS232" : true, "CommRS485" : true }, "EncodeFunction" : { "DoubleStream" : true, "SmartH264" : true, "SmartH264V2" : true, "SnapStream" : true }, "NetServerFunction" : { "IPAdaptive" : false, "Net3G" : false, "Net4GSignalLevel" : false, "NetAlarmCenter" : true, "NetDAS" : false, "NetDDNS" : false, "NetDHCP" : true, "NetDNS" : true, "NetEmail" : true, "NetFTP" : true, "NetIPFilter" : true, "NetMutlicast" : false, "NetNTP" : true, "NetNat" : true, "NetPMS" : true, "NetPMSV2" : true, "NetPPPoE" : false, "NetRTSP" : true, "NetSPVMN" : false, "NetUPNP" : true, "NetWifi" : true, "OnvifPwdCheckout" : true, "RTMP" : false, "WifiModeSwitch" : true, "WifiRouteSignalLevel" : true }, "OtherFunction" : { "NOHDDRECORD" : false, "SupportAdminContactInfo" : false, "SupportAlarmVoiceTips" : true, "SupportAlarmVoiceTipsType" : true, "SupportAppBindFlag" : true, "SupportBT" : true, "SupportCamareStyle" : true, "SupportCameraWhiteLight" : true, "SupportChangeLanguageNoReboot" : true, "SupportCloseVoiceTip" : true, "SupportCommDataUpload" : true, "SupportCorridorMode" : false, "SupportCustomizeLpRect" : false, "SupportDNChangeByImage" : true, "SupportDimenCode" : true, "SupportDoubleLightBoxCamera" : true, "SupportDoubleLightBulb" : false, "SupportElectronicPTZ" : false, "SupportFTPTest" : true, "SupportFaceDetectV2" : false, "SupportFaceRecognition" : false, "SupportMailTest" : true, "SupportMusicBulb433Pair" : false, "SupportMusicLightBulb" : false, "SupportNetWorkMode" : false, "SupportOSDInfo" : false, "SupportOneKeyMaskVideo" : false, "SupportPTZTour" : false, "SupportPWDSafety" : true, "SupportParkingGuide" : false, "SupportPtz360Spin" : false, "SupportRPSVideo" : true, "SupportSetDetectTrackWatchPoint" : false, "SupportSetHardwareAbility" : true, "SupportSetPTZPresetAttribute" : false, "SupportSetVolume" : true, "SupportShowH265X" : true, "SupportSnapCfg" : false, "SupportSnapV2Stream" : true, "SupportSoftPhotosensitive" : false, "SupportStatusLed" : false, "SupportTextPassword" : true, "SupportTimeZone" : true, "SupportTimingSleep" : false, "SupportWebRTCModule" : false, "SupportWriteLog" : true, "SuppportChangeOnvifPort" : true }, "PreviewFunction" : { "Talk" : true, "Tour" : false }, "TipShow" : { "NoBeepTipShow" : true } } }
....................{ "General.General" : { "AutoLogout" : 0, "FontSize" : 24, "IranCalendarEnable" : 0, "LocalNo" : 0, "MachineName" : "LocalHost", "OverWrite" : "OverWrite", "ScreenAutoShutdown" : 10, "ScreenSaveTime" : 0, "VideoOutPut" : "Auto" }, "Name" : "General.General", "Ret" : 100, "SessionID" : "0x00000001" }
....................{ "General.General" : { "AutoLogout" : 0, "FontSize" : 24, "IranCalendarEnable" : 0, LocalNo" : 0, "MachineName" : "LocalHost", "OverWrite" : "OverWrite", "ScreenAutoShutdown" : 10, "ScreenSaveTime" : 0, "VideoOutPut" : "Auto" }, "Name" : "General.General", "Ret" : 100, "SessionID" : "0x00000001" }
...............x.G...{ "Name" : "OPPTZControl", "OPPTZControl" : { "Command" : "DirectionDown", "Parameter" : { "AUX" : { "Number" : 0, "Status" : "On" }, "Channel" : 0, "MenuOpts" : "Enter", "POINT" : { "bottom" : 0, "left" : 0, "right" : 0, "top" : 0 }, "Pattern" : "SetBegin", "Preset" : 65535, "Step" : 5, "Tour" : 0 } }, "SessionID" : "0x1" }
..............x.D...{ "Name" : "OPPTZControl", "OPPTZControl" : { "Command" : "DirectionDown", "Parameter" : { "AUX" : { "Number" : 0, "Status" : "On" }, "Channel" : 0, "MenuOpts" : "Enter", "POINT" : { "bottom" : 0, "left" : 0, "right" : 0, "top" : 0 }, "Pattern" : "SetBegin", "Preset" : -1, "Step" : 5, "Tour" : 0 } }, "SessionID" : "0x1" }
...............x.E...{ "Name" : "OPPTZControl", "OPPTZControl" : { "Command" : "DirectionUp", "Parameter" : { "AUX" : { "Number" : 0, "Status" : "On" }, "Channel" : 0, "MenuOpts" : "Enter", "POINT" : { "bottom" : 0, "left" : 0, "right" : 0, "top" : 0 }, "Pattern" : "SetBegin", "Preset" : 65535, "Step" : 5, "Tour" : 0 } }, "SessionID" : "0x1" }

@matt1 can you perhaps point me into a direction on how to sniff the traffic between openhab (raspberry Pi4) and the camera? The traffic above is between Laptop (windows and wireshark) and the camera.

Thanks @Charley, I am using your script now: My nas gets via ftp-server all video files (in case of motion detection) pushed directly by each ipcam. Script was perfect; I had to change only few lines of code to adapt it to my folder structure on the nas. First part is now solved; however, does anyone know a solution for triggering events on openhab based on onvif motion events directly from the camera?

Thanks for your thoughts @matt1, with this I decided to go for a mixed setup using the best out of both worlds (push / pull). Push with the script of @Charley (push on motion detection) and the binding with extremely large poll intervals of 20 seconds (pull infrequent and on demand). This makes my network connection to all 11 ipcams stable. MP4 files are recorded only when triggered by PIR sensors from openhab. This does not require frequent poll interval of 2 seconds (default value that I used before).

@matt1: Also HLS streams in the browser run now stable from all cams, so I assume the instable behavior was due to high frequency snapshot polls of too many cams. Looking forward to see the HLS-PREROLL working, as soon as you find time for it. Great job from your side even without this feature!

If anyone knows a solution to trigger events in openhab based on motion detection from ONVIF protocol directly from the ipcam, please let me know. This is my only missing part using the openhab binding, i.e. exploit camera-side functionality for surveillance areas with no PIR installed.

Just got a Dahua IPC-HDW4631C-A
It connects fine with ONVIF. But I simply cant get the motion alarm switch to triggerā€¦ Any advice?

Problems authenticating - EZVIZ DB1/HIKVISION DS-HD1
I have been working on getting a local only video doorbell working with this binding. I absolutely do not want my doorbell video, audio and sensor data going to the cloud. My hope is that I can get event notifications through ONVIF and use those in rules in OH2. Using this binding I get the message, The action requested requires authorization and the sender is not authorized. However, I am able to connect to the doorbell and GETs and PUTS work using the ONVIF Device Manager.

I have the latest release of the binding. I am running OH 2.5.5 Release Build on Ubuntu 18.04 Desktop on a pretty capable Intel NUC.

I have several Hikvision bullet cameras, and they all work and authenticate using the Thing ipcamera:HIKVISION:camname1 definition. ONVIF and API access all working well according to the TRACE level OH logs. Video URLs are populated in OH, and events are reported correctly on the other Hikvision cameras.

The doorbell is very popular with home automation enthusiasts. For more info, see this link on ipcamtalk., although no one that I have found so far on that forum is using OH. I want to make this device work and then report there what I have found, hoping we can get some more OH converts.

A word about my doorbell. It is a EZVIZ Model DB1. I have modified it by loading the firmware from the Hikvision DS-HD1 doorbell. These doorbells are all made by Hikvision, but they are sold by Hikvision directly, or by RCA (HSDB2A), LAVIEW 9LV-PDB1630-U), Nellyā€™s (NSD-DB2) and LTS (LTH-7132-WIFI). All of the vendorsā€™ firmware will run on the doorbells. I specifically chose the Hikvision FW because it supports ONVIF, and I am hoping, some sort of API.

Regarding this binding, I do not expect the HIKVISION Thing to work - this camera has no web page interface. There is, I believe, API support, but I have not yet verified this. So instead, I have used Thing ipcamera:ONVIF:doorbell at the head of my Thing definition. Here is my ipcamera.things file.

Thing ipcamera:ONVIF:doorbell
[
   IPADDRESS=xxx.xxx.xxx",
   USERNAME="admin",
   PASSWORD="mysecretpassword",
   POLL_CAMERA_MS=2000,
   SERVER_PORT=54321,
   FFMPEG_OUTPUT+"/tmpfs/doorbell/"
]

When I load the Things file, I see this in the /var/log/openhab2/openhab.log

2020-05-18 18:02:58.940 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.18.30:80
2020-05-18 18:02:58.943 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera failed to report a valid Snaphot and/or RTSP URL. See readme on how to use the SNAPSHOT_URL_OVERRIDE feature.
2020-05-18 18:02:58.964 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - We sucessfully connected to a ONVIF SERVICE:/onvif/device_service
2020-05-18 18:02:59.005 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - ONVIF error 400:<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl" xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:dn="http://www.onvif.org/ver10/network/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12" xmlns:http="http://schemas.xmlsoap.org/wsdl/http" xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2" xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2" xmlns:trc="http://www.onvif.org/ver10/recording/wsdl" xmlns:tse="http://www.onvif.org/ver10/search/wsdl" xmlns:trp="http://www.onvif.org/ver10/replay/wsdl" xmlns:tnsn="http://www.eventextension.com/2011/event/topics"><env:Body><env:Fault><env:Code><env:Value>env:Sender</env:Value>
<env:Subcode><env:Value>ter:NotAuthorized</env:Value>
</env:Subcode>
</env:Code>
<env:Reason><env:Text xml:lang="en">The action requested requires authorization and the sender is not authorized</env:Text>
</env:Reason>
</env:Fault>
</env:Body>
</env:Envelope>

There are a lot of these doorbells out there, and it would be great if we are able to get them working with this binding.

I can do wireshark captures, run tests, whatever we need to do in order to see if we can get this working.
Thanks,
Brad

You did set it up with thing type DAHUA and not as onvif? Also it is not clear if you mean the control to enable/disable the alarm or the alarm output itself.

Hi! I have a [Dahua] LTN6208-P8 NVR with LTDHIP3682W-28ISM, and I can report that alarm detection seems to work (I havenā€™t tried anything else) with Openhab connecting to the NVR.

Iā€™ve noticed a problem that I have no idea how to go about debugging. After a day or so, my RTSP stream to the NVR drops and cannot reconnect. Most of the time, the NVR no longer acknowledges the IPC as being connected. This most recent time, I am able to connect through the NVR proxy service and see that the IPC is indeed online (and through the proxied web browser connection, I can verify that the camera video is live). It clearly smells like a NVR bug, but this has never happened before I tried the IpCamera binding. Iā€™m used to linux machines that I can peek and poke around, but Iā€™ve never been able to figure out how to get better debug access to the NVR: so, are there any suggestions of things that I could try, specifically with this binding, to determine what is causing the problem?

If it has api then you should try hikvision thing type. Those doorbells donā€™t notify that the bell button has been pushed but the rtsp works from what I read.

Hmm for some reason it is/was setup as Genereic Onvifā€¦ IĀ“m almost possitive IĀ“d choose the Dahuaā€¦ Anyway, I have now changed it to Dahua and will see if it mattersā€¦ I do see a bunch of new channels as wellā€¦ need to study those tooā€¦ IĀ“ll be back!

EDIT - Now tested, and it seems to work just fine. The motion alarm switch now trigger, when someone step infront of the camā€¦ Guess I must have been quite a bit sleepy last night when I choose the Genereic Onvif :smiley:

Now for some serious test regarding streaming to Home hub, chromecast devices etcā€¦
First test, IĀ“m not that satisfied with the speed/time it takes to start, (only tested it using Microsoft Edge browser for now).
And then some play around with the IVS/Face Detection etcā€¦