Trigger event when sitemap is loaded

Is it possible to trigger an event when the sitemap is access by the browser?

Use case: I would like to trigger some actions when this is happening.

I can’t think of a way to do it within OH. You could write an agent that follows the OH logs and watch for a statement that indicates someone logged in.

One approach could be to use the redirection page to access your sitemap, and the act of going to that page would send an ON command to the item before redirecting. The file /usr/share/openhab/webapps/static/index.html

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="refresh" content="0;URL=/"> 
  <title>openHAB Redirect</title> 

  <style type="text/css">
      position: absolute;
<div class="centerMe">
  <a href="/">Redirecting...</a>

After the <body> tag, you could add

<img src="http://IP_ADDRESS:8080/CMD?YourSwitchItem=ON"/>

That wouldn’t give you an image, but it would hit the HTTP server with a GET request to flip the switch. Obviously, if you went straight to the sitemap, this would be skipped altogether. You might have to change the 0 timeout to maybe 3 or some other low number in the second <meta> tag.

what if you simply include a webview widget in the sitemap that turns the switch item on?

1 Like

Hi watou, Exactly what you have been proposing also came into my mind. I will try out your suggestion immediately.

Hi Dan, webview widget does not work when accessing your openhab site via myopenhab. So this is not an option.

Thanks to all who have responded.



I think the same may be true for my suggested hack! :frowning: If you can’t hit the redirection page from my.openHAB, it won’t work.

Random thought - what if you deliberately put an error in the sitemap, then have a shell script monitoring the openHAB logfile for that error?

Hi watou,

that correct.But what I would do is store the index.hmtl locally on the machine I am using the browser. Therefore it is looking promising.

regards Martin

1 Like