String item not updating Sitemap Webview\Video\Image URL

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) consider item.
  • 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


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"


rule "Search and download event"    
         Item Cctv_searcheventid received command ON
             var String json_eventid = sendHttpGetRequest("" + 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)
             executeCommandLine('curl --output /etc/openhab2/html/' + eventid + '.mp4' + eventid, 5000)
             Cctv_eventurl.postUpdate("/static/" + eventid + '.mp4')
// 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("" + 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

worked around it using a webview, this is the functional setup:


Number Cctv_monitorid                  "CCTV EVENT Monitor Id"
Number Cctv_ora                        "CCTV EVENT Ora"
Number Cctv_minuto                     "CCTV EVENT Minuto"
Switch Cctv_searcheventid              "CCTV EVENT Search EventID"
String Cctv_eventurl                   "CCTV EVENT Url"
Switch Cctv_today                      "CCTV EVENT Today"
Number Cctv_day                        "CCTV EVENT Day"
Number Cctv_month                      "CCTV EVENT Month"
Number Cctv_year                       "CCTV EVENT Year"
String Cctv_eventid                    "CCTV EVENT Id"
String Cctv_oldeventid                 "CCTV OLD EVENT Id"


rule "Search and download event"    
         Item Cctv_searcheventid received command ON
         if (Cctv_today.state != OFF) {
             val Number day = now.getDayOfMonth()
             val Number month =
             val Number year =
         var String json_eventid = sendHttpGetRequest("" + Cctv_monitorid.state + "/StartTime%20%3E%3D%3A" + Cctv_year.state + "-" + Cctv_month.state + "-" + Cctv_day.state + "%20" + Cctv_ora.state + ":" + Cctv_minuto.state + ":00.json")
         var String eventcount = transform("JSONPATH", "pagination.count", json_eventid)
         //logInfo("Rules", "eventcount: [{}]",eventcount)
         if (eventcount != "0") {
             var String eventid = transform("JSONPATH", "events.[0].Event.Id", json_eventid)
             Cctv_oldeventid.postUpdate (Cctv_eventid.state) 
             executeCommandLine('curl --output /etc/openhab2/html/' + eventid + '.mp4' + eventid, 5000)
             executeCommandLine('/bin/sh@@-c@@echo "<body bgcolor=\"#000000\"><meta http-equiv=\"refresh\" content=\"1\"><a href=\"/static/' + eventid + '.mp4\">DOWNLOAD</a>" > /etc/openhab2/html/event.html', 5000)
             executeCommandLine('rm /etc/openhab2/html/' +  Cctv_oldeventid.state + '.mp4', 5000)             
         else {
             Cctv_eventid.postUpdate("NON ESISTE")

sitemap snippet:

Text label="Registrazioni" icon="recordings" {
                 Frame label="Selezione registrazione" {
                     Selection item=Cctv_monitorid label="Telecamera" icon="cctv" mappings=["1"="Davanti Dx","6"="Davanti Sx","5"="Balcone","2"="Ingresso","3"="Dietro Dx","7"="Dietro Sx","4"="Box"]
                     Switch item=Cctv_today label="Data" icon="calendar" mappings=[ON="Oggi",OFF="Altra data"]
                     Selection item=Cctv_ora label="Ora [%.0f]" icon="time" mappings=[1="1",2="2",3="3",4="4",5="5",6="6",7="7",8="8",9="9",10="10",11="11",12="12",13="13",14="14",15="15",16="16",17="17",18="18",19="19",20="20",21="21",22="22",23="23",24="24"]
                     Selection item=Cctv_minuto label="Minuti [%.0f]" icon="none" mappings=[0="0",5="5",10="10",15="15",20="20",25="25",30="30",35="35",40="40",45="45",50="50",55="55"]

                 Frame visibility=[Cctv_today == OFF] label="Data" {
                     Selection item=Cctv_day label="Giorno [%.0f]" icon="none" mappings=[1="1",2="2",3="3",4="4",5="5",6="6",7="7",8="8",9="9",10="10",11="11",12="12",13="13",14="14",15="15",16="16",17="17",18="18",19="19",20="20",21="21",22="22",23="23",24="24",25="25",26="26",27="27",28="28",29="29",30="30",31="31"]
                     Selection item=Cctv_month label="Mese [%.0f]" icon="none" mappings=[1="1",2="2",3="3",4="4",5="5",6="6",7="7",8="8",9="9",10="10",11="11",12="12"]
                     Selection item=Cctv_year label="Anno [%.0f]" icon="none" mappings=[2022="2022",2023="2023",2024="2024",2025="2025",2026="2026",2027="2027",2028="2028",2029="2029",2030="2030",2031="2031"]                
                 Frame label="Cerca e prepara" {    
                     Switch item=Cctv_searcheventid label="Avvio ricerca" icon="find" mappings=[ON="CERCA"]
                 Frame visibility=[Cctv_searcheventid != ON] label="Download" {                     
                     Text item=Cctv_eventid visibility=[Cctv_eventid != "NON ESISTE"] label="Scarica video [%s]" icon="downloadfile" {
                         Webview item=Cctv_eventurl url="/static/event.html" label=" " icon="none" height=20
                     Text label="VIDEO NON ESISTE" visibility=[Cctv_eventid == "NON ESISTE"] icon="alert"

had to use an ‘hardcoded’ selection item instead of setpoint since android app seems to have a bug.
it sends Number values as decimals (ex: 35.0 instead 35) breaking the generated url.
on desktop is working as intended.

now i’m having some problems trying to interface another openhab instance based on OH3:

a very simple sendHttpPutRequest on OH3 machine, sending POST to OH2 machine:

String Cctv_monitorid                  "CCTV EVENT Monitor Id" 

rule "Cctv_monitorid"
         Item Cctv_monitorid received command
         sendHttpPutRequest("https://user:password@RemoteOpenhabDDNS/rest/items/Cctv_monitorid", "text/plain", receivedCommand, 5000) 

results in:

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'cctvevents-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,java.lang.String,java.lang.String,int) on instance: null in cctvevents

i’ll probably post in related section later.