DEFAULT_DELTATIME_FORMAT

138 views
Skip to first unread message

Werner Krenn

unread,
Feb 11, 2022, 2:02:01 PM2/11/22
to weewx-user
seems that in 4.6.x on RasPi 4 (Buster) 
DEFAULT_DELTATIME_FORMAT = "%(day)d%(day_label)s, " \
                           "%(hour)d%(hour_label)s, " \
                           "%(minute)d%(minute_label)s"

raised alway an execption here:
    <tr>
      <td class="label">$obs.label.uptime</td>
      <td class="data">$current($max_delta=3600,$data_binding='davishealthapi_binding').uptime</td>
    </tr>

uptime:
weewx.units.obs_group_dict["uptime"] = "group_deltatime"

 
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/cheetahgenerator.py", line 344, in generate
weewx[13269] ERROR weewx.cheetahgenerator: ****      unicode_string = compiled_template.respond()
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "_etc_weewx3_skins_health_index_html_tmpl.py", line 178, in respond
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3/dist-packages/Cheetah/Template.py", line 1707, in _handleCheetahInclude
weewx[13269] ERROR weewx.cheetahgenerator: ****      self._CHEETAH__cheetahIncludes[_includeID].respond(trans)
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "_etc_weewx3_skins_health_sensors_inc.py", line 706, in respond
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/cheetahgenerator.py", line 819, in filter
weewx[13269] ERROR weewx.cheetahgenerator: ****      filtered = six.text_type(val)
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/units.py", line 1005, in __str__
weewx[13269] ERROR weewx.cheetahgenerator: ****      s = self.toString()
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/units.py", line 1000, in toString
weewx[13269] ERROR weewx.cheetahgenerator: ****      localize=localize)
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/units.py", line 688, in toString
weewx[13269] ERROR weewx.cheetahgenerator: ****      s = self._to_string(val_t, context, addLabel, useThisFormat, None_string, localize)
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/units.py", line 748, in _to_string
weewx[13269] ERROR weewx.cheetahgenerator: ****      val_str = self.delta_secs_to_string(val_t[0], format_string)
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/share/weewx/weewx/units.py", line 796, in delta_secs_to_string
weewx[13269] ERROR weewx.cheetahgenerator: ****      ans = locale.format_string(label_format, etime_dict)
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3.7/locale.py", line 223, in format_string
weewx[13269] ERROR weewx.cheetahgenerator: ****      new_val.append(_format(perc.group(), val, grouping, monetary))
weewx[13269] ERROR weewx.cheetahgenerator: ****    File "/usr/lib/python3.7/locale.py", line 187, in _format
weewx[13269] ERROR weewx.cheetahgenerator: ****      formatted = percent % value
weewx[13269] ERROR weewx.cheetahgenerator: ****  TypeError: %x format: an integer is required, not dict

corrected it now with the code from 4.5.1:
        elif val_t[2] == "group_deltatime":
            # Get a delta-time format string. Use a default if the user did not supply one:
            if useThisFormat is None:
                format_string = self.time_format_dict.get("delta_time",
                                                           default_time_format_dict["delta_time"])
            #if useThisFormat is None:
            #    format_string = self.time_format_dict.get(context, DEFAULT_DELTATIME_FORMAT)
            else:

Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Christian Peters

unread,
Feb 11, 2022, 4:29:36 PM2/11/22
to weewx-user
Hi ,
I saw the same error here on Buslleye and ugrade from 4.5.1 to 4.6.2-1. After the  downgrade my weewx.conf seems modified/broken as I now saw Fahrenheit instead of Celsius, inHg  instead of hPa  in my Responsive skin!? Something odd.... After restoring my weewx.conf too all is ok again now on 4.5.1....

Regards,

Christian 

Tom Keffer

unread,
Feb 12, 2022, 7:35:50 AM2/12/22
to weewx-user

--
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/c35c3628-24e3-4989-8854-c30778d07cb9n%40googlegroups.com.

Werner Krenn

unread,
Feb 12, 2022, 1:41:49 PM2/12/22
to weewx-user
Tom,

where can I add "context='long_delta' ?
python? 
or Weewx direct in cheetahgenerator?
I use no extension -  my "uptime" is a value from the archive records in the database. 
My meaning is: that the default-settings for deltatime in 4.6 are not used 

vince

unread,
Feb 12, 2022, 2:07:58 PM2/12/22
to weewx-user
On Saturday, February 12, 2022 at 10:41:49 AM UTC-8 xzei...@googlemail.com wrote:
raised alway an execption here:
    <tr>
      <td class="label">$obs.label.uptime</td>
      <td class="data">$current($max_delta=3600,$data_binding='davishealthapi_binding').uptime</td>
    </tr>


It is likely associated with your weewx-davishealthapi extension....

Do "wee_extension --list" and you should see that you have that installed. 
Message has been deleted

Tom Keffer

unread,
Feb 12, 2022, 7:29:03 PM2/12/22
to weewx-user
I've taken a look at your extension, and I've been able to replicate the problem.

You are defining some new types (such as 'uptime', or 'linkUptime') that are assigned to group_deltatime, which is a perfectly reasonable thing to do. The problem is that there is no 'context' to go along with them to specify what string format to use, which causes the TypeError. 

This is a use case that I had not anticipated, although I really should have. I had assumed that members of group_deltatime would always be generated programmatically, not from a database. In retrospect, a silly assumption.

I've done a commit to supply a sensible default context if none has been supplied. Commit 279bb45.

Here's the patch:

Index: bin/weewx/units.py
===================================================================
diff --git a/bin/weewx/units.py b/bin/weewx/units.py
--- a/bin/weewx/units.py (revision ce49dbdf5d9125550594e3ba58ebbfc0a67073ea)
+++ b/bin/weewx/units.py (date 1644711155863)
@@ -741,6 +741,8 @@

         elif val_t[2] == "group_deltatime":
             # Get a delta-time format string. Use a default if the user did not supply one:
             if useThisFormat is None:
+                if context == 'current':
+                    context = 'delta_time'

                 format_string = self.time_format_dict.get(context, DEFAULT_DELTATIME_FORMAT)
             else:
                 format_string = useThisFormat

If the default delta time formatting doesn't work, you can supply an explicit formatting. Formatting for delta times is a little different from regular types because interpolation must be used to cover all the different parts of the string. For example, instead of 

$current.linkUptime

use

$current.linkUptime.format("%(hour)d%(hour_label)s, %(minute)d%(minute_label)s, %(second)d%(second_label)s")

or

$current.linkUptime.format("%(day)d%(day_label)s, %(hour)d%(hour_label)s, %(minute)d%(minute_label)s")

Hopefully, you get the idea.

To get you going now, you can either supply the patch I included above, or you can use explicit formatting. Either will work.

-tk



On Sat, Feb 12, 2022 at 2:55 PM 'Werner Krenn' via weewx-user <weewx...@googlegroups.com> wrote:
vince,

... ValueHelper(delta_time_vt, context='long_delta', formatter=self.generator.formatter, converter=self.generator.converter)
or so. 
If now (V4.6) all values from the database with "group_deltatime' need extra converting for showing, then that makes sense. 
--
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.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages