IpCamera: New IP Camera Binding

Would you prefer the ability to just turn off the whitelist and then handle security with your firewall or other methods like managed switches? In most cases with the whitelist disabled the only requests that get through are what Java calls ‘sitelocal’ and even then they have to be a certain file type and inside the folder.

That would make sense… for those with a simple setup the single address works well, for those of us with multiple site to site VPN’s/ vlans and subnets ‘I hope’ we should all know how to protect ourselves :thinking:

I wasn’t just using OH and the binding Matt, VLC, Xine and MPlayer were all in the mix of things I played with, so it could be any of them.

Will try a few rules out when I get the time, good idea and can use cron to schedule saves. Gif anims aren’t really that important in the scheme of things, more of a novelty really.

My camera can save to several locations, FTP, email, a network host and of course to an SD Card on which I have 24hr recording set in 5min loops.

Thanks matt it works now! Great work. For myself i want to use animated gif so i can send frontdoor image when someone is at my door through pushover. I’m out until monday, will test some more next week. Should i keep the cusom ffmpeg opions in the thing config or should it also work using the defauls?

I would opt to make this optional as we don’t want to store every gif generated, and to use the gif in a rule i’m happy with current fixed naming.

Thanks for taking the time to report it is fixed. I see a lot of downloads but few seem to post unless they have issues so it is always appreciated a simple “it works and thanks”. I am also looking for people to write example rules or how to’s so people including me can cut and paste and get things working faster.

I recommend the defaults, but encourage people to experiment to make things work better in their situation. Currently the default is to give you a 8 second long period of time in 0.25 aka a quarter of the time. In other words meaning 8 seconds of video shown in a 2 second long GIF loop. This way a quick glance at your phone and you see a person walking to your door and pushing the doorbell but you do not have to wait 8 seconds to watch the loop on your mobile phone.

The approach I had in mind which you may find useful was to use a pet friendly PIR sensor to trigger the GIF creation, you could get fancy and instead use a cameras line crossing alarm to detect if they are walking towards the door or away before asking for the GIF to be produced. This would be 1 Openhab rule.

A second Openhab rule would trigger when the createGif changes to OFF. You can then set a switch to ON which is set to EXPIRE with the expire binding. You then set another switch with an EXPIRE when the doorbell is pushed. And then when both switches are ON at the same time, you can send the GIF with pushover. If timed right for the average time it takes to walk to the door, the gif could be sent a second or two after the doorbell is pushed.

I would try to do it this way so you do not have to wait for the doorbell to be pushed before starting to create the GIF.

An extra option I am considering at the moment is for the time the GIF is created to be changeable. This could be done in a few ways so I am waiting to hear back from users how they find the features and in what cases the defaults are not optimal.

This kind of automation is why I love Openhab, you are combining multiple technologies to work together to make the ultimate system.

Great stuff Matt, i’m going to look into your suggestions, i already saw the motion trigger works on my front cam, so i should be able to do exactly what you suggest. I need to set motion window though as currently wind is triggering motion…

Keep you posted, i really like your binding; currently i used wget for getting cam output, your binding is a much more clean way of working with camera video and inages.

Tried the new version and now scale 1600 works flawlessly, outstanding job Matt.

I’ll probably get around to playing with some rules later tonight or tomorrow. Been installing and setting up door and window sensors, hooking them up to OH via a Sonoff RF Bridge which all came in the same package and that’s taken a lot of my time the last day or two.

Oh yeah, the reason I go for the cheaper end of the scale is I’m a pensioner and can’t really afford too much. Before I bought my current one I did look at all the brands supported by your binding but they were out of my price range I’m afraid.

That would be a nice addition, especially if the time could be controlled by a slider rather than set in the Thing definition.

Cheers …

OK, have a working rule, most the instructions are in the rule itself. You’ll need the exec binding enabled.

rule "Rename GIF Anims when Saved"
        Item ipCam2_GIF changed to OFF
        // Same as FFMPEG_OUTPUT parameter in Thing definition.
        var filePath = "/mnt/data/tmp/ipCam2/"
        val String timeNow = String::format( "%1$tY%1$tm%1$td-%1$tT", new java.util.Date )
        // Substitute "ipCam2_" to your preference, recommend keeping the underscore to separate filename and timestamp
        var newFileName = (filePath + "ipCam2_" + timeNow + ".gif")
        // Keep the space after the filename to separate if from target filename
        var oldFileName = (filePath + "ipcamera.gif ")
        executeCommandLine("/bin/mv " + oldFileName + newFileName)
        logInfo(oldFileName, "Renamed to " + newFileName)

