Thanks Again Karen K! It needed a little bit of tweaking but now it’s working
great. Here’s the working code extract from week.html.tmpl:
<div class="col-3 text-muted font-small">
#from weewx.units import ValueTuple, ValueHelper
#attr $dayradiationacc=0
#attr $n=0
#for $dd in $year.days
#set $light=$daylight(timestamp=$dd)
#set $dayradiation=$light.radiation.avg.raw
#if $dayradiation is not None
#set $dayradiationacc=$dayradiationacc+$dayradiation
#set $n=$n+1
#end if
#end for
#if $n is not None
#set $dayradiationavg=$dayradiationacc/$n
#set
$dayradiation_vh=ValueHelper(ValueTuple($dayradiationavg,$unit.unit_type.radiation,'group_radiation'),formatter=$station.formatter)
#else
#set $dayradiation_vh=0
#end if
$dayradiation_vh <br>
$Extras.Translations[$Extras.language].avg
</div>
I had to change the initial values for $dayradiationacc and $n to #attr= rather
than #set=, and I put in a test for $n is not None to avoid a divide by zero
error at the start of a new week / month / year before the $daylight tag
returns a value > 1
You can see it in action here: https://www.360shetland.co.uk/weather/week.html
<https://www.360shetland.co.uk/weather/week.html>
Using the standard $week.radiation.avg tag returns a very low value (around
4w/sqm prior to getting this working) as it is averaging each day over 24 hours.
Cheers!
Rory
> On 28 Jan 2023, at 19:45, Karen K <[email protected]> wrote:
>
>
> #from weewx.units import ValueTuple, ValueHelper
> #set $dayradiationacc=0
> #set $n=0
> #for $dd in $week.days
> #set $light=$daylight(timestamp=$dd)
> #set $dayradiation=$light.radiation.sum.raw
> #if $dayradiation is not None
> #set $dayradiationacc=$dayradiationacc+$dayradiation
> #set $n=$n+1
> # end if
> #end for
> #set $dayradiationavg=$dayradiationacc/$n
> #set
> $dayradiation_vh=ValueHelper(ValueTuple($dayradiationavg,$unit.unit_type.radiation,'group_radiation'),formatter=$station.formatter)
>
> --
> You received this message because you are subscribed to a topic in the Google
> Groups "weewx-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/weewx-user/7CPWHA8azqY/unsubscribe
> <https://groups.google.com/d/topic/weewx-user/7CPWHA8azqY/unsubscribe>.
> To unsubscribe from this group and all its topics, 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/79c7e465-551b-43dd-84d3-08a7129be8c4n%40googlegroups.com
>
> <https://groups.google.com/d/msgid/weewx-user/79c7e465-551b-43dd-84d3-08a7129be8c4n%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/3437D5F1-D768-4E4E-861A-8C716C7A7C25%40googlemail.com.