I managed to complete the binding on my own and it works nicely. Now I can just configure items for each camera like this:
DateTime camera1 "Date [%1$td.%1$tm.%1$tY %1$tT]" <calendar> { snapshot="path=/path/to/snapshots;maxFiles=50" }
DateTime camera2 "Date [%1$td.%1$tm.%1$tY %1$tT]" <calendar> { snapshot="path=/another/path/here;maxDays=30" }
When the binding starts, it begins monitoring the configured directories. I have my Hikvision cameras set up to send jpegs based on motion detection to those directories via FTP. When a new snapshot appears then the binding does the following:
- updates the corresponding Item on the event bus
- if the option maxDays is configured, it deletes any snapshots older than the value configured
- if the option maxFiles is configured, it sorts the snapshots by creation date, then deletes the oldest files so that the file count for the given folder does not exceed maxFiles
The binding has a webservlet with the following features:
- renders a webpage to summarise the folders and their contents
- groups the snapshots based on timestamp (if snapshots are less than a minute apart they are presumed to relate to the same event and so are grouped together). This means it’s easy to browse recent ‘events’. The snapshot shown in the summary view is the middle snapshot.
- renders a webpage to provide a list of snapshots in a specific group
- uses tokens and template files (I took the concept from the excellent weather binding) so that you can fully customise the webpages
- can optionally resize snapshots to create thumbs/previews in the webpages
- can render the original snapshot
I was planning to do a pull request and contribute the binding back, but according to the ‘How to Contribute’ page, it needs to be tested on OH 2.0 which it’s not as I am on OH 1.7.
So if anbody’s interested in this binding or sees value in it, please let me know, in which case I can either send the code or if there’s enough enthusiasm, I’ll upgrade to OH 2 and contribute.