IpCamera: New IP Camera Binding

Try to move your camera with both PTZ features, how to do this is explained here as well as many other things.

https://github.com/Skinah/IpCamera/blob/master/README.md#moving-ptz-capable-cameras

Then if there is any problems moving the camera, I will need DEBUG level log output of when the camera is starting to connect, it will have some XML responses that I need to fault find with. Just put the log into a PM to keep the thread cleaner.

thanks.

is there any cool IP Camera with a decent image quality, which allows setting all the image settings. Any recommendations? Thanks!

I am guessing that you wish to do this to lower the traffic across your network unless an alarm state is reached? Without a reason why I can only guess.

There are two ways to do this.

  1. Buy any camera (See note below) and buy a separate PIR sensor of some kind, zwave for example. Then with all updating turned off, it only fetches a jpg when you ask for one, so if you only ask for the ipcamera.jpg when the PIR is going off with a rule, then you get what you desire(?) and all cameras can do this. You may not need a PIR if your goal is to only have traffic when a UI is open to the picture as this happens automagically with the Openhab framework. Close the picture in the UI and the traffic stops. The animated gif feature would make this pretty simple in a rule to display the last motion alarm, when the alarm is trigged just flip the switch to make a Gif, then when it is done, it auto flips the switch back that can trigger another rule. The Gif can be high res if you change the default options which by default scales the GIF smaller.

  2. Buy a camera with an API and then the binding can do it internally without you needing to write any rules using the image channel. All the brands that have an API listed in the first post of this thread make models that have good picture quality. There are also cameras with the ability to stay in full colour at night time under certain conditions. Best forum to look is here where there are reviews posted with video examples https://ipcamtalk.com/forums/

that’s a nice idea, but no… sorry for being unspecific. I’d like to take neat pictures. My present camera doesn’t support ONVIF (at least not fully), and so I have to improvise.
A bit more context: the camera is installed on our mountain cottage - and I’d like to get some idea, if it’s worth the ride! :wink:
grafik
(present view)

My goal(s) are:

  • taking pictures every 5mins and uploading them to a google site, where I can watch them live (don’t want to expose the remote network directly to the internet)
  • making some cool hyperlapse videos

