changing to metric system when using driver as a standalone program

111 views
Skip to first unread message

Saverio Guzzo

unread,
Feb 21, 2022, 9:40:30 AM2/21/22
to weewx-user
Hello community!

I'm using the vantage's driver as a standalone program and I'm wondering if there is an way to convert the measurements to the metric system.
I tried to edit the entry "unit_system" of the  file "weewx-x.y.z/weewx.conf" to 'metric', but when running the following piece of code

for packet in vantage.genDavisArchiveRecords(since_ts):
print(packet)

I still get all the measurements in US system.

What I am missing?

Thank you very much for your help, I appreciate it :)
Saverio

Tom Keffer

unread,
Feb 21, 2022, 1:01:52 PM2/21/22
to weewx-user
The Vantage series reports measurements in the US Customary unit system. Because you are printing packets directly from the driver, that's what you're going to get.

One thing you can do is take advantage of one of the functions in units.py. Try this:

import weewx.units
for packet in vantage.genDavisArchiveRecords(since_ts):
    new_packet = weewx.units.to_METRICWX(packet)
    print(new_packet)



--
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/9e5b1613-3b95-4696-aa40-f928d42d3c92n%40googlegroups.com.

Saverio Guzzo

unread,
Feb 23, 2022, 7:23:00 AM2/23/22
to weewx-user
Wow, thanks Tom!
Such an excellent program!

SG

Saverio Guzzo

unread,
Mar 23, 2022, 4:04:48 AM3/23/22
to weewx-user
Hi Tom,

Using the function weewx.units.to_METRICWX is working well for all the fields but highOutTemp, which keeps still being reported in Fahrenheit. Would you have any ideas on the reason for this?

Thanks again!
Saverio

Tom Keffer

unread,
Mar 23, 2022, 8:33:14 AM3/23/22
to weewx-user
It looks like it (and lowOutTemp) were never assigned to a unit group. 

Fixed in commit a55892e.

You can either patch your copy of weewx/units.py, or download a fresh one.

Saverio Guzzo

unread,
Mar 24, 2022, 7:57:17 AM3/24/22
to weewx-user
This is solving the issue!

Thanks a lot, Tom!

Reply all
Reply to author
Forward
0 new messages