Belchertown skin: Reload index_hooks

81 views
Skip to first unread message

Manfred Maier

unread,
Jun 24, 2020, 4:03:18 AM6/24/20
to weewx-user
Hi Pat,
there might be a possible issue with the reload functionality of the additional index_hook section on the front-page of the skin.

I have the following settings in the weewx.conf

            reload_hook_images = 1

            reload_images_radar = 300

            reload_images_hook_asi = 300

            reload_images_hook_af = -1

            reload_images_hook_as = -1

            reload_images_hook_ac = 300


Still, the index_hook_after_station_info doesn't reload.

Is there anything wrong with this functionality or did I make a mistake in setting up the index_hook (which is much more likely)?

Manfred

Pat

unread,
Jun 24, 2020, 11:41:37 AM6/24/20
to weewx-user
I'll look into this 

Pat

unread,
Jun 24, 2020, 2:24:54 PM6/24/20
to weewx-user
Do you have images in your after station info hook? Or just text. 

Right now it's only going to reload images - but I wonder if it should reload the entire hook? 

Manfred Maier

unread,
Jun 24, 2020, 2:30:12 PM6/24/20
to weewx-user
It's text.
I'm displaying the amount of sunshine hours on that day. In a somewhat dynamic way.

Here's the index_hook_after_station_info I'm using.

    #set sunshinetime = $day.sunshineTime.sum.raw
    #set sunshinetheoretical = $day.sunshineTheoretical.sum.raw
    #set ratio = 0 

    #set hours = int($sunshinetime / 60)
    #set minutes = int($sunshinetime - ($hours * 60))

    #if $sunshinetheoretical > 0
        #set $ratio = $sunshinetime / $sunshinetheoretical
    #end if

    #set $hoursstr = str($hours)

    #if $minutes < 10
        #set $minutesstr = '0' + str($minutes)
    #else
        #set $minutesstr = str($minutes)
    #end if

    #set $sundurationtext = $hoursstr + ':' + $minutesstr + ' Stunden'

    #if $sunshinetheoretical > 0 and $current.sunshineTheoretical.raw == 0 and $sunshinetime > 0
        #set $suntext = 'Heute gab es insgesamt ' + $sundurationtext + ' Sonnenschein.'
    #else if $sunshinetheoretical > 0 and $current.sunshineTheoretical.raw == 0 and $sunshinetime == 0
        #set $suntext = 'Heute gab es leider gar keinen Sonnenschein.'
    #else if $ratio >= 0.7
        #set $suntext = 'Heute gab es schon ' + $sundurationtext + ' Sonnenschein.'
    #else if $ratio >= 0.4
        #set $suntext = 'Heute gab es bisher ' + $sundurationtext + ' Sonnenschein.'
    #else if $ratio < 0.4 and $sunshinetheoretical > 0 and $sunshinetime > 0
        #set $suntext = 'Heute gab es erst ' + $sundurationtext + ' Sonnenschein.'
    #else if $ratio < 0.4 and $sunshinetheoretical > 0 and $sunshinetime == 0
        #set $suntext = 'Heute gab es leider noch keinen Sonnenschein.' 
    #else
        #set $suntext = ''      
    #end if

    #set $dailyrain = $day.rain.sum.raw 

    #if $dailyrain == 0
        #set raintext = 'Bisher kein Regen.'
    #else 
        #set $raintext = 'Bisher ' + str($day.rain.sum) + ' Regen.'
    #end if

<br>
<p align="center" style="font-size:24px">
$suntext $raintext
</p>
<br>

Pat

unread,
Jun 24, 2020, 2:37:13 PM6/24/20
to weewx-user
Ok that makes more sense. Right now the reloads are only for images, not text. 

I'm not sure how I'd be able to reliably reload the hook area text. Those .inc files are only called when the skin is generated, and when the page is reloaded. The AJAX portion does not reload them (since they're unavailable to the public because they live in the skins folder).

Manfred Maier

unread,
Jun 24, 2020, 2:44:35 PM6/24/20
to weewx-user
So a better strategy for me would be to try to include the hours of sunshine in the station observations?

Pat

unread,
Jun 24, 2020, 3:11:17 PM6/24/20
to weewx-user
Good question. I'm not sure that'll work either unless you're able to inject that data into your MQTT broker since the station observation table is updated by MQTT payloads that match the observation's name. 

What would be idea is a way to have a folder called "hooks", and have weewx generate any html.tmpl file within that folder. Then I could use javascript to get the contents of those HTML files much like how I am doing today with the other data. But that won't work because you have to define the folder and template file in skin.conf. If the file is missing, then weewx won't process the skin website generation. 

Not sure how best for you to move forward with custom text being updated automatically. There's gotta be a way, just need to think it through with the limitations in place. 
Reply all
Reply to author
Forward
0 new messages