Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web page locks up if pressure in mbar #4

Open
e107steved opened this issue Feb 25, 2016 · 9 comments
Open

Web page locks up if pressure in mbar #4

e107steved opened this issue Feb 25, 2016 · 9 comments

Comments

@e107steved
Copy link

Using weewx 3.4.0 with VantagePro2 and gauges V2.5.11
Updated ss/skin.conf (or weewx.conf - same effect) with the [[Groups]] definitions to force metric units - in particular:
group_pressure = mbar
Web page with gauges retrieved data once, then locked up - the 'time to next read' counter kept decrementing, but apparently no new data read.

Traced to the fact that in gauge-data.txt we have "pressunit":" mbar", but gauges.js appears to be looking for the string 'mb'

In gauges.js I duplicated every "case 'mb':" statement I could find with "case 'mbar':" and this seems to have solved the problem.
No doubt there is a more elegant solution!

@mcrossley
Copy link
Owner

I have updated the gauge-data.txt.tmpl file to force the pressure units to mb if WeeWX uses mbar. I think that is the best way of handling this. Could you test this version for me and let me know if it works? If it is OK I'll commit the change.

gauge-data.txt.zip

@e107steved
Copy link
Author

Not quite - weewx confuses the issue by adding a leading space to the units!

I modified the template file to cover both eventualities:
`

set pressure UoM to match gauge requirements

#set $UOM_bar = $unit.label.barometer
#if $UOM_bar == 'mbar'
#set $UOM_bar = 'mb'
#else
#if $UOM_bar == ' mbar'
#set $UOM_bar = ' mb'
#end if
#end if
`

With that, the units are certainly generated correctly, and I think its working. I'll give it 24 hours.

@gjr80
Copy link
Contributor

gjr80 commented Mar 2, 2016

Hi, could I suggest using $unit.unit_type.barometer rather than $unit.label.barometer. $unit.label.barometer returns the weewx formatted unit label normally used in weewx generated output, hence the added space. This format is set in the associated skin.conf and could be anything (eg could contain non-English characters etc). If you use $unit.unit_type.barometer then this gives you the internally stored weewx 'type' used for barometer (actually all pressures), again it is set in skin.conf but can only be one of four different values('mbar', 'inHg', 'hPa' or 'mmHg'). The advantage is that if millibars have been specified as the pressure units then the unit type is set to 'mbar' and it will not change irrespective of whether the formatted unit label has spaces or potentially foregin language characters.

Probably does not make a great deal of difference in this case but I think it gives slightly cleaner code and a better example for those that may follow.

Might I suggest the following code:

#set $UOM_bar = $unit.unit_type.barometer
#if $UOM_bar == 'mbar'
#set $UOM_bar = 'mb'
#end if

@mcrossley
Copy link
Owner

Thanks, that is a better solution. I'll have a look at doing the same for the other UoM as well if the labels can be localised...

@e107steved
Copy link
Author

The fix has worked fine for nearly 24 hours now, so I think the principle is proven (it used to fail pretty much instantly).

@e107steved
Copy link
Author

I've just implemented gjr80's suggested change, and that's been working OK for 20 minutes or so now.

@mcrossley
Copy link
Owner

I am working on a more general solution (v. part time) that uses
the unit_type rather than the labels for all the UoM values passed to the
gauges. As has been pointed out the labels can be localised/customised so
are not a good choice.

I'd like you guys to test it for me before I release it.

On 2 March 2016 at 22:03, e107steved notifications@github.com wrote:

I've just implemented gjr80's suggested change, and that's been working OK
for 20 minutes or so now.


Reply to this email directly or view it on GitHub
#4 (comment)
.

@gjr80
Copy link
Contributor

gjr80 commented Mar 15, 2016

Sure.

@mcrossley
Copy link
Owner

This should be in the v2.15.16 update 31 Oct 16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants