Very clever!

Be sure to check out the wiki document *Tags for series
<https://github.com/weewx/weewx/wiki/Tags-for-series>*. It might help you
simplify some of your template.

On Sun, Apr 3, 2022 at 8:30 PM Warren Gill <[email protected]> wrote:

> curves.json.tmpl is a custom template I made to use with Chart.js
> It's all working now!
>
> { "current" : { "datetime" : "$current.dateTime.raw"},
>   "monthly": [
> #for $m in $range(12)
>      {
>           "month": "$month($months_ago=$m).dateTime.format('%B')",
>           "min": $month($months_ago=$m).outTemp.min.nolabel('%.1f'),
>           "max": $month($months_ago=$m).outTemp.max.nolabel('%.1f')
> #if $m < 11
>      },
> #else
>      }
> #end if
> #end for
>   ],
>   "last24": [
> #for $_span in $span($hour_delta=24).spans(interval=1200)
>      { "datetime": "$_span.start.format('%r')", "temp":
> $_span.outTemp.avg.format(add_label=False), "dewpoint":
> $_span.dewpoint.avg.format(add_label=False), "humidity":
> $_span.outHumidity.avg.format(add_label=False), "windchill":
> $_span.windchill.avg.format(add_label=False), "heat_index":
> $_span.heatindex.avg.format(add_label=False), "barometer" :
> $_span.barometer.avg.format(add_label=False) },
> #end for
>      { "void_end" : null }
>   ]
> }
> [image: wechart.png]
>
> On Sunday, April 3, 2022 at 7:58:56 PM UTC-5 [email protected] wrote:
>
>> I just tried your snippet on my machine and it worked fine:
>>
>> { "month": -3.8°C },
>> { "month": -3.7°C },
>> { "month": -4.9°C },
>> { "month": 5.9°C },
>> { "month": 9.2°C },
>> { "month": 8.5°C },
>> { "month": 5.7°C },
>> { "month": 0.5°C },
>> { "month": -1.2°C },
>> { "month": -4.0°C },
>> { "month": -4.0°C },
>> { "month": -7.7°C },
>>
>> What is the template /etc/weewx/skins/Seasons/curves_json.tmpl? It's not
>> part of WeeWX. Check it for errors.
>>
>> -tk
>>
>> On Sun, Apr 3, 2022 at 11:13 AM Warren Gill <[email protected]> wrote:
>>
>>> If I add the month aggregation to my templates, Cheetah chokes.
>>>
>>> #for $m in $range(12)
>>> { "month": $month($months_ago=$m).outTemp.min },
>>> #end for
>>>
>>> Produces the following error:
>>>
>>> Apr 03 13:07:04 weather python2[21603]: wee_reports[21603] ERROR
>>> weewx.cheetahgenerator: Evaluation of template
>>> /etc/weewx/skins/Seasons/curves.json.tmpl failed with exception '<type
>>> 'exceptions.TypeError'>'
>>> Apr 03 13:07:04 weather python2[21603]: wee_reports[21603] ERROR
>>> weewx.cheetahgenerator: **** Ignoring template
>>> /etc/weewx/skins/Seasons/curves.json.tmpl
>>> Apr 03 13:07:04 weather python2[21603]: wee_reports[21603] ERROR
>>> weewx.cheetahgenerator: **** Reason: __call__() got an unexpected
>>> keyword argument 'months_ago'
>>> Apr 03 13:07:04 weather python2[21603]: wee_reports[21603] ERROR
>>> weewx.cheetahgenerator: **** Traceback (most recent call last):
>>> Apr 03 13:07:04 weather python2[21603]: wee_reports[21603] ERROR
>>> weewx.cheetahgenerator: **** File
>>> "/usr/share/weewx/weewx/cheetahgenerator.py", line 348, in generate
>>> Apr 03 13:07:04 weather python2[21603]: wee_reports[21603] ERROR
>>> weewx.cheetahgenerator: **** unicode_string =
>>> compiled_template.respond()
>>> Apr 03 13:07:04 weather python2[21603]: wee_reports[21603] ERROR
>>> weewx.cheetahgenerator: **** File
>>> "_etc_weewx_skins_Seasons_curves_json_tmpl.py", line 109, in respond
>>> Apr 03 13:07:04 weather python2[21603]: wee_reports[21603] ERROR
>>> weewx.cheetahgenerator: **** TypeError: __call__() got an unexpected
>>> keyword argument 'months_ago'
>>>
>>> However, other aggregations (days, weeks, years) work fine:
>>>
>>> #for $m in $range(12)
>>> { "month": $year($years_ago=$m).outTemp.min },
>>> #end for
>>>
>>> No errors produced, output is as expected.
>>>
>>> What am I doing wrong?
>>>
>>> --
>>> 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/16b67157-78d9-4af4-8241-4746023cdb66n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/weewx-user/16b67157-78d9-4af4-8241-4746023cdb66n%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/e67239cc-eab8-4f26-adda-2745c498a37an%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/e67239cc-eab8-4f26-adda-2745c498a37an%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/CAPq0zED5S398tigZAJyFYYK9r%2B_nx-n7T1MDHbqV0YxziGL0MQ%40mail.gmail.com.

Reply via email to