Yep, that's my plan for future records. 

For past records in the archive table, I need to convert those since 
they're in the wrong unit because I was not letting weewx handle the 
conversion previously. 

On Thursday, July 2, 2020 at 5:19:35 PM UTC-4, Tom Keffer wrote:
>
> Again, I wouldn't "convert to miles." Instead, convert to whatever unit 
> system the record is using. Let WeeWX take care of the rest.
>
> On Thu, Jul 2, 2020 at 1:30 PM Pat <p...@obrienphoto.net <javascript:>> 
> wrote:
>
>> Excellent! Now to update the extension and convert all my archive records 
>> to miles instead of km. Always learning. Thanks again! 
>>
>> On Thursday, July 2, 2020 at 3:27:49 PM UTC-4, Tom Keffer wrote:
>>>
>>> usUnits == 1 means that the packet uses the US Customary unit system. 
>>> So, yes, you would have to change to miles. But, good extensions assume 
>>> nothing. The function weewx.units.convertStd is a convenient way to ensure 
>>> the correct units. For example, if "val" holds the distance in km, 
>>> something like this would work (NOT TESTED):
>>>
>>> record['lightning_distance'] = weewx.units.convertStd( (val, 'km', 
>>> 'group_distance'), record['usUnits'])
>>>
>>> -tk
>>>
>>> On Thu, Jul 2, 2020 at 8:16 AM Pat <p...@obrienphoto.net> wrote:
>>>
>>>> Got it, running weewxd, I see the usUnits: 1, so I assume I have a 
>>>> mismatch with this particular field?
>>>>
>>>>
>>>> On Thursday, July 2, 2020 at 11:12:16 AM UTC-4, Tom Keffer wrote:
>>>>>
>>>>> Then you need to check the unit system of the incoming packet (don't 
>>>>> assume it's in US), then change lightning_distance into the appropriate 
>>>>> unit for that unit system.
>>>>>
>>>>> The goal is for the units within a packet to be in a consistent unit 
>>>>> system. Doesn't matter what that unit system is --- just that all types 
>>>>> within the packet are in that system.
>>>>>
>>>>> -tk
>>>>>
>>>>> On Thu, Jul 2, 2020 at 7:59 AM Pat <p...@obrienphoto.net> wrote:
>>>>>
>>>>>> Thanks. Currently I'm just putting it into the loop as the raw data 
>>>>>> which is in km. Sounds like I need to convert it to miles so it's 
>>>>>> consistent.
>>>>>>
>>>>>> On Thursday, July 2, 2020 at 8:49:12 AM UTC-4, Tom Keffer wrote:
>>>>>>>
>>>>>>> Just make sure its units are consistent with whatever packet or 
>>>>>>> record you put it in. The engine will take care of the rest. 
>>>>>>>
>>>>>>> Details depend on whether you are adding lightning_distance to an 
>>>>>>> existing packet, or if you are creating a packet.
>>>>>>>
>>>>>>> -tk
>>>>>>>
>>>>>>> On Thu, Jul 2, 2020 at 5:42 AM Pat <p...@obrienphoto.net> wrote:
>>>>>>>
>>>>>>>> I'm working on migrating over to the extended schema and have a 
>>>>>>>> question on the lightning_distance column. My sensor outputs as km, 
>>>>>>>> but 
>>>>>>>> should I save this observation as miles in the database if my usUnits 
>>>>>>>> are 1?
>>>>>>>>
>>>>>>>> Just looking for confirmation since I didn't see anything in the 
>>>>>>>> docs. 
>>>>>>>>
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "weewx-development" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>> send an email to weewx-de...@googlegroups.com.
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/weewx-development/0d8b6153-6f83-49d2-9be3-46a12cec21b1o%40googlegroups.com
>>>>>>>>  
>>>>>>>> <https://groups.google.com/d/msgid/weewx-development/0d8b6153-6f83-49d2-9be3-46a12cec21b1o%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>> .
>>>>>>>>
>>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "weewx-development" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to weewx-de...@googlegroups.com.
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/weewx-development/98985075-bab7-4c73-8598-3cc7c2b64d0co%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/weewx-development/98985075-bab7-4c73-8598-3cc7c2b64d0co%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "weewx-development" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to weewx-de...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/weewx-development/770c70d5-1168-42cf-b4a6-1b28e0664689o%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/weewx-development/770c70d5-1168-42cf-b4a6-1b28e0664689o%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-development" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to weewx-de...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-development/36078a3e-e170-4431-ba3a-fee7c83ca494o%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-development/36078a3e-e170-4431-ba3a-fee7c83ca494o%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-development+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/5f31affa-047e-4473-abe9-7356415541aco%40googlegroups.com.

Reply via email to