Hi Manfred,
Thanks for that, I'll have to give that a try,
cheers
Tim
On 25/9/20 5:50 am, Manfred Maier wrote:
So, this is my approach.
In the index.html.tmpl I've included the following script:
<script>
setInterval("reload_hook();", 10000);
function reload_hook () {
$.get('./hooks/hook_after_station_info.html', function(data) {
\$('#target_after_station_info').html(data);
})
}
</script>
This script replaces later in the index.html a certain content by the
content of the file hook_after_station_info.html in the subfolder
'hooks'. The replacement is done every 10000 milliseconds.
In the same index.html.tmpl file I've replaced the code, that manages
the content of the "index_hook_after-station_info" by the following:
#if os.path.exists("index_hook_after_station_info.inc")
<!-- Start of index_hook_after_station_info row -->
<div class="row index-hook-after-station-info
border-bottom">
<div id="target_after_station_info">
#include "index_hook_after_station_info.inc"
</div>
</div>
<!-- End of index_hook_after_station_info row -->
#end if
In the index_hook_after_station_info.inc I've put the HTML code that
should be displayed on the page. In my case the file contains a couple
of custom calculations of variables and then the following html code:
<br>
<p align="center" style="font-size:24px">
$suntext $raintext
<br>
<a href="https://www.brezentrager.de/wetter-zorneding/"
target="_blank">Hier geht's zur aktuellen Vorhersage für Zorneding</a>
</p>
<br>
The last missing part is the file that is used to update the index hook.
As mentioned above, this file is stored in the subfolder 'hooks'. So
create this subfolder in your Belchertown folder and create a file
called 'hook_after_station_info.html.tmpl'. The content of this file
is identical to the content of the index_hook_after_station_info.inc
Finally you have to tell Belchertown, that this file has to be
produced every time the skin is produced. This can be done in the
skin.conf file.
Under [CheetahGenerator] add:
[[[hooks]]]
template = hooks/hook_after_station_info.html.tmpl
This approach leads to the desired behavior (i.e. the index hook
updates automatically). But I'm definitely not an experienced
web-programmer. I'm pretty sure there is a more elegant way of doing
it. There's for example no reason for having two separate file with
the code for the index_hook. This easily could be done with just one file.
Hope this works for you. In case you have any questions, please let me
know.
Best,
Manfred
Manfred Maier schrieb am Donnerstag, 24. September 2020 um 13:46:16 UTC+2:
Hi Tim,
the only thing you've missed is that the refresh of the image
hooks only works for images.
There is a workaround available (using some custom script). I
hopefully find some time later in the evening to post the solution
here.
I'm using this workaround on my page: wetter-zorneding.de
<http://wetter-zorneding.de>
The text below the station observations updates automatically
(showing the sunshine hours and amount of rain).
Best,
Manfred
[email protected] schrieb am Donnerstag, 24. September 2020 um
09:39:28 UTC+2:
Hi all,
I have this in my index_hook_after_station_info.inc
<div style="text-align: center; background-color:
#$aqi($current($data_binding='aqi_binding').aqi_pm2_5_category).color;"
>
<H2> The 24hr AQI for South Penrith is
$current($data_binding='aqi_binding').aqi_pm2_5 which is
$aqi($current($data_binding='aqi_binding').aqi_pm2_5_category).category.</H2>
</div>
and in /etc/weewx/weewx.conf I have ..
reload_hook_images = 1
reload_images_hook_asi = 300
But hook1 never refreshes.
Have I missed something ?
thanks
Tim
--
You received this message because you are subscribed to the Google
Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/ec9f86d9-7a8f-4df7-aa39-9dab82d9df52n%40googlegroups.com
<https://groups.google.com/d/msgid/weewx-user/ec9f86d9-7a8f-4df7-aa39-9dab82d9df52n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/cd8b9fa4-c6b2-7109-1495-056aac20392d%40skybase.net.