On Tuesday, 28 May 2019 06:52:22 UTC+10, engolling wrote:
>
> So I started off with the noob variant...
> https://github.com/menachers/WeatherDuino/tree/master/WeeWx_Plugin
>

That looks like it will work, but be aware that if the record you are 
augmenting is in anything other than US customary units no conversion will 
be applied (this may be fine given your current setup but who knows how it 
may change in the future). Nothing to worry about if you are going to 
rewrite the code anyway.
 

> I will change it to the sophisticated procedure you proposed. 
> As I got you right
> # express our rainfall value as a ValueTuple
> rainfall_vt = weewx.units.ValueTuple(rainfall, 'mm', 'group_rain')
> I have to generate a tuple with the variable holding the actual value, 
> followed by the unit of the signal as it can be found in the units.py dict 
> and ending with the unit group which it belongs to.
>

Correct. The ValueTuple is the basis of the WeeWX system for unit 
conversion; it brings together the value, the units used and the unit group 
to which it belongs. When WeeWX needs to convert the value to some other 
units or to the units used in a particular unit system (US, Metric or 
MetricWX) the ValueTuple has the core information used to determine how to 
do the conversion. You might want to look at the class ValueTuple in 
bin/weewx/units.py 
<https://github.com/weewx/weewx/blob/master/bin/weewx/units.py#L454>. the 
other good thing about ValueTuple based conversion is that it will handle 
the case where the data value is None - note how in the simple approach I 
outlined we had to take care of the case where the data value may be None. 

Gary

-- 
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/5a5068ac-1c63-4aba-b741-41e05e48eb61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to