This information is also summarized in the documentation: *Units
<https://www.weewx.com/docs/5.1/reference/units/>*

On Wed, Oct 2, 2024 at 8:15 PM 'John Kline' via weewx-user <
weewx-user@googlegroups.com> wrote:

> IIRC,
>
> When your driver creates loop and archive observations, you need to set
> usUnits to reflect the correct system.  For example, the vantage drive sets:
> 'usUnits': weewx.US
> In the loop data and archive records.
>
> If custom driver is in metric, set:
> ‘UsUnits’: weewx.METRIC
>
> If you do this, weewx will do the conversions and store values in the
> database in the system you specified when you created the database.
>
> But there is more.  You have to use the correct metric units.  To do this,
> see the weewx/units.py file.  Look up the observation in that file, find
> the group, and then look up what that group expects.
>
> For example, rain is:
> "rain"                      : "group_rain",
>
> And, if you look up group_rain for metric, you’ll find group_rain is
> expecting cm:
> "group_rain"        : "cm",
>
> # This dictionary maps unit groups to a standard unit type in the
> # metric unit system:
> MetricUnits = ListOfDicts({
>     "group_altitude"    : "meter",
>     "group_amp"         : "amp",
>     "group_angle"       : "degree_angle",
>     "group_boolean"     : "boolean",
>     "group_concentration": "microgram_per_meter_cubed",
>     "group_count"       : "count",
>     "group_data"        : "byte",
>     "group_db"          : "dB",
>     "group_degree_day"  : "degree_C_day",
>     "group_deltatime"   : "second",
>     "group_direction"   : "degree_compass",
>     "group_distance"    : "km",
>     "group_elapsed"     : "second",
>     "group_energy"      : "watt_hour",
>     "group_energy2"     : "watt_second",
>     "group_fraction"    : "ppm",
>     "group_frequency"   : "hertz",
>     "group_illuminance" : "lux",
>     "group_interval"    : "minute",
>     "group_length"      : "cm",
>     "group_moisture"    : "centibar",
>     "group_percent"     : "percent",
>     "group_power"       : "watt",
>     "group_pressure"    : "mbar",
>     "group_pressurerate": "mbar_per_hour",
>     "group_radiation"   : "watt_per_meter_squared",
>     "group_rain"        : "cm",
>     "group_rainrate"    : "cm_per_hour",
>     "group_speed"       : "km_per_hour",
>     "group_speed2"      : "km_per_hour2",
>     "group_temperature" : "degree_C",
>     "group_time"        : "unix_epoch",
>     "group_uv"          : "uv_index",
>     "group_volt"        : "volt",
>     "group_volume"      : "liter"
> })
>
>
> On Oct 2, 2024, at 7:51 PM, Thomas Carlin <thomascarl...@gmail.com> wrote:
>
> I have a sensor that is adding data to WeeWX with a custom driver.
> Unfortunately, the sensor provides values in various metric units, C, hPa,
> µg/m³, things like that.  Obviously it is not a big deal to write these
> conversions into the driver, but i am curious if there is a prebuilt
> mechanism to convert them *before* they go into the database.  Obviously,
> we can do the conversions after the fact, but logically it is better to
> convert and store everything in the same units.
>
> Do i need to do the conversions in the driver, or is there a way built
> into WeeWX?
>
> Many thanks!
>
> --
> 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/e8e19545-1c1b-43b7-8a07-472f5daa4232n%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-user/e8e19545-1c1b-43b7-8a07-472f5daa4232n%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/7862DA18-FA9F-4B63-88AF-C8355C8D3AC2%40johnkline.com
> <https://groups.google.com/d/msgid/weewx-user/7862DA18-FA9F-4B63-88AF-C8355C8D3AC2%40johnkline.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/CAPq0zEB3Hg9mhwDezo0bCWk97bwX59eu3XJMcZy4fRxnCaBNXw%40mail.gmail.com.

Reply via email to