with my current camera I have to make compromises to have pictures which are viewable regardless it’s morning, noon or black night. This I’d like to automate (presently just static, but perhaps I can automate this with a bit of logic and imagemagick, which analyzes the pictures and adjusts the image settings accordingly…

Thanks for the forum-link, I’d dive into this…

1 Like

Interesting situation, always good to read how others use cameras…

You can buy cameras that will on their own upload every 5 minutes to a FTP server and you can set schedules to not do this at night time, as a view like that is not going to get lit up by any built in LED.

If you have Openhab running on a Pi you could setup the binding to Poll every 5 minutes and set the gif preroll to 143 and the postroll to 1. Then at a certain time of day automate the animated gif switch to create you a 12 hour long timelapse that gets sent via pushover to your phone. Pushover then can be set to only keep the last 10 messages automatically. Just open the app and you can have a look when it suits you.

I have never done it with that many snapshots before nor do I know if there is a limit to the size of a gif that pushover can handle, but if you have enough ram it should work as you will need 144* the size of a snapshot to hold all the images. The binding does not have any limits other than the size of a INT and your ram that Java can use.

Would love to hear if it works.

1 Like

@matt1

Sorry for the delay. i am a little bit lost

let me summarize in order to not waste your time if this camera is not supported.

  • From VLC, i can access to

rtsp://192.168.1.40:8001/0/avN with admin and Password blank

  • The PTZ works works ONVIF Device manager with admin and Password blank
    Found URI :http://192.168.1.40/onvif/device_service

i have tried all those url without success

As far, i understood my thing definition should be like :slightly_smiling_face:

Thing ipcamera:ONVIF:003
[
    IPADDRESS="192.168.1.40",
    USERNAME="admin",
	PASSWORD="",
    ONVIF_PORT=8001,
    PORT=80,
	FFMPEG_OUTPUT="/etc/openhab2/html/cameras/cam1/"
]

But my thing is offline


i have tried this approach to integrate rstp feed

the camera is well accessible also from an ONVIF android application

on the second side, a thing with the settings below is in status online


What i am missing? will be glad to help!

Hi Matt,
Has the multiple adapter issue been resolved in the latest version as I’m still unable to use the binding where my unit is selecting the wrong ip for the server?

Also, if you get a minute spare… I have a EZVIZ db1 doorbell. There is no web interface, but I can access the rtsp stream. I cannot add to binding due to this, however I wasn’t sure if there is a way to get motion detection into openhab. I’ve seen couple of posts regarding the motion in homeassistant with their library so maybe it’s a possibility but I don’t know what to look for.

Also you can add hik DS-2CD2032-I as compatible btw

@nakh_Home think you need to add SNAPSHOT_URL_OVERRIDE to your thing and set it to the url as in the bottom right of your Android app showing the snapshot url.

The camera thing in paperui is telling you the issue, it’s offline because it can’t set the url through onvif

1 Like

@Daniel_Linder you do know there is a hack for Chinese Hikvision cameras to permanently change them to english? I have 4 and I now upgrade with English firmware. It involves changing some hex values. Have done upgrades over the last 6 years now without any issue

Thanks now it’s Up!

with this thing definition :slightly_smiling_face:

Thing ipcamera:ONVIF:003
[
    IPADDRESS="192.168.1.40",
    USERNAME="admin",
	PASSWORD="",
    ONVIF_PORT=8001,
    PORT=80,
	FFMPEG_OUTPUT="/etc/openhab2/html/cameras/cam1/",
	SNAPSHOT_URL_OVERRIDE="http://192.168.1.40/onvif/snapshot"
]

but i can see this error in the IP CAM binding log

2020-01-06 23:21:59.229 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-06 23:21:59.867 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Channel status is -1 for URL:/onvif/snapshot
2020-01-06 23:22:00.624 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - initialize() called.
2020-01-06 23:22:01.627 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - About to connect to the IP Camera using the ONVIF PORT at IP:192.168.1.40:8001
2020-01-06 23:22:01.633 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-06 23:22:01.791 [INFO ] [ing.ipcamera.handler.IpCameraHandler] - IP Camera at 192.168.1.40 is now online.
2020-01-06 23:22:01.796 [WARN ] [ing.ipcamera.handler.IpCameraHandler] - We got an ONVIF error404:Not Found
2020-01-06 23:22:08.787 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-06 23:22:10.787 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-06 23:22:12.787 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-06 23:22:14.787 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-06 23:22:16.787 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-06 23:22:18.787 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-06 23:22:20.787 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot

And some errors in the openhab.log

2020-01-06 22:52:21.299 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@113851c': String index out of range: 7

	at org.openhab.binding.ipcamera.internal.Ffmpeg.buildFfmpegCommand(Ffmpeg.java:86) ~[?:?]

	at org.openhab.binding.ipcamera.internal.Ffmpeg.<init>(Ffmpeg.java:74) ~[?:?]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.setupFfmpegFormat(IpCameraHandler.java:1076) ~[?:?]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:1205) ~[?:?]

2020-01-06 22:52:35.018 [vent.ChannelTriggeredEvent] - logreader:reader:openhablog:newErrorEvent triggered 2020-01-06 22:52:21.299 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@113851c': String index out of range: 7

2020-01-06 22:52:35.029 [vent.ItemStateChangedEvent] - openhablogreaderLastError changed from 2020-01-06 22:51:52.718 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'mqtt_sensor_door_LastUpdate': The name 'mqtt_sensor_door_LastUpdate' cannot be resolved to an item or type; line 134, column 2, length 27 to 2020-01-06 22:52:21.299 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@113851c': String index out of range: 7

2020-01-06 22:52:35.070 [vent.ItemStateChangedEvent] - openhablogreaderLastError changed from 2020-01-06 22:52:21.299 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@113851c': String index out of range: 7 to 2020-01-06 22:52:21.632 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'mqtt_sensor_motionf2 update': The name 'mqtt_sensor_motionf2_LastUpdate' cannot be resolved to an item or type; line 103, column 13, length 31

2020-01-06 23:15:51.862 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@bb60ca': String index out of range: 7

	at org.openhab.binding.ipcamera.internal.Ffmpeg.buildFfmpegCommand(Ffmpeg.java:86) ~[?:?]

	at org.openhab.binding.ipcamera.internal.Ffmpeg.<init>(Ffmpeg.java:74) ~[?:?]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.setupFfmpegFormat(IpCameraHandler.java:1076) ~[?:?]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:1205) ~[?:?]

2020-01-06 23:15:56.938 [vent.ChannelTriggeredEvent] - logreader:reader:openhablog:newErrorEvent triggered 2020-01-06 23:15:51.862 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@bb60ca': String index out of range: 7

