...and it looks like the weewx-mqtt extension already has the ability to do 
just that - specify unit overrides. Taking a look at the weewx-mqtt code 
has this comment:

[StdRestful]
    [[MQTT]]
        ...
        unit_system = METRIC # default to metric
        [[[inputs]]]
            [[[[outTemp]]]]
                name = inside_temperature  # use a label other than outTemp
                format = %.2f              # two decimal places of precision
                units = degree_F           # convert outTemp to F, others 
in C
            [[[[windSpeed]]]]
                units = knot  # convert the wind speed to knots

So, Colin, you could try altering the mqtt settings in your weewx.conf to 
this example below. This example worked for me. I had 0.3 inches of rain 
today, after adding the below and a weewx restart it changed it from 
dayRain_in to dayRain_mm and was showing 7.62 which converts correctly. 
Everything else stayed as it was. 

[StdRestful]
    [[MQTT]]
        ...
        unit_system = METRIC # default to metric
        [[[inputs]]]
            [[[[dayRain]]]]
                name = dayRain_mm
                units = mm


And based on your comment on GitHub 
<https://github.com/poblabs/weewx-belchertown/issues/23#issuecomment-440458755>,
 
I think this is what you want. 

METRIC wind (km/h) - default by the unit_system = metric
METRICWX rain (mm) - overridden by the input above



On Tuesday, November 20, 2018 at 10:05:27 PM UTC-5, Pat wrote:
>
> Thinking about this further, I said:
>
> So would the answer be to have weewx-mqtt transmit in METRICWX and then 
>> specify in the skin options group_wind = km_per_hour? Or would that 
>> cause some miscalculations of wind data?
>
>
> This would be invalid because the base skin would probably do the 
> conversion, but the MQTT published message would have wind in m/s since the 
> weewx-mqtt is setup for METRICWX (in this example). So no matter what I 
> would display that observation as the published m/s but with a label of 
> km/h on the page. 
>
> I think I keep going back to the idea of having the weewx-mqtt 
> <https://github.com/weewx/weewx/wiki/mqtt> send specific observations in 
> the unit the user wants. Similar to a skin's [[[Units]]] [[[[Groups]]]] 
> setup.
>
>
> On Tuesday, November 20, 2018 at 9:57:20 PM UTC-5, Pat wrote:
>>
>> The Belchertown skin extension allows users to specify which group units 
>> they want (much like the standard skin). I think this Issue on my GitHub 
>> repo 
>> <https://github.com/poblabs/weewx-belchertown/issues/23#issuecomment-440477408>
>>  (which 
>> Colin started) tries to a) get my own head wrapped around this and b) 
>> suggest that the weewx-mqtt extension have the ability to also send 
>> specific observations in the unit they want. Similar to a skin setup. 
>>
>> The MQTT extension can specify which units to transmit values in - but 
>> it's an all or nothing conversion (US, METRIC, METRICWX). However based on 
>> the table in the GitHub link (also attached here), I think what's trying to 
>> be determined is if a hybrid scenario can exist somehow? Is that up to the 
>> skin or up to the MQTT extension's transmit values?
>>
>> So would the answer be to have weewx-mqtt transmit in METRICWX and then 
>> specify in the skin options group_wind = km_per_hour? Or would that 
>> cause some miscalculations of wind data?
>>
>> An additional layer on top of all of this is that my skin just displays 
>> what's present in MQTT. So if MQTT is sending dayRain_cm, I display that 
>> even if the user wants dayRain_mm. So I think it would make sense for the 
>> mqtt extension to be able to have granular ability on altering certain 
>> observations. Otherwise the live-updated data coming from MQTT would have 
>> to do in-situ conversions within the JavaScript functions (outside of weewx 
>> conversion utilities) - which is another layer of complexity I'd like to 
>> avoid if possible. 
>>
>> Lastly, if I'm not mistaken I think Colin's database is in US units based 
>> on previous conversations we've had. 
>>
>> On Tuesday, November 20, 2018 at 8:23:05 PM UTC-5, gjr80 wrote:
>>>
>>> Colin,
>>>
>>> US, METRIC or METRICWX merely defines the units used in the weeWX 
>>> database, it really should have no bearing on the presentation of data. For 
>>> example, in the weeWX Standard skin (and for that matter other skins that 
>>> simply use the weeWX report system for generating reports) the weeWX tag 
>>> system and config settings in skin.conf/weewx.conf determine what 
>>> presentation units are used. The user can freely (and simply) change these 
>>> settings to display whatever units he/she requires in the resulting 
>>> reports. Of course once you step outside extensions that only use the weeWX 
>>> reporting system things become a little more complex, chnaces are you 
>>> cannot rely solely on the weeWX tag system. In my view it really behoves 
>>> those that produce extensions to weeWX to provide a means of selecting the 
>>> units displayed by their extension, this may be as simple as the tags and 
>>> skin/weewx config as previously mentioned, or for more complex extensions 
>>> that say use MQTT or some other external app/system then some other 
>>> mechanism is required. I am not fully across Pat's Belchertown extension 
>>> but given it is still relatively young and being actively developed I would 
>>> hope Pat would include some sort of user selectable settings/config options 
>>> that allow you to display in whatever units you wish irrespective of the 
>>> underlying database units.
>>>
>>> In getting back to your original question I suspect there is not too 
>>> much that can be done by you to change things unless the Belchertown 
>>> extension has some as yet unknown config settings to do what you want. Pat 
>>> or other Belchertown users are the best placed to help with this. I also 
>>> suspect there is little you can do directly to weeWX. If it was me I would 
>>> be using US customary units in my database unless you have good reason not 
>>> to (* see note) and I would be approaching Pat for a means to allow the 
>>> user to alter the Belcherton presentation units.
>>>
>>> Note: FWIW I am in Australia and prefer to be able to view metric data 
>>> on the odd occasion I want to look at my raw database data so I run METRIC 
>>> (when I first started using weeWX there was only US or METRIC, METRICWX 
>>> came later), I just have to keep reminding myself that rain is in cm. I 
>>> also do all my development work using a US units database and since I 
>>> mostly develop for my requirements that way I am forced to make sure I have 
>>> a mechanism to display metric units.
>>>
>>> Gary
>>>
>>> On Wednesday, 21 November 2018 10:06:16 UTC+10, Colin Larsen wrote:
>>>>
>>>> Hi all
>>>>
>>>> I'm putting this out on the Weewx forum as I'm not sure if there is a 
>>>> simple answer within Weewx for this problem.
>>>>
>>>> Down in NZ it is common to report rain in mm and wind speed in kp/hr
>>>>
>>>> In publishing MQTT data for Pats Belchertown skin this is causing an 
>>>> issue whereby if I set MQTT to publish Metric I get wind speed and gust in 
>>>> kp/h ..... but rain is reported in CM. Pats skin looks at the group units 
>>>> which I have set to mm for rain and publishes the data, which is CM as he 
>>>> sees the MQTT data is Metric and I get 0.14 mm of rain instead of the 
>>>> 1.4mm 
>>>> it should be. Same for rain rate of course.
>>>>
>>>> I can fix the rain by using Metricwx which publishes rain in mm - but 
>>>> then wind is in m/s so that reports wrong as the group units are kph.
>>>>
>>>> Can anyone suggest a solution within Weewx to the conundrum?
>>>>
>>>> Many thanks
>>>> Colin
>>>>
>>>

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to