I'm still struggling with this. Here's the updated code: #errorCatcher Echo #from weewx.units import ValueTuple, ValueHelper #set $dayradiationacc=0 #for $dd in $week.days #set $light=$daylight(timestamp=$dd) #set $dayradiation=$light.radiation.sum.raw #set $dayradiationacc=$dayradiationacc+$dayradiation #end for #set $dayradiationavg=$dayradiationacc/$week.days #set $dayradiation_vh=ValueHelper(ValueTuple($dayradiationavg,$unit.unit_type.radiation,'group_radiation'),formatter=$station.formatter)
And the error: Jan 28 13:20:28 weather weewx[625144] ERROR weewx.cheetahgenerator: Evaluation of template /etc/weewx/skins/neowx-material/week.html.tmpl failed with exception '<class 'TypeError'>' Jan 28 13:20:28 weather weewx[625144] ERROR weewx.cheetahgenerator: **** Ignoring template /etc/weewx/skins/neowx-material/week.html.tmpl Jan 28 13:20:28 weather weewx[625144] ERROR weewx.cheetahgenerator: **** Reason: unsupported operand type(s) for +: 'float' and 'NoneType' Jan 28 13:20:28 weather weewx[625144] ERROR weewx.cheetahgenerator: **** Traceback (most recent call last): Jan 28 13:20:28 weather weewx[625144] ERROR weewx.cheetahgenerator: **** File "/usr/share/weewx/weewx/cheetahgenerator.py", line 348, in generate Jan 28 13:20:28 weather weewx[625144] ERROR weewx.cheetahgenerator: **** unicode_string = compiled_template.respond() Jan 28 13:20:28 weather weewx[625144] ERROR weewx.cheetahgenerator: **** File "cheetah__etc_weewx_skins_neowx_material_week_html_tmpl_1674912028_8195086_18355.py", line 930, in respond Jan 28 13:20:28 weather weewx[625144] ERROR weewx.cheetahgenerator: **** TypeError: unsupported operand type(s) for +: 'float' and 'NoneType' I'm sure there must be an easy way to do this, I need to calculate the average UV index and solar radiation based on daylight hours only. Thanks in advance! Rory On Thursday, January 26, 2023 at 7:43:57 PM UTC kk44...@gmail.com wrote: > Just before the loop. > > #set $dayradiationacc=0 > > rory.g...@googlemail.com schrieb am Donnerstag, 26. Januar 2023 um > 20:35:07 UTC+1: > >> Thanks again. I have removed the .raw, but as you say $dayradiationacc is >> not initialised: >> >> Jan 26 19:30:32 weather weewx[625144] ERROR weewx.cheetahgenerator: >> Evaluation of template /etc/weewx/skins/neowx-material/week.html.tmpl >> failed. >> >> Jan 26 19:30:32 weather weewx[625144] ERROR weewx.cheetahgenerator: **** >> Ignoring template /etc/weewx/skins/neowx-material/week.html.tmpl >> >> Jan 26 19:30:32 weather weewx[625144] ERROR weewx.cheetahgenerator: **** >> Reason: cannot find 'dayradiationacc' >> >> I’m not sure where this should be initialised so it can increase in value >> through the for loop? >> >> On 26 Jan 2023, at 18:46, Karen K <kk44...@gmail.com> wrote: >> >> There are 3 problems in the next line: >> >> - $dayradiation is already raw, so another raw is too much. >> - $dayradiationacc is not initialized for the first loop >> - $dayradiationacc is already raw, so another raw is too much for the >> following loops >> >> >> rory.g...@googlemail.com schrieb am Donnerstag, 26. Januar 2023 um >> 18:08:23 UTC+1: >> >>> Thanks! That’s moved the error down a line so I’m moving in the right >>> direction. I can’t seem to iterate through the for loop to add each day’s >>> average radiation. >>> >>> On 26 Jan 2023, at 12:59, Karen K <kk44...@gmail.com> wrote: >>> >>> rory.g...@googlemail.com schrieb am Mittwoch, 25. Januar 2023 um >>> 14:22:27 UTC+1: >>> >>>> #set $dayradiation=$dd.$light.radiation.sum.raw <-- this is where it >>>> fails >>>> >>> >>> Try $light.radiation.sum.raw >>> >>> $dd and $light in one statement is too much. >>> >>> >>> >>> -- >>> 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. >>> To unsubscribe from this group and all its topics, send an email to >>> weewx-user+...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/weewx-user/dab05ce0-7f02-4cfe-bd31-1e3e31c9632cn%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/weewx-user/dab05ce0-7f02-4cfe-bd31-1e3e31c9632cn%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >>> >>> >> -- >> 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. >> To unsubscribe from this group and all its topics, send an email to >> weewx-user+...@googlegroups.com. >> >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/weewx-user/7760fae9-9ee4-4ec7-90fc-73654c2ec4f7n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/weewx-user/7760fae9-9ee4-4ec7-90fc-73654c2ec4f7n%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 weewx-user+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/c884c7ba-0b32-4789-b6ad-2da7a4986960n%40googlegroups.com.