Tom,
 your patch  
"
+                if context == 'current':
+                    context = 'delta_time'
"
solves the problem.  
Many thanks for this. 

Ok,  explicit formatting should always  work,  but this should be the last 
option, to get correct values.
(My personal meaning)  

tke...@gmail.com schrieb am Sonntag, 13. Februar 2022 um 01:29:03 UTC+1:

> 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 
> <https://github.com/weewx/weewx/commit/279bb450ab801c80a12b8ceadd0144e16c473bea>
> .
>
> 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,
>>
>> see https://github.com/WernerKr/weewx-davishealthapi
>> There is no 
>> ... 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. 
>>
>
>> vince schrieb am Samstag, 12. Februar 2022 um 20:07:58 UTC+1:
>>
>>> 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. 
>>>
>> -- 
>>
> 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/aa325a81-83b5-4760-bfe5-06cbbf44ce3an%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-user/aa325a81-83b5-4760-bfe5-06cbbf44ce3an%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/e32d33d8-aadf-4183-86f9-0d7090f635f3n%40googlegroups.com.

Reply via email to