Where do I override / specify %3.2 float format for an added measurement?

104 views
Skip to first unread message

messyp...@gmail.com

unread,
Jul 15, 2023, 5:55:24 PM7/15/23
to weewx-user
I got the added  measurement added to the database, and into the skins, however I don't need Lake Elevation to be show in so many digits.  I previously (3.9.1) had it showing 2 digits to the right of the decimal. 
Also, I don't know what happened but now the Barometer has changed its formatting to bold and more decimal places.
Where do I fix this?
Thanks - - -
Current Conditions

Outside Temperature

86.1°F

Dew Point

73.8°F

Outside Humidity

67%

Barometer

29.799 inHg (-0.033)

Wind

0 mph N/A ( N/A)

Rain Today

0.02 in

Rain Rate

0.00 in/h

Inside Temperature

92.6°F

LakeElev

594.770000

Inside Humidity

64%

Tom Keffer

unread,
Jul 15, 2023, 6:22:00 PM7/15/23
to weewx...@googlegroups.com
For altitude, format it like any other tag. See the section Formatting options in the Customizing Guide. For example, if you do not want anything beyond the decimal point:

$station.altitude.format("%.0f")

Same with barometer. To show 2 digits:

$current.barometer.format("%.2f")

Whether it is in bold is a function of whatever CSS styling you are using.

-tk


--
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/c2c9ce27-f091-4ddb-afad-616d6c287bfdn%40googlegroups.com.

Messy Potamia

unread,
Jul 16, 2023, 3:33:05 AM7/16/23
to weewx...@googlegroups.com
Where do those 2 formatting statements go?
Also, why, in current.inc, is the line
#set $observations =
$to_list($DisplayOptions.get('observations_current', ['outTemp',
'barometer']))
containing only outTemp and barometer? Where are the rest of the items
displayed in Current Conditions? Sorry I'm just not getting the
formatting layout big picture. Yes I'm reading the customization guide
but I'm having questions as I read it.
Thanks!
> You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/9hY3_PBqY5E/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEAaMotCOwYy6y0sqiPK-n8Jzz1F2ZzRB0t5ofQtfJefBQ%40mail.gmail.com.

Messy Potamia

unread,
Jul 16, 2023, 5:11:31 AM7/16/23
to weewx...@googlegroups.com
Also should I have mentioned my newly added LakeElev column in the
database is not a member of any "group"? i.e. not group_altitude. Not
sure where I would group it; I do remember that in my 3.9.1 I edited
"units.py" and added group Lake and added new things like "foot2" and
"inch2" and someone politely admonished me as that was not the optimum
practice, but I didn't understand the preferred method of making Lake
Elevation %3.2f and wave height (inches) %2.0f. Sorry.
Thanks for your help.

Tom Keffer

unread,
Jul 16, 2023, 10:22:52 AM7/16/23
to weewx...@googlegroups.com
Sorry. I had assumed you were still using your v3.9.1 Seasons skin. If that's the case, the tag $current.barometer is in the file Seasons/current.inc. 

Incidentally, there's no reason not to continue using your old skin.

But, if you are actually using a V4 skin, then to answer your questions:

1. The line "#set observations = ..." is actually saying get the set of observations from $DisplayOptions. If DisplayOptions does not have an entry, then the fallback is to use just outTemp and barometer. See the configuration file skin.conf for what's in DisplayOptions.

2. You can specify an override for the barometer formatting for the unit "inHg" in weewx.conf:

[StdReport]
  ...
  [[Defaults]]
    ...
    [[[Units]]]
      ...
      [[[[StringFormats]]]]
        inHg = %.2f

3. I'm not following your question about "LakeElev". I don't know what that is.


DR

unread,
Jul 16, 2023, 12:19:22 PM7/16/23
to weewx...@googlegroups.com

I'm confused (again).

You mention that you CAN use an older version of a skin even in a newer version of WeeWx.


I have a WeeWx 4.5.1 running with a Seasons skin that I like.  Somewhere along the evolution the way that the newer versions handle the plots and the summaries was changed, and I assumed that to run the newer versions of WeeWx that those old skins were not compatible with the current release.


I haven't gotten things figured out yet, but perhaps should just hold tight and wait for 5 to come out and then tackle learning the finer points.


I was just taken aback by Tom's comment that older skins were OK to use.


Dale

vince

unread,
Jul 16, 2023, 1:13:52 PM7/16/23
to weewx-user
You're probably overthinking.

WeeWX doesn't care what version of a skin you use, be it older, newer, or totally custom written by you or a third party.


gjr80

unread,
Jul 16, 2023, 1:56:49 PM7/16/23
to weewx-user
You do need to be careful with the parameterised Seasons skin introduced in v4.6.0, there are a couple of features that require WeeWX v4.6.0 or later. But in the main the shipped skins don't care about WeeWX version, the shipped skins tend to use WeeWX features/tags that have existed since very early on. I would tread carefully with third party skins, new tags have been introduced in quite a few WeeWX versions so any skins relying on these new tags may not work with earlier WeeWX versions. Really depends on the skin.

Gary 

DR

unread,
Jul 16, 2023, 2:42:33 PM7/16/23
to weewx...@googlegroups.com

Thank you for those answers.  I will continue to experiment.  Dale


On 7/16/2023 12:13 PM, vince wrote:
You're probably overthinking.

WeeWX doesn't care what version of a skin you use, be it older, newer, or totally custom written by you or a third party.


--
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.

Messy Potamia

unread,
Jul 16, 2023, 2:45:44 PM7/16/23
to weewx...@googlegroups.com
re: "3. I'm not following your question about "LakeElev". I don't know
what that is."
I have a ultrasonic range sensor (MaxBotix) which uses ttyS0 on the pi
which some python code (which has been working very well for several
years and still is) which writes a single line of text containing two
values to a file. My /home/weewx/bin/user/lakedata.py reads the first
value, converts it to a float, and stores it in the new parameter I
added to the weewx.sdb using the utility to add a column. Using a
sqlitebrowser i verified that column is populating every 5 minutes.
The name of the column is LakeElev; weewx is successfully displaying
that data since I've added it to the proper skins/configs.
The only problem is, even after reading & rereading the guides, I
don't get how I tell weewx to treat that as a fully organized
measurement. For instance, added "[[[[StringFormats]]]]
inHg = %.2f" to weewx.conf and it indeed gives the desired
format to barometer. However, my attempts to provide a format to
LakeElev has met with acute disaster. Here's a segment from my
weewx.conf with comments:

[[[[StringFormats]]]]

count = %d
foot = %.2f
inch2 = %.1f
inHg = %.2f
# LakeElev = %.2f #DOES NOTHING
# $current.LakeElev.format(format_string="%.2f")
#CRASHES STDREPORT THREAD
# current.LakeElev.format(format_string="%.2f")
#CRASHES ENGINE

As you can see I still don't know what I'm doing. Here's the contents
of my lakedata.py, which is working fine, but notice the #Note I wrote
to myself in it:

#!/usr/bin/env python

#file user/lakedata.py
import weewx
import weewx.units
from weewx.engine import StdService

class AddLakedata(StdService):

def __init__(self, engine, config_dict):
# Initialize my superclass first:
super(AddLakedata, self).__init__(engine, config_dict)
# Bind to any new archive record events:
self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_packet)

def new_archive_packet(self, event):

#(code that reads two measurements from a file)
with open("/home/pi/wxdata/weewxmbdata.dat") as f:
for line in f:
numbers_str = line.split()
numbers_float = [float(x) for x in numbers_str]
value1 = numbers_float[0]
value2 = numbers_float[1]

event.record['LakeElev'] = value1
# event.record['lakeWaveheight'] = value2

#
#Am I supposed to assign this to a units group? Which is best? What if I don't?



Okay something tells me there's a few things i'm leaving out in adding
this parameter. Like I said, back in the 3.9. days I modified some
file (units.py?) but was told that wasn't the best way to add my
lakedata parameters (which back then included LakeElevation and
WaveHeight).
I'd like to do this the preferred way.

Thanks again, so much - - -
Phil
> To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEAfhRDtxg7L3Dbhu_WtVPyhurobZqtNGJXqDzs%3Dr30YiQ%40mail.gmail.com.

Tom Keffer

unread,
Jul 16, 2023, 4:44:51 PM7/16/23
to weewx...@googlegroups.com
The answer is that you're confusing units (such as "inHg") with observation types (such as "LakeElev").

The [[[[StringFormats]]]] section uses units as keys, not observation types. If LakeElev is measured in meters, it will use whatever formatting has been specified for meters. 

I suspect that you have not specified which unit group LakeElev is in, so WeeWX is just printing out the raw, unformatted value. See the section Assigning a unit group for how to do this. Once it's a member of a unit group (say "group_altitude") it will use whatever unit that group is measured in (usually meters or feet) and follow the formatting conventions for that unit.

Or, maybe you have already done that and something else is wrong, in which case, come back and give us more details.

-tk

Messy Potamia

unread,
Jul 16, 2023, 5:00:54 PM7/16/23
to weewx...@googlegroups.com
Before I read your reply I edited units.py and added LakeElev to
group_altitude at the bottom of the ...Dicts whatever-that-is, gave it
some time, had a bourbon, and lo and behold it is now printing out
lake elevation as ""LakeElev 594.75 feet" instead of 594.750000
But I'm going to read your section Assigning a unit group to see what
I did wrong. Don't know how I missed that.
Thanks
Phil
> To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEDyYZMH8Nfe-thQL99r-g3WtkRFHvnQM9-TWtFkUuVogA%40mail.gmail.com.

Messy Potamia

unread,
Jul 16, 2023, 5:23:53 PM7/16/23
to weewx...@googlegroups.com
I followed that guidance, removed my hack to units.py, placed the
entries in user/lakedata.py, and it's great.
to wit:
LakeElev 594.74 ftMSL

Yeah.
Thank you again. This is probably what I should've done way back in
the 3.9 days.
Phil
image.png

Tom Keffer

unread,
Jul 16, 2023, 6:50:40 PM7/16/23
to weewx...@googlegroups.com
Glad it's working for you.

Single-malt Scotch works best for me.

michael.k...@gmx.at

unread,
Jul 17, 2023, 1:06:49 AM7/17/23
to weewx-user
Noted that. I might drop off one bottle, when I'm in Hood River next time. 
Reply all
Reply to author
Forward
0 new messages