The log output, of course comment out logInfo line if unneeded.

2019-05-05 01:26:52.070 [INFO ] [t./mnt/data/tmp/ipCam2/ipcamera.gif ] - Renamed to /mnt/data/tmp/ipCam2/ipCam2_20190505-01:26:52.gif

Hope it works for you guys.

1 Like

Consider using cp instead of mv, then you get both a predictable file name left in place and a second copy with the time stamp. Should work just by changing the two letters only.

That’s easy enough for anyone to do if they wish, I prefer to have only one copy of the file though, guess that’s just down to personal preference. Also could trigger on the ON state and grab the time, sleep for 9 or 10 secs then do the renaming. Alternately, just subtract 8secs from this version. But 8 secs disparity is not a big deal unless you’re using it strictly for security purposes, which I suspect many will.

Will do a more complete version later, time to sleep, it’s 7:10am here, been a long night, LOL.

New version of rule, now triggers and gets timestamp from when gif capture is initiated.

  • Makes choice of whether to copy or rename file easier
  • Allows easier selection of filename/datetime separator
  • Removes requirement to format choices manually with the separator and source/target trailing space
rule "Rename GIF Anims when Saved"
        Item ipCam2_GIF changed to ON
        val String timeNow = String::format( "%1$tY%1$tm%1$td-%1$tT", new java.util.Date )
        // Wait 12 secs for ffmpeg to complete

        // Same as FFMPEG_OUTPUT parameter in Thing definition
        var filePath = "/mnt/data/tmp/ipCam2/"
        var oldFileName = (filePath + "ipcamera.gif")

        // Separator between filename and timestamp, e.g. '_', '-', '.', or whatever you prefer
        var fileDateSeparator = "_"

        // Substitute "ipCam2" to your new filename preference
        var newFileName = (filePath + "ipCam2" + fileDateSeparator + timeNow + ".gif")

        // Options are "mv" to rename file or "cp" to copy file
        var methodUsed = "mv"

        executeCommandLine("/bin/" + methodUsed + " " + oldFileName + " "  + newFileName)
        logInfo(oldFileName, "Renamed to " + newFileName)

Just a quickie on that rule, would it be better to use a timer than thread sleep… 12 seconds is a long time to stop rules that way. Only 5 threads by default if I’m right in thinking…

You are correct it is best not to use sleep in rules. The binding already tells you when the file is ready so I would set the time by doing NOW - 12 seconds when the file is ready. Alternatively you could store the time in a rule when switch goes on and use it when the switch goes back off. For getting help on rules please start another thread.

I just bought an Axis A8105 for my front door . Would it be possible to use this binding for it in OH?

Yes you can set it up as ONVIF thing type.

1 Like

Hey Matt,

Great work with this binding, especially now with native RTSP streams!
Since it has been a few days since you released this and it seems like the reviews are quite good from the community, at least based on this thread, I’m just wondering when are you planning to release an official (not beta) release of the binding?
I am considering implementing this, but want to move forward with this once it has some run rate and not just a beta version.

Thanks again for your work on this!!!

Every programmer has their own opinion on what BETA means, mine is that I have found as many issues as I can find and now need help from others finding any more. If something is not stable I don’t like to build and let people use it. So far I have not heard any feedback on the HLS streaming features which is usually either none one uses it, or a good sign that no one has an issue with it, hard to know which one just yet. Until I get feedback and fine tune the HLS features to work most of the time on multiple cameras I wont remove the beta tag. I have been using the build for over two weeks without issues on my own live server as a baby monitor where it needs to be reliable and can report it all looks good :slight_smile: However there are many brands of cameras, many different servers and platforms to test on and I can not do this without people helping to test…

As for when it will be pushed to the Openhab project, first the new bundle format needs to be finalised and a test environment created for Eclipse, and I have no control or idea when this will be.

@matt1: it appears my system has some issues after enabling all my camera’s. I saw some crashes and get the following output: java.lang.OutOfMemoryError: Java heap space

When i disable ipcamera things everyting runs smooth again. Currently i only use image every 10 seconds and some motion detection, nothing fancy…

Do you use the android app and leave it open showing the camera? Have you tried increasing the java heap space? Search this thread for more info.