WeeWX 4.10.1 deltatime, long_form and current

104 views
Skip to first unread message

Werner Krenn

unread,
Feb 8, 2023, 6:54:38 AM2/8/23
to weewx-user
before 4.10.1
$current.runtime        18 Tage, 0 Stunden, 18 Minuten

with 4.10.1
$current.runtime        1556294 Sekunden
$current.runtime.hour        432,3 Stunden
$current.runtime.day        18,0 Tage
$current.runtime.long_form    18 Minuten, 14 Sekunden     #missing days and hours!

temporary solution:
in weewx.conf
[StdReport]
    [[Defaults]]
        [[[Units]]]
            [[[[DeltaTimeFormats]]]]
                current = "%(day)d Tage, %(hour)d Stunden, %(minute)d Minuten"        Labels are Text

with
                current   = "%(day)d%(day_label)s, %(hour)d%(hour_label)s, %(minute)d%(minute_label)s"
weewx[11327] ERROR weewx.reportengine: Syntax error: missing option "day_label" in interpolation.
weewx[11327] ERROR weewx.reportengine:    ****       Report ignored

Is there another solution?

Tom Keffer

unread,
Feb 8, 2023, 11:06:12 AM2/8/23
to weewx...@googlegroups.com
Take a look at the Upgrade guide and see if it answers your questions. 






--
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 on the web visit https://groups.google.com/d/msgid/weewx-user/244f2e80-195c-4f99-a5a2-a99af0052257n%40googlegroups.com.

Werner Krenn

unread,
Feb 9, 2023, 5:33:00 AM2/9/23
to weewx-user
>and see if it answers your questions. 
NO.

@Tom,
You assume that the current deltatime value is always less than 1 hour,
otherwise the default definition of
current = "%(minute)d%(minute_label)s, %(second)d%(second_label)s"
makes no sense.

You can now redefine this in weewx.conf or %lang.conf:
current = "%(day)d%(day_label)s, %(hour)d%(hour_label)s, %(minute)d%(minute_label)s".
But with that, you get an error when starting the report:

ERROR weewx.reportengine: Syntax error: missing option "day_label" in interpolation.
If you then change this definition without the '_labels', e.g.;
current = "%(day)d days, %(hour)d hours, %(minute)d minutes".
Then it works, but you lose the foreign language support.
I have now changed the units.py and in
    def long_form(self, val_t, context, format_string=None):
I now differentiate between less than 3600 seconds and less than 86400 seconds and then greater.

Tom Keffer

unread,
Feb 9, 2023, 5:54:23 PM2/9/23
to weewx...@googlegroups.com
@Tom,
You assume that the current deltatime value is always less than 1 hour,
 
I'm not assuming anything. You are using the tag $current, which implies something that is, well, "Current." That is, it is of a time scale comparable to an archive interval or, perhaps, up to a day. Definitely not longer than that.

It can't guess your intentions, nor can it guess that "runtime" might be measured in days. If it can, then tell it that:

$current.runtime.long_form(format_string="%(day)d%(day_label)s, %(hour)d%(hour_label)s, %(minute)d%(minute_label)s")

The reason why it's done this way is so that you don't end up with a leading "0 days" for the typically short time intervals associated with $current.

An alternative is to define a search list extension for "runtime". Then you can apply any context you wish, not just the "current" context.

Hope this helps.

-tk


Reply all
Reply to author
Forward
0 new messages