IpCamera: New IP Camera Binding

Will do, I’ve ran out of time to play with it now but will do later in the week

How do I define the item for the region alarm? Do you have an example for how it should look?

Thanks

@matt1
I installed the latest 2.5 snapshot earlier today in order to improve the situation with the Amcrest / Dahua cam moving offline frequently.
The situation now is as follows:

2019-02-04 19:34:13.660 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at 192.168.x.xxx:xx check your network for issues. 

2019-02-04 19:35:53.160 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.x.xxx:xx is now online.

2019-02-04 19:40:13.162 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler 		URL:null

2019-02-04 19:40:13.162 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - ?!? Channel can not connect to the camera, so going to restart and close all channels.

2019-02-04 19:40:13.166 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at 192.168.x.xxx:xx check your network for issues.

2019-02-04 19:41:52.374 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.x.xxx:xx is now online.

2019-02-04 19:42:02.439 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - Can't find ch when removing handler 		URL:null

2019-02-04 19:42:02.438 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - ?!? Channel can not connect to the camera, so going to restart and close all channels.

2019-02-04 19:42:02.448 [ERROR] [ing.ipcamera.handler.IpCameraHandler] - Can not connect with HTTP to the camera at 192.168.x.xxx:xx check your network for issues.

2019-02-04 19:43:40.468 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.x.xxx:xx is now online.

I have ONVIF off on the cam.

From my point of view, it is worse than before. Do you have an idea about what is causing this?

Update: during the last 30 minutes, the camera went off- and then online again 5 times.

Not surprised. If the binding being labelled as 2.5 snapshot is confusing you into thinking it should be used on the same that is not correct. I use 2.4 stable Openhab and recommend you use the same unless you like using unstable builds right in the middle of a full upturn of code caused by moving away from Eclipse framework.
Please take the time to read the readme file on what to do if you have issues, hint TRACE.

Sorry for missleading you. I ment to say that I installed the latest 2.5. snapshot binding for Ipcamera. I run Openhab 2.4 stable.
I will use some tracing to find out what is going on.

@matt1
I attach a Trace-Log for the issue I have with the camera moving offlline. As mentioned before, this happens very frequently now.
TRACE Ipcamera 190205-01.txt (44.1 KB)

thanks for your help.

I noticed two things…

192.168.1.3/cgi-bin/eventManager.cgi?action=attach&codes=[All]

This url is getting a response back from the camera:
HTTP/1.1 400 Bad Request
It is possible this camera does not support the alarm stream. Try it in a browser after chaning the IP and see what happens. If the camera does not support it, try using the camera as AMCREST which uses an older method for the alarms, or check for newer firmware.

[WARN ] [ing.ipcamera.handler.IpCameraHandler] - ?!? Channel can not connect to the camera, so going to restart and close all channels.

This line occurs if the binding asks the camera to open a channel and it times out, older versions would wait for 5 seconds, and I just changed this to only wait for 4 seconds. So yes I can understand it may have gotten worse and you will need to work out why it takes the camera so long to respond. Is it WIFI and if you open the video stream in a browser does it work fine or does it glitch? I wont help ppl fault find their wifi setup, but it is common for people to have their WIFI on the same or close channels to neighbours wifi. Google will find info if you need it.

Start with a firmware update for the camera.

New build 2009-02-06 Has these changes…

  • New channels or changes to ch type for FOSCAM,DAHUA,AMCREST so may require removing and adding things if not done with textual config.

  • Dahua now has ability to control the IR LED and hence a channel that foscam used had to change to allow 0-100% control over the LED brightness instead of only on and off.

  • Dahua can now overlay text onto the video stream using this from a rule.

TextOverlay.sendCommand('Foo Bar') //sending null removes text.
  • All cameras will now try to connect after 9 seconds if it is the first time going offline to get the camera back up faster if a minor glitch occurs.

@ffr
This feature should help you out if your issues are caused by the internal webserver of the camera having a glitch. I have seen this with my Amcrest and I fixed it by playing with the schedules for snapshots by turning off snapshots when motion occurs, but ‘general’ needs to be enabled. Not sure if this is the same for your camera.

I’ve just installed the latest binding and tried again with trace turned on. On a reboot without the camera defined I get:

2019-02-07 16:51:18.338 [DEBUG] [org.openhab.binding.ipcamera        ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory}={service.id=151, service.bundleid=263, service.scope=bundle, component.name=org.openhab.binding.ipcamera.internal.IpCameraHandlerFactory, component.id=54} - org.openhab.binding.ipcamera
2019-02-07 16:51:18.343 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent STARTING - org.openhab.binding.ipcamera
2019-02-07 16:51:18.357 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent STARTED - org.openhab.binding.ipcamera
2019-02-07 16:51:18.358 [DEBUG] [org.openhab.binding.ipcamera        ] - BundleEvent [unknown:512] - org.openhab.binding.ipcamera

adding a camera using PaperUI seems to work and gives this in the logs:

