Using $time_since with a different database binding.

64 views
Skip to first unread message

Ian

unread,
Mar 2, 2026, 7:09:24 PM (5 days ago) Mar 2
to weewx-user
Tom, 

Is it possible to use the weewx-time_since extension tag $time_since with a different binding?

Thanks,
Ian

Tom Keffer

unread,
Mar 2, 2026, 7:33:00 PM (5 days ago) Mar 2
to weewx...@googlegroups.com
No you cannot, but it really should be possible. An omission on my part.

Let me think about that a bit.

--
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+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-user/b20d3467-4052-423c-bd75-239c5571e8a0n%40googlegroups.com.

Tom Keffer

unread,
Mar 2, 2026, 9:10:50 PM (4 days ago) Mar 2
to weewx...@googlegroups.com
Give it a try now.  It would look something like:
<p>It last rained at $time_at('rain>0', alt_binding) ($time_since('rain>0', alt_binding).long_form ago).</p>

DR

unread,
Mar 2, 2026, 10:21:06 PM (4 days ago) Mar 2
to weewx...@googlegroups.com
Is there a newly revised service which needs to be reloaded to make this
work, or did  you just clarify that what was installed with the
time_since type of tag works ok with what was furnished previously?


Ian Millard

unread,
Mar 3, 2026, 2:23:14 AM (4 days ago) Mar 3
to weewx...@googlegroups.com
It looks like it as it was updated 5 hours ago.

> On 3 Mar 2026, at 03:20, DR <daleea...@gmail.com> wrote:
>
> Is there a newly revised service which needs to be reloaded to make this work, or did you just clarify that what was installed with the time_since type of tag works ok with what was furnished previously?
>
>
> --
> 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+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/weewx-user/f387b426-a947-4a3e-89f9-9b185e4e2612%40gmail.com.

Tom Keffer

unread,
Mar 3, 2026, 7:18:17 AM (4 days ago) Mar 3
to weewx...@googlegroups.com
weewx-time_since is just a simple search list extension. No service involved.

--
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+...@googlegroups.com.
Message has been deleted

Ian

unread,
Mar 3, 2026, 7:54:59 AM (4 days ago) Mar 3
to weewx-user
Tom, 

This is from my journal log when I tried the update: -

Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: Evaluation of template /home/trixie/weewx-data/skins/Test/test.php.tmpl failed with exception '<class 'NameError'>'
Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: **** Ignoring template /home/trixie/weewx-data/skins/Test/test.php.tmpl
Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: **** Reason: name 'weewx_extras_binding' is not defined
Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: ****  Traceback (most recent call last):
Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: ****    File "/home/trixie/weewx-venv/lib/python3.13/site-packages/weewx/cheetahgenerator.py", line 334, in generate
Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: ****    File "_home_trixie_weewx_data_skins_Test_test.php.tmpl .py", line 5350, in respond
Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: ****    File "_home_trixie_weewx_data_skins_Test_test.php.tmpl .py", line 2030, in __errorCatcher280
Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: ****    File "<string>", line 1, in <module>
Mar 03 12:35:55 trixiepi weewxd[2955661]: ERROR weewx.cheetahgenerator: ****  NameError: name 'weewx_extras_binding' is not defined

The weewx_extras.sdb is actively up and running and being populated.

This is how I deployed in test.php.tmpl: -

$rain["event"] = $data["observations"]["eventRain"] ?? null;
if(is_numeric($rain["event"]) != 1){$rain["event"] = 0;}
if($rain["event"] > 0 ){$rain["storm_start"] = date('H:i D j M',($TS)-($time_since('stormRain=0', weewx_extras_binding).raw);}


Ian

Tom Keffer

unread,
Mar 3, 2026, 8:25:09 AM (4 days ago) Mar 3
to weewx...@googlegroups.com
I gave you a bad example. You need quotes around weewx_extras_binding. It's a string, not a Python expression.

So, it becomes:

if($rain["event"] > 0 ){$rain["storm_start"] = date('H:i D j M',($TS)-($time_since('stormRain=0', 'weewx_extras_binding').raw);}


Ian

unread,
Mar 3, 2026, 9:23:56 AM (4 days ago) Mar 3
to weewx-user
Thank you Tom, that worked perfectly :-)

Ian
Reply all
Reply to author
Forward
0 new messages