Sorry. It should be:

t_vh = weewx.units.ValueHelper(t_vt,
converter=weewx.units.StdUnitConverters[weewx.METRICWX])

-tk

On Tue, Apr 30, 2019 at 1:18 AM Graham Eddy <[email protected]> wrote:

> i tried the above and i am missing something...
> it gives an attribute error for a well-known unit. clues would be welcome.
> cheers
>
> my code snippet:
>
>       # Create a Metric ValueHelper for the metric
>
>       t_vt = weewx.units.as_value_tuple(record, metric)
>
>       t_vh = weewx.units.ValueHelper(t_vt,
> converter=weewx.units.MetricWXUnits)
>
>       desc = '[{}] {} {} {} {}'. \
>
>               format(name, metric,
>
>                      t_vh.toString(addLabel=True),
>
>                      '>' if is_rising else '<', threshold)
> noting that i tried just t_vh in string formatting, then tried the
> .toString() in case that was the problem
>
> stack trace snippet:
>
>   File "/opt/weewx/bin/weewx/engine.py", line 224, in dispatchEvent
>
>     callback(event)
>
>   File "/opt/weewx/bin/user/alarm.py", line 166, in new_archive_record
>
>     format(name, metric, t_vh.toString(addLabel=True), '>' if is_rising
> else '<', threshold)
>
>   File "/opt/weewx/bin/weewx/units.py", line 944, in toString
>
>     vtx = self._raw_value_tuple
>
>   File "/opt/weewx/bin/weewx/units.py", line 1015, in __getattr__
>
>     raise AttributeError("Illegal conversion from '%s' to
> '%s'"%(self.value_t[1], target_unit))
>
> AttributeError: Illegal conversion from 'percent' to '_raw_value_tuple'
>
>

Reply via email to