2019-02-07 17:26:00.969 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - init called.
2019-02-07 17:26:00.970 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Getting configuration to initialize a new IP Camera at IP 192.168.1.117
2019-02-07 17:26:00.971 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.1.117:80
2019-02-07 17:26:02.675 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Fetching the number of Media Profiles this camera supports.
2019-02-07 17:26:03.640 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Checking the selected Media Profile is a valid number.
2019-02-07 17:26:03.641 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Fetching a Token for the selected Media Profile.
2019-02-07 17:26:03.641 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to fetch some information about the Media Profiles from the camera
2019-02-07 17:26:03.642 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - *********** Media Profile 0 details reported by camera at IP:192.168.1.117 ***********
2019-02-07 17:26:03.651 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera will use this Media Profile unless you change it in the bindings settings.
2019-02-07 17:26:03.651 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 is named:VideoEncoder_1
2019-02-07 17:26:03.652 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video encoder	:H_264
2019-02-07 17:26:03.655 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video quality	:3.0
2019-02-07 17:26:03.655 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video resoltion	:1920 x 1080
2019-02-07 17:26:03.663 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 0 uses video bitrate	:10240
2019-02-07 17:26:03.663 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - *********** Media Profile 1 details reported by camera at IP:192.168.1.117 ***********
2019-02-07 17:26:03.664 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 is named:VideoEncoder_2
2019-02-07 17:26:03.664 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video encoder	:H_264
2019-02-07 17:26:03.665 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video quality	:3.0
2019-02-07 17:26:03.666 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video resoltion	:640 x 480
2019-02-07 17:26:03.666 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Media Profile 1 uses video bitrate	:768
2019-02-07 17:26:03.666 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to interrogate the camera to see if it supports PTZ.
2019-02-07 17:26:04.524 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera is reporting that it does NOT support Absolute PTZ controls via ONVIF
2019-02-07 17:26:04.525 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Finished with PTZ with no errors, now fetching the Video URL for RTSP from the camera.
2019-02-07 17:26:05.865 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.1.117:443, 	URL:/ISAPI/Streaming/channels/101/picture
2019-02-07 17:26:05.941 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 0 channels tracked (some of these may be closed).
2019-02-07 17:26:05.949 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/ISAPI/Streaming/channels/101/picture
2019-02-07 17:26:05.950 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have  opened  a  brand NEW channel:0 	GET:/ISAPI/Streaming/channels/101/picture
2019-02-07 17:26:05.954 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.1.117:443 is now online.
2019-02-07 17:26:05.973 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0 	URL:/ISAPI/Streaming/channels/101/picture
2019-02-07 17:26:06.954 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.1.117:443, 	URL:/ISAPI/Streaming/channels/101/picture
2019-02-07 17:26:06.957 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 1 channels tracked (some of these may be closed).
2019-02-07 17:26:06.962 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/ISAPI/Streaming/channels/101/picture
2019-02-07 17:26:06.962 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:0 	GET:/ISAPI/Streaming/channels/101/picture

but I then get this lot repeated around every second:

2019-02-07 17:26:52.954 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - The alarm checking stream was not running. Cleaning channels and then going to re-start it now.
2019-02-07 17:26:52.955 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.1.117:443, 	URL:/ISAPI/Event/notification/alertStream
2019-02-07 17:26:52.957 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 3 channels tracked (some of these may be closed).
2019-02-07 17:26:52.959 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/ISAPI/Event/notification/alertStream
2019-02-07 17:26:52.960 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:1 	GET:/ISAPI/Event/notification/alertStream
2019-02-07 17:26:52.961 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.1.117:443, 	URL:/ISAPI/System/IO/inputs/1/status
2019-02-07 17:26:52.962 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:1 	URL:/ISAPI/Event/notification/alertStream
2019-02-07 17:26:52.962 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 3 channels tracked (some of these may be closed).
2019-02-07 17:26:52.964 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/ISAPI/System/IO/inputs/1/status
2019-02-07 17:26:52.965 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have re-opened  the closed channel:2 	GET:/ISAPI/System/IO/inputs/1/status
2019-02-07 17:26:52.968 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:2 	URL:/ISAPI/System/IO/inputs/1/status

Typing https://192.168.1.117/ISAPI/Event/notification/alertStream into a web browser gives regularly scrolling XML, so I assume this isn’t what its expecting? The contents of the XML only contains the status of the video.which is repeated twice every 10 seconds

<EventNotificationAlert version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<ipAddress>192.168.1.117</ipAddress>
<portNo>80</portNo>
<protocol>HTTP</protocol>
<macAddress>my:mac:address</macAddress>
<channelID>1</channelID>
<dateTime>2019-02-07T17:59:19+12:00</dateTime>
<activePostCount>0</activePostCount>
<eventType>videoloss</eventType>
<eventState>inactive</eventState>
<eventDescription>videoloss alarm</eventDescription>
<channelName>Camera 01</channelName>
</EventNotificationAlert>

That is correct at what the binding is wanting to see, however if you typed that into a browser it would have used a different port and the log you provided indicates the binding is trying to use port 443.

