IpCamera: New IP Camera Binding

I’m using Arduino as it is IMO the easiest to set up for novices.

I’m starting with mqtt as I’m already using it big time but I’d like to offer the option for an alarm stream as this prevents users to go for mqtt just for this.

Maybe we had a little misconception - I’m waiting for the Camera PLUS and you are looking forward for an Camera.

Yes I am wanting the PIR sensors mostly and less interested in the camera side, but will have a bit of fun playing. The camera you are getting has the button labelled RST so I hope that does not mean it can not be reprogrammed for other tasks and only resets the esp32.

The last build for this binding changed the updateImageNow channel and this was done with these cameras in mind and if someone wanted to use a MQTT trigger for the channel to start and stop the image channel.

Hi matt…
I´m currently using this version:

openhab> bundle:list -s |grep -i ipcam
207 x Active x  80 x 2.5.0.201901260300    x org.openhab.binding.ipcamera
openhab>

I wonder, if I update the binding to the latest would require ffmpeg to be installed as well? I´m not sure if my Rpi 3B+ is capable of handling it.

Second:
Do you know if it would be possible to cast the image channel to a chromecast device? (I know this is not about ipcamera binding, but I have search and couldn´t find any answer). Or is there a local path where the graped image is stored?

You can use the latest bindingversion without ffmpeg, but if you try and use a feature that needs it then you will get an error in logs. The features u have now will all work without it installed. There were some minor breaking changes around 2019.02.27 and I kept the last version available in the old version download area. This thread covers the breaking changes so use the search function to find the info.

But why not install ffmpeg as I suspect it will work on the pi3 if u setup a tempfs for ffmpeg to use for the hls streaming. The read me covers this.

It may be possible to cast a static picture but the hls works so well I would not bother. Hls does not use much cup power if the camera is set to use h264 and the cup load is only when you are using the stream.

I´m not sure if it´s just my concern due to not really understanding the ffmpeg. But I use a Reolink ipcam, and for somehow I can only use it for httponly format even though it´s onvif supported. I have this concern about ffmpeg, that

  1. my Rpi is to small. I have had a hell before when using Grafana on my Rpi to render charts… It simply killed java/openhab.
    and
  2. I probably run into trouble with this Reolink due to my lack of knowledge for things like this.

Thats why I wanted to test with an image insted.

It should be fine as ffmpeg does not run in the background so if you don’t use the features it will not be running at all and the binding will still work the way it does for you now. It is mainly a cpu using program not a ram hog and as mentioned if the cameras feed is h264 which is every cameras default the cpu load is next to nothing as it does not Re encode for HLS which is what u want for casting.

HLS uses the storage device to hold around 10 seconds worth of video so with slow sd cards it is an issue, which tmpfs solves this.

You really should not be scared to give it a go. This shows you do not trust your backup to work. Copy the sd card to a second card and try it out on the copy then any issues just pop your unchanged card back in, easy, no risk and no need to worry.

I use SSD drive for openhab.
I´m not afraid of the backup. I know how to make backups.
I´m afraid experience the same as with Grafana. It worked fine for quite a while, then I updated openhab to 2.4, and hell broke loose with openhab/java restarted several times a day, (Java crashed and restarted openhab). But it only happened randomly. I could render one chart fine, and sometimes two, but often two crashed java, and three charts for certain crashed Java. It was a hell finding the reason, and required deeper Linux knowledged, which I havn´t got. So it took me quite a while to figure this one.

Thats the experience I´m afraid of using rpi and pushing it too hard. But I´m tempted to give it a try as I would rather want HLS streaming than image snapshots… Or perhaps animated gif´s. As you can see in another thread, my plan is to cast this to my Google Home Hub.

When I install the latest binding (06.09.2019) I get this error:

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

2019-06-11 18:50:25.160 [WARN ] [org.apache.felix.fileinstall        ] - Error while starting bundle: file:/usr/share/openhab2/addons/org.openhab.binding.ipcamera-2.5.0-SNAPSHOT.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.ipcamera [295]
  Unresolved requirement: Import-Package: io.netty.bootstrap; version="[4.1.0,5.0.0)"
	at org.eclipse.osgi.container.Module.start(Module.java:444) ~[?:?]
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[?:?]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [10:org.apache.felix.fileinstall:3.6.4]
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [10:org.apache.felix.fileinstall:3.6.4]

In the zip file I downloaded, there are 8 .jar files beside the binding… Are they all suppose to be copied into the addons ?

Got my module today, just got it working with arduino and your binding to just dial into my Wifi and provide regular MJPEG images. Will polish the code (and remove Wifi credentials :wink: ) and publish tomorrow I think. Adding Wifi Manager will be in a later time but on my agenda.

Nifty little thing - great small display.

… this enables to use deep sleep - so this thing will be on coin cell for ages.

Yes all must be in the addons.
You will also need to clear tmp and cache folders.
If you have not done textual config (things file) you need to delete and readd the camera.
There are breaking changes to be aware of especially if you override urls with textual config.

Using the search on this thread will answer these for you.

@Sascha_
Very Cool let me know how it goes.

@matt1: can i somehow display these prefetch images through use of a URL? For me the new animated gif creation (pre- and postroll) work perfectly; i send that to my phone. But i want to display camera images on my kodi systems using Security camera overlay. This uses a URL for image retrieval refreshed every second. As i have 3 Kodi streamers and am using image refresh every second for animated image creation, i get too much calls to my camera and the images are not dispayed. If i can serve the images already retrieved by your binding this will take out any additional stress on the camera; openhab will serve these images to all 3 streamers.

Not currently but it would be possible for the binding to pass them on without being saved to disk if the feature was added. I already do a similar thing for the mjpeg stream for similar reasons.

I would normally say use the camera to serve the files directly but you gave a good description of why that won’t work.

This method may work if you save the file to the HTML folder and use openhabs serving ability.

Just to be clear about the way it works now; does the image channel save the image to disk every poll interval? it doesn’t seem to do that. It would be a welcome addition to have a switch channel available to be able to to just that. If the switch is on the fetched image is also saved to the FFMPEG_OUTPUT location (and thus overwritten every poll), if it is off it behaves as current behaviour. THis way i can save the images to the opehad html folder for some seconds as long as the kodi streamers show the camera overlay…

No the binding tries to keep loads on the openhab server as low as possible and as most users have a raspberry pi with possibly a sd card I don’t believe that is a good idea. The way would be to allow this url to be used which keeps things consistent with how the rest of the binding works.
Openhabip:54321/ipcamera.jpg
Then it only places a load on the server when kodi asks for the file and it does not use the disk, only ram.

Could you do a guide on how u setup kodi to do the overlay?

Not to spam this topic, I’ve created a seperate thread for my development

1 Like

The Kodi Security Cam Overlay can be found here. After installation you can configure up to 4 camera feeds (image URL) and some other stuff like refresh time etc.

within openhab i created a rule which is used to send an animated gif to my phone with pushover, and display image feed onto kodi:

rule "DoorBell"
when
    Item Doorbell changed to ON
then
    if (FrontDoorButtonPressed.state != ON) {
        FrontDoorCreateGif.sendCommand(ON)
        FrontDoorButtonPressed.sendCommand(ON)
        var String content = '{"jsonrpc":"2.0","method":"Addons.ExecuteAddon","params":{"addonid":"script.securitycam"},"id":"1"}'
	    sendHttpPostRequest("http://192.168.x.x:8080/jsonrpc",'application/json',content)
        sendHttpPostRequest("http://192.168.x.x:8080/jsonrpc",'application/json',content)
        sendHttpPostRequest("http://192.168.x.x:8080/jsonrpc",'application/json',content)
    }
end

So it would be very welcome the ipcamera binding could host a snapshot available through an url so i have to configure one URL only, not having multiple requests to the camera.

You could always mount a tmpfs directory and just store it there.

Thanks for your amazing work on this, Matt. I recently rebuilt my OH server which had been upgraded from 2.0->2.1->2.2->2.3-2.4 and was frequently crashing due to running out of Java heap space so I took the opportunity to upgrade to the latest version of your binding.

I’m using several Hikvision 2085 cameras and I noticed that the snapshot capture URL override and the stream URL override needed to be filled in the latest version. I’m fairly sure I didn’t need to specify these with the earlier version of the binding. I say I’m fairly sure but I have a bad memory and never take notes when I configure stuff…

I also got the GIF capture working and can see a ipcamera.gif file in the tmpfs directory. How can I use this file with Telegram. I already have a rule that sends a couple of snapshots:

    rule "Send telegram with fixed message when front door camera intrusion detected"
when
    Item CameraFrontDoor_IntrusionAlarm changed from OFF to ON
then
    logInfo("Dev", "Front door camera intrusion detected.")
    CameraFrontDoor_UpdateTheImage.sendCommand(ON)
	AVTVLGWebOSTVOLED55B6V_1_Toast.sendCommand("Front door camera intrusion detected")
    sendTelegram("Bot", "Front door camera intrusion detected")
    Thread::sleep(100)
    CameraFrontDoor_UpdateTheImage.sendCommand(OFF)
    var String base64Image0 = CameraFrontDoor_SnapshotFromCamera.state.toFullString
    sendTelegramPhoto("Bot", base64Image0, "Intrusion detected at front door")
    Thread::sleep(1000)
    CameraFrontDoor_UpdateTheImage.sendCommand(ON)
    Thread::sleep(100)
    CameraFrontDoor_UpdateTheImage.sendCommand(OFF)
    var String base64Image1 = CameraFrontDoor_SnapshotFromCamera.state.toFullString
    sendTelegramPhoto("Bot", base64Image1, "Intrusion detected at front door")
end

The line

var String base64Image1 = CameraFrontDoor_SnapshotFromCamera.state.toFullString

gets the snapshot into an item that can be passed to the Telegram binding. How can I do the same thing with the GIF file?

The documentation looks very good… See this link as it could be done by the file or by the URL. NOTE: I have not done it yet so the below rule is just a guess.

rule "Send telegram with local image and caption"
when
    Item CameraFrontDoor_CreateGif changed from ON to OFF
then
    sendTelegramPhoto("bot1", "file:///path/to/local/ipcamera.gif", "sent from openHAB")
end

I had no idea the Telegram binding could access files. Thanks for the info.

I’ve updated my rule to these two:

rule "Create front door camera GIF when front door camera intrusion detected"
when
    Item CameraFrontDoor_IntrusionAlarm changed from OFF to ON
then
    logInfo("Dev", "Front door camera intrusion detected, triggering camera GIF creation...")
    CameraFrontDoor_CreateAnAnimatedGIF.sendCommand(ON)
end

rule "Send front door camera GIF via Telegram"
when
    Item CameraFrontDoor_CreateAnAnimatedGIF changed from ON to OFF
then

sendTelegram("Bot", "Front door camera intrusion detected")

sendTelegramPhoto("Bot", "file:///etc/openhab2/html/tmpfs/ipcamera.gif", "Intrusion detected at front door, GIF sent")

end

This works as far as sending an image to Telegram but it’s not animated. The ipcamera.gif file on the OH server is around 800k but the file saved to the gallery on my phone is about 50k. This must be a limitation of the Telegram binding, maybe it’s pulling only the first frame from the GIF and sending that?

Have you managed to send animated GIF files via Telegram? Maybe I’m missing something important…