Hello,
i have a zoneminder server on LAN, and i’m trying to setup an easy openhab interface to check recorded clips.
i know this is somehow forced and not really a sitemap use case but i’m really close to get it to work
this is my workflow:
- let user select hour, minute, and monitor (i’ll add later day selection)
- retreive event ID from zoneminder API
- download clip in /etc/openhab2/html/<“eventID”>.mp4 using curl
- show video on sitemap
i previously saved the clip as a static /etc/openhab2/html/event.mp4 file, but of course it gets cached in openhab android app\desktop browser so it does not update
you have to close and restart android app\desktop browser to watch the new downloaded clip
so i tried using a String item to update a sitemap Video or Webview:
as stated in docs:
item
can refer to a String Item whose state is a URL to a video. Some clients may not (yet) consideritem
.url
is the default URL from which to retrieve the video if there is no associated Item or if the associated item’s state is not a URL.
but since url= argument is mandatory, sitemap will show the hardcoded url instead of item string value
cctvevent.items:
String Cctv_monitorid "CCTV EVENT Monitor Id"
String Cctv_hours "CCTV EVENT Hours"
String Cctv_minutes "CCTV EVENT Minutes"
Switch Cctv_searcheventid "CCTV EVENT Search EventID"
String Cctv_eventurl "CCTV EVENT Url"
String Cctv_eventid "CCTV EVENT Id"
cctvevent.rules:
rule "Search and download event"
when
Item Cctv_searcheventid received command ON
then
var String json_eventid = sendHttpGetRequest("http://192.168.2.2/zm/api/events/index/MonitorId:" + Cctv_monitorid.state + "/StartTime%20%3E%3D%3A2022-08-18%20" + Cctv_hours.state + ":" + Cctv_minutes.state + ":00.json")
var String eventid = transform("JSONPATH", "events.[0].Event.Id", json_eventid)
Cctv_eventid.postUpdate(eventid)
executeCommandLine('curl --output /etc/openhab2/html/' + eventid + '.mp4 http://192.168.2.2/zm/index.php?view=view_video&eid=' + eventid, 5000)
Cctv_eventurl.postUpdate("/static/" + eventid + '.mp4')
end
// i'll add later rm command to delete old event clip when new one is downloaded
already tried different url variations:
Cctv_eventurl.postUpdate("http://localhost:8080/static/" + eventid + '.mp4')
Cctv_eventurl.postUpdate("http://192.168.0.240:8080/static/" + eventid + '.mp4')
sitemap snippet:
Text label="Recordings" icon="none" {
Selection item=Cctv_monitorid label="Monitor" icon="none" mappings=["1"="Davanti Dx","6"="Davanti Sx","5"="Balcone"]
Setpoint item=Cctv_ora label="Hours [%s]" icon="none" minValue=0 maxValue=23 step=1
Setpoint item=Cctv_minuto label="Minutes [%s]" icon="none" minValue=0 maxValue=55 step=5
Switch item=Cctv_searcheventid label=" " icon="none" mappings=[ON="DOWNLOAD"]
Webview item=Cctv_eventurl url="/static/fallback.html" label=" " icon="none" height=15
Text item=Cctv_eventid label="Event ID [%s]" icon="none"
Text item=Cctv_eventurl label="Event URL [%s]" icon="none"
}
i probably misunderstood how Webview or Video sitemap items use a String item
can somebody point me the right direction?
i’d really like to use a sitemap feature instead of writing an external html webview
thank you