thanks (i think).
if i use this - and i have yet to come up with a feasible alternative - i think 
i’ll bury it under a pile of leaves at the bottom of the file...

> On 2 Nov 2020, at 11:14 pm, Tom Keffer <[email protected]> wrote:
> 
> I can't think of any elegant way to do it, but an inelegant way is to monkey 
> patch ValueHelper.
> 
> import weewx.units
> 
> def category(vh):
>   if vh.raw is None:
>     result = "N/A"
>   elif vh.raw < 50:
>     result = "good"
>   elif vh.raw < 100:
>     result = "moderate"
>   else:
>     result = "bad"
>   return result
> 
> weewx.units.ValueHelper.category = category
> 
> The ValueHelper class has been pretty stable for a long time, so you're 
> unlikely to break things in an upgrade. But, there's no guarantees!
> 
> -tk
> 
> On Mon, Nov 2, 2020 at 1:12 AM Graham Eddy <[email protected] 
> <mailto:[email protected]>> wrote:
> there is an existing optional formatting tag ‘ordinal_compass’ for data_type 
> ‘windDir’
> eg. where $current.windDir.raw = 45, $current.windDir.ordinal_compass = “NE"
> 
> i would like to create a new optional formatting tag ‘category’ for new xtype 
> ‘aqi_pm2_51’ (air quality index derived PM2.5)
> e.g. where $current.aqi_pm2_51.raw = 75, $current.aqi_pm2_51.category = 
> “Moderate”
> 
> how do i create the new optional formatting tag?
> so far all i have found is to extend weewx.units.ValueHelper - i guess a 
> function called “catgeory” would be picked up to do the formatting. but this 
> would require changing rather than extending weewx codebase.
> have i missed something obvious?
> 
> -- 
> 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 [email protected] 
> <mailto:weewx-user%[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/weewx-user/487EFABB-872F-449C-A685-8BB5FD83EF98%40gmail.com
>  
> <https://groups.google.com/d/msgid/weewx-user/487EFABB-872F-449C-A685-8BB5FD83EF98%40gmail.com>.
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/weewx-user/CAPq0zEA-biYRcrTk__y2-Avam%2BcW9U0-z0iDjxc%2BdW%3DH-dkq1g%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/weewx-user/CAPq0zEA-biYRcrTk__y2-Avam%2BcW9U0-z0iDjxc%2BdW%3DH-dkq1g%40mail.gmail.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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/B6BE9719-0EC9-4DF2-A68A-A34A272CF1DA%40gmail.com.

Reply via email to