To actually test what the binding is sending you would need to enter this…

http://192.168.1.117:443/ISAPI/Event/notification/alertStream

The XML the camera is sending back is confirming that the camera is port 80 which is the default setting that the binding will use, so you must have changed it from the default?

I’d told it to use HTTPS in the config software, but as its hardwired to OH it doesn’t really matter so I’ve reverted it to HTTP and it now seems to work.
I have another question.
I’ve mapped “Update the Image” to an item as well as “a JPG Image that can be made to update from your cameras feed.” to an image item. This gives me a snapshot when looking at OH on a web browser, but nothing in the ios App. I would like to turn this into an image item that I can then attach to a Pushover Message.

It does not work in the IOS app, possibly a bug in the app!!! But it will work in a browser on your iphone using basic UI, the Andriod app works for me as I use it on a tablet…
As for push over need to search the forum how to do it before asking in your own thread.
The binding does not support HTTPS yet, I did some work on it but other things were more pressing to get going. I will change the log output to make the address more clear what to try in a browser for future builds.

Thanks for the reply, that all makes sense.
Should " Image URL" point to the snapshot file taken with the “Update the Image” function? Both “Image URL” and “Video URL” which I mapped to a string seem blank. Are they implimented yet?

See this post.

You can not use the URL strings unless your camera has no authentication. You need to use the image channel which is best asked in its own thread.

EDIT: Next time you reboot the url strings should update, but just ignore them for now as they may be useful when extra functions are added to the binding.

Anyone looked at Grandstream IP Cameras?

I run a zoneminder setup at home with some of these cameras. I’m just starting with OpenHAB though.

Thanks for suggesting, the API has alarm support so this could be implemented if someone with the cameras is willing to help with some testing? Is there something that zoneminder can not do that the API allows? Switching the alarm input and output IO perhaps?

Hello

I’m using this binding with my Dahua camera for few weeks now.
Something happend and now I can’t see updated image anymore.
I’ve tired to delete the binding, replace new jar, it takes one snapshot when adding thing and that’s it.
I’m also monitoring the line cross alarm which used to work and now nothing.

How can I debug this ?

Hi,

I have a dahua camera and its working great. Thanks for the binding.

This is what i am getting in the logs: the alarm stream is resetting every minute

2019-02-19 12:54:18.882 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - !!!! Channel was found idle for more than 15 seconds so closing it down

2019-02-19 12:54:18.887 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - EmptyLastHttpContent

2019-02-19 12:54:18.915 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent some kind of message.Bytes=0

2019-02-19 12:54:18.918 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Camera has sent last part of the message.Bytes=0

2019-02-19 12:54:18.922 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - commonCameraHandler closed channel:0 	URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All]

2019-02-19 12:54:18.924 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Closing CommonCameraHandler. 		URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All]

2019-02-19 12:54:23.486 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - The alarm checking stream was not running, going to clean channels and re-start it now.

2019-02-19 12:54:23.490 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - ******** Cleaning channels for camera at 192.168.100.80 *********

2019-02-19 12:54:23.493 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Clean channels is now locked

2019-02-19 12:54:23.496 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel status is -1 for URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All]

2019-02-19 12:54:23.499 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Clean channels is now unlocking

2019-02-19 12:54:23.502 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera at IP:192.168.100.80, 	URL:/cgi-bin/eventManager.cgi?action=attach&codes=[All]

2019-02-19 12:54:23.513 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - CommonCameraHandler created.... 0 channels tracked (some of these may be closed).

2019-02-19 12:54:23.522 [TRACE] [ipcamera.internal.MyNettyAuthHandler] - MyNettyAuthHandler is now setup for 	GET:/cgi-bin/eventManager.cgi?action=attach&codes=[All]

2019-02-19 12:54:23.525 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Have  opened  a  brand NEW channel:0 	GET:/cgi-bin/eventManager.cgi?action=attach&codes=[All]

2019-02-19 12:54:23.544 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpResponse(decodeResult: success, version: HTTP/1.0)

HTTP/1.0 200 OK

Any ideas as to what is happening?

using 2.4 snapshot binding

Also,

what does this mean?

==> /var/log/openhab2/openhab.log <==

2019-02-19 13:35:08.147 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - DefaultHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 101, cap: 101/101, unwrapped: PooledUnsafeDirectByteBuf(ridx: 101, widx: 101, cap: 432)), decoderResult: success)

2019-02-19 13:35:08.149 [TRACE] [ing.ipcamera.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary

Content-Type: text/plain

Content-Length:38

Code=AudioMutation;action=Stop;index=0

:

==> /var/log/openhab2/events.log <==

@Chura
read the readme file, it has the answer you seek.

@Dileepa_R
Your issue is because you are using an old version with an issue that has since been fixed, update. You can use 2.5 snapshot builds in Openhab 2.4 I do this on my main setup.

If you wish to learn the replies back from a camera and what they mean please see the API documents for your brand which is found linked in the readme file.

Thanks for the quick answer.:hugs: