Custom Widget: Camera History and Live Popup

This Widget is very hard to explain what it does as it is designed to take up not much space in a Panel and give lots of features. Hopefully the picture explains it more clearly than my writing.

It can be used to:

  1. Auto popup (modal) a live view of the camera when an item triggers the view to open. Auto closes back to your Habpanel when the trigger turns off. You can choose to popup the video only over the widget if your don’t want the whole screen taken over.
  2. Gives you a history of recent recordings, indicated by the red dot and number. Update to the latest ipCamera binding for all the new features that allow this to work. You can manually create the history with rules if you wish as it is just comma separated values (CSV).
  3. Allows you to clear the history without deleting the files so you can keep track of the recordings you have not yet had time to review.
  4. The history feature supports GIF or MP4 with gif being the more compatible. You can change the play back speed to get an idea faster of what the camera has captured with gif. MP4 is higher frame rate, supports audio and can be paused.


Camera-History.widget.json (6.5 KB)

Some example rules for using with the ipCamera binding and this widget will then have a history of the recordings tracked by the new channels the binding just got…


var DoorbellMp4TimeStamp

rule "Auto Front Doorbell"
	Item Doorbell_MotionAlarm changed to ON
		if (Doorbell_MP4Recording.state == 0 || Doorbell_MP4Recording.state == NULL ) {
			DoorbellMp4TimeStamp = new DateTimeType().format("%1$ty-%1$tm-%1$td_%1$tH-%1$tM-%1$tS").toString			
			getActions("ipcamera", "ipcamera:onvif:1921681174").recordMP4(DoorbellMp4TimeStamp,10)
			sendBroadcastNotification("Someone is at the door and baby is alseep.")
		}   else{

rule "Doorbell Mp4 recording done"
	Item Doorbell_MP4Recording changed to 0
	val String result=executeCommandLine("mv /tmp/Doorbell/"+ DoorbellMp4TimeStamp +".mp4 /etc/openhab/html/Doorbell/"+ DoorbellMp4TimeStamp +".mp4", 500)
	logInfo("MovingFile", "Command line result: {}",result)


Switch Doorbell_MotionAlarm "PIR Motion" { channel="ipcamera:ONVIF:Doorbell:cellMotionAlarm" }
String Doorbell_MP4Filename "MP4 Filename" { channel="ipcamera:ONVIF:Doorbell:mp4Filename" }
Number Doorbell_MP4Recording "MP4 Record" { channel="ipcamera:ONVIF:Doorbell:recordMp4" }
String Doorbell_MP4History "MP4 History" { channel="ipcamera:ONVIF:Doorbell:mp4History" }
Number Doorbell_MP4HistoryLength "MP4 History Length" { channel="ipcamera:ONVIF:Doorbell:mp4HistoryLength" }

Fixed an issue with the widget that stopped the edit screen from coming up without refresh being pushed. Re download the widget if you have that issue or any others.

Hi @matt1 how the recording location should be entered? “static/cameras/corridor/” or direct like “/etc/openhab2/html/cameras/corridor/” ?

I use this

How it is supposed to work the history? i can see the red dot with 1 , if i click the red dot i can play, control the mp4 file.But if the red dot say more 2 if i click it then its coming only the trash bin to delete, no video player.


The widget was designed to work with the ipcamera channels/items as everything is done for you with the binding, but you can manually use them with the following info or use it to fault find.

The history is a string with the mp4 or gif file names separated by a comma. Don’t include the .mp4 it is only the name without the extension.


If your not getting the video controls When there are multiple files then check if the history string is correct and does not contain illegal characters. Http addresses don’t like spaces and certain Other characters and need to be replaced. The binding does not do that currently but could be added as a feature as the coding needed is already done.

If the above does not help then take some screen shots and give more info as to what the history string is holding.

i am using the ipcamera binding.
i am using this command to get the mp4 but everytime its creating only one file but the history its increasing everytime i run the rule
getActions(“ipcamera”, “ipcamera:onvif:19216817864”).recordMP4( “reolink”, 5)
what i am doing wrong??

It is over writing the file each time. I did add a special case which you may wish to use. Instead of reolink use ipcamera as the filename when you record. Now it does not make the history longer but the numbers in the red dot will climb to match the events.

Red dot shows 6 visitors but only the last visitor has its video shown.

Another example as to why some may like to do this is a baby monitor. The red dot counts how many times the baby stirred during the night but you only want to see the last time they woke and moved In a video.

So that means i cannot have a history with my last 5 or x visitors ??what is the point of the events if you don’t have the options to see your last triggers?? or i am totally understand this wrong. ok now i read your edit, but will not be nice to have also the option to keep a track with visitors?

You can do that but you need to use a variable in the filename before it is recorded. Otherwise the recording replaces the previous one. I use a date time stamp in mine so they can be order neatly and found here easier. When in front of my computer I can share the rule that does it.

the rule is on the first post??if yes it doesnt work for me.
with this command Doorbell_RecordMP4.sendCommand(5)//Record mp4 for 5 seconds
the channel stay with the value 5 for ever and no file is creating.

Just updated the first post with what is working for me at the moment. Since the binding was merged you dont send commands to the Doorbell_RecordMP4 channel anymore, you have to use the action.

The rule does a move on the file as I record to a ram drive which has limited space, so it gets moved to a long term storage folder. The folder is for openHAB 3 note the missing 2 in the path.

I could have stripped the rule back more than what I did so let me know if it is not working or something is broken as the rule does more on my system I wanted to make it cleaner and shorter for the example.

Thanks a lot i use the variable method and its working perfect.

Keep up the good work :+1: :+1:

1 Like

Hi all,

is there a way to run this widget also in OH3?


Yes you can run habpanel in OH3. I have not gotten around to creating a similar widget for the main UI yet.

@FranzS Check this code for a new OH3 widget in this post…

Camera MP4 Recording History and Live HLS - Add-on Marketplace / UI Widgets - openHAB Community

Thanks @matt1
i really run in many troubles with the camera i own (TAPO C320WS).
seems FFMPEG returns often error 400.
If i get it fixed I’ll give it for sure a try!
Thanks a lot!