2020-01-06 23:15:56.947 [vent.ItemStateChangedEvent] - openhablogreaderLastError changed from 2020-01-06 23:01:04.631 [ERROR] [org.apache.felix.configadmin        ] - [org.osgi.service.cm.ManagedService, org.osgi.service.event.EventHandler, id=423, bundle=273/mvn:org.openhab.binding/org.openhab.binding.weather/1.14.0]: Updating property weather of configuration org.openhab.weather caused a problem: Unable to find any configuration settings for weather binding. Check openhab.cfg. to 2020-01-06 23:15:51.862 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@bb60ca': String index out of range: 7

2020-01-06 23:16:16.337 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@bb60ca': String index out of range: 7

	at org.openhab.binding.ipcamera.internal.Ffmpeg.buildFfmpegCommand(Ffmpeg.java:86) ~[?:?]

	at org.openhab.binding.ipcamera.internal.Ffmpeg.<init>(Ffmpeg.java:74) ~[?:?]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.setupFfmpegFormat(IpCameraHandler.java:1076) ~[?:?]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:1205) ~[?:?]

2020-01-06 23:16:16.943 [vent.ChannelTriggeredEvent] - logreader:reader:openhablog:newErrorEvent triggered 2020-01-06 23:16:16.337 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@bb60ca': String index out of range: 7

2020-01-06 23:16:16.947 [vent.ItemStateChangedEvent] - openhablogreaderLastError changed from 2020-01-06 23:15:51.862 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@bb60ca': String index out of range: 7 to 2020-01-06 23:16:16.337 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@bb60ca': String index out of range: 7

2020-01-06 23:22:31.362 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@1e9d66': String index out of range: 7

	at org.openhab.binding.ipcamera.internal.Ffmpeg.buildFfmpegCommand(Ffmpeg.java:86) ~[?:?]

	at org.openhab.binding.ipcamera.internal.Ffmpeg.<init>(Ffmpeg.java:74) ~[?:?]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.setupFfmpegFormat(IpCameraHandler.java:1076) ~[?:?]

	at org.openhab.binding.ipcamera.handler.IpCameraHandler.handleCommand(IpCameraHandler.java:1205) ~[?:?]

2020-01-06 23:22:36.967 [vent.ChannelTriggeredEvent] - logreader:reader:openhablog:newErrorEvent triggered 2020-01-06 23:22:31.362 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@1e9d66': String index out of range: 7

2020-01-06 23:22:36.976 [vent.ItemStateChangedEvent] - openhablogreaderLastError changed from 2020-01-06 23:16:16.337 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@bb60ca': String index out of range: 7 to 2020-01-06 23:22:31.362 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ipcamera.handler.IpCameraHandler@1e9d66': String index out of range: 7

That’s ones outside my knowledge I’m afraid
@nakh_Home have you tried using the url override and setting it to the known working stream url?

Try this as it is your ONVIF_PORT is wrong hence why you got a 404 error right after the onvif was trying to connect. Onvif will give you the rtsp and snapshot urls if it connects and it needs that port to be right.

Thing ipcamera:ONVIF:003
[
    IPADDRESS="192.168.1.40",
    ONVIF_PORT=80,
    PORT=80,
    SERVER_PORT=54321
    FFMPEG_OUTPUT="/etc/openhab2/html/cameras/cam1/"
]

This shows that it is port 80 as the port is missing, hence it is 80.

The FFmpeg errors are probably because it has no RTSP url, the next build of the binding detects this already and puts up an error. This should not happen when onvif connects as it will find the snapshot and the rtsp url on its own.

Thanks for your answer

with the thing definition above. i am getting the errors in the IP binding log

2020-01-07 01:26:40.238 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-07 01:26:40.295 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to move with new PTZ now
2020-01-07 01:26:40.338 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - We got a ONVIF PTZ ERROR -1:unexpected end of stream on http://192.168.1.40/...
2020-01-07 01:26:40.890 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-07 01:26:42.238 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Sending camera: GET: http://192.168.1.40/onvif/snapshot
2020-01-07 01:26:42.299 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - Trying to move with new PTZ now
2020-01-07 01:26:42.321 [DEBUG] [ab.binding.ipcamera.onvif.PTZRequest] - We got a ONVIF PTZ ERROR -1:unexpected end of stream on http://192.168.1.40/...

Yes I have had someone that was having the issue report that it is now solved with the latest build.

Does it have onvif? Currently the only way for a camera to come online is to have a working snapshot or at least the camera needs to accept a http connection as the binding does not wait for the snapshot to actually get sent back. Currently there is no way unless you know of a snapshot url or the camera has ONVIF as snapshots are a requirement for onvif compatibility. It would be very easy to remove the need for a snapshot for cameras to come online and just make them always show as online. I believe I know an easy way to add this to the binding now I have had a change to think it over, I may look at it tonight if I get a chance…

Home Assistant does have the ability to use FFMPEG to generate a bad/basic motion alarm using ffmpeg to look for changes in the frames of the video stream from rtsp. Is that what u mean?

  1. It means your server will be streaming non stop from the camera chewing network bandwidth and CPU from your openhab server. EDIT: Reports are that it takes 20% of an i5 to process 1 camera. I tried it tonight and found it used 30% of a Pi4 cpu for a single 1080p camera stream and it would not work in realtime. By using a low res stream I could get realtime working and I found a far better method than what HA is using but it is just as CPU hungry. Most cheap cameras don’t have the ability to do multiple streams in different formats.

  2. The motion detection is very poor from feedback on their forum so I never looked at doing this. Now I have tried it, it does suck but I found a better method. If you run motion or any of the other camera software packages on a PI you then get far better motion detection with far less false positives and can remove the CPU and network load from Openhab.

  3. The other option is PIR sensors can be had for $40 and they are far better at not generating false alarms. I’m guessing rain at night time would make the ffmpeg method useless where a PIR would still work perfectly.

  4. Cameras that have good motion alarms and an api only cost $30 more than the cameras that are not onvif and have far better picture quality and more features. It really annoys me when I see people recommending X cheap cameras to nnobs without a few warnings that they lack X and X feature and only an extra $30 gets you those features and better quality and ease of use etc…

You can test the ffmpeg detection with this command…

ffmpeg -i YOUR_RTSP_INPUT -an -filter:v select='gt(scene\,0.03)' -f null -

If you wanted such a feature then by all means request it after running a test or two on your system with the above command, it is probably a 1-3 hour job to add it to the binding. Adjust the 0.03 value up and down to set how sensitive it is.

I have been dabbling on getting Onvif alarms/events working and it is 40% done but I hit a minor road block and all my cameras work so it has been shelved for now. I uploaded my work on it to GitHub if anyone wants to play.

Try using the new goto PRESET channel. Not all cameras support ABSOLUTE movements and if that is the first thing in your logs then the binding probably collected successfully a list of presets that it can move to.

Use Onvif device manager to setup the presets and test that they work first before trying in Openhab. ODM will also allow you to test the absolute move, but if it is missing any you only see RELATIVE and CONTINUOIS options for move then it shows the camera does not have it implemented.

I actually prefer using the presets now, they would be the way I would move my camera as they are simple to use and the need to move a camera remotely in real time is probably what most people wont want. The ability to jump to an exact location from a drop down list is IMHO a better easier way.

@delid4ve
I could be wrong but ezviz are rebranded hikvision and it may work in the binding if you setup the camera as a hikvision worth a try.

Thanks for your help

i have tried to set preset in ONVIF without success

getting an error when trying to save the preset

Continuous move

Absolute

Relative

To summarize:

in ONVIF i can only watch and also move the cam with the green arrows. maybe it’s a details but the up arrow moves the camera down and vice versa. the same for right and left arrow

Some additional ONVIF information that might help
image

@matt1 Is there anything I need to specify to select the correct adapter? It still on the wrong subnet: (should be 192.168.6.0/24)

Nope not that I can find and I can’t find a snapshot url yet, will get wire shark out when I get a bit of time to test.

I did try this but doesn’t accept anything on port 80. As with all these doorbells they want to force you into paying for the subscription, went with this model rather than the ring etc as at least I can record locally due to the rtsp stream being available

So for anyone that has the Hikvision CS-DB1 Doorbell you can hack it to provide onvif support and use within this binding:


and this tool:
https://us.hikvision.com/en/support-resources/downloads/tools

There are multiple brands of this doorbell but they are all hikvisions rebranded. Just make sure you read the post in full before upgrading.

I can confirm it now integrates.
Full model: CS-DB1-A0-1B3WPFR (flashed with LaViews firmware)
snapshot overrride: http://IPADDRESS/onvif/snapshot.jpg

1 Like

One time bump…

Any thought on this issue? I understand this is voluntary development and I do not want to take more of your time than necessary.

In case the system is not designed to handle 8 cams at a time using an openhabian installation, please let me know and I will remove it.

In case I can provide more information to help tracking what the problem is, please let me know too.

Thank you, Harald