How do I change the number of displayed decimal places?

180 views
Skip to first unread message

Wayne Rademacher

unread,
Mar 28, 2023, 9:48:22 PM3/28/23
to weewx-user
Hi,

I would like to know if there is a way to change the displayed decimal places of an observation.   I have searched the WeeWX setup and user guides, I have also stepped through my weewx.conf file but can't seem to find out how this is done.

I have attached a screen shot showing my current display.   I would like to trim off (4) digits from both Brightness and Battery.  I am new to this group so please let me know if I need to supply more or different information. 

windBatteryStatus = Battery
luminosity (luxXXX)  = Brightness

Here is my PWS configuration:
  • WeatherFlow Tempest
  • WeeWX Ver 4.10.2
  • Belchertown Skin Ver. 1.3
  • Pi4
Thanks,
Wayne
display.JPG

vince

unread,
Mar 29, 2023, 12:21:21 AM3/29/23
to weewx-user
You'd have to share how you made that Brightness and Battery stuff appear in the skin, was there an .inc file possibly ?

You might look at your skin.conf [[StringFormats]] section and add entries there for whatever units your Brightness and Battery are set to use and set the format there.

Karen K

unread,
Mar 29, 2023, 7:03:10 AM3/29/23
to weewx-user
@vince: That is the Belchertown skin. The area schown in the screenshot is configured in a single entry in skin.conf, listing the observation types to be displayed. There is no special configuration for decimal places available. So the general configuration of WeeWX applies.

Wayne Rademacher

unread,
Mar 29, 2023, 8:47:35 AM3/29/23
to weewx-user
To display the data, I simply added the observation title from my sensor map to the "station_observations" string in the weewx.conf file.

Since I was able to change the name of the observation (i.e. luminosity to Brightness) I was hoping the data could also be formatted.  I included snippets from my weewx.conf file that shows how I got the information to show up on the belchertown screen.

Regards,
Wayne 

station_observations = "barometer","dewpoint","outHumidity","rain", "luminosity", "UV", "cloud_cover", "windBatteryStatus"
[[sensor_map]]
        outTemp = air_temperature.ST-00105xxx.obs_st
        outHumidity = relative_humidity.ST-00105xxx.obs_st
        pressure = station_pressure.ST-00105xxx.obs_st
        lightning_strikes = lightning_strike_count.ST-00105xxx.obs_st
        avg_distance = lightning_strike_avg_distance.ST-00105xxx.obs_st
        outTempBatteryStatus = battery.ST-00105xxx.obs_st
        windSpeed = wind_speed.ST-00105xxx.rapid_wind
        windDir = wind_direction.ST-00105xxx.rapid_wind
        luminosity = illuminance.ST-00105xxx.obs_st
        UV = uv.ST-00105xxx.obs_st
        rain = rain_accumulated.ST-00105xxx.obs_st
        windBatteryStatus = battery.ST-00105xxx.obs_st
        radiation = solar_radiation.ST-00105xxx.obs_st
        lightningXXX = distance.ST-00105xxx.evt_strike
        lightningYYY = energy.ST-00105xxx.evt_strike
[[[Labels]]]
            # Users frequently change the labels for these observation types
            [[[[Generic]]]]
                  windBatteryStatus = Battery
                  luminosity    = Brightness
                # inHumidity     = Inside Humidity


vince

unread,
Mar 29, 2023, 1:14:53 PM3/29/23
to weewx-user
For this original question:
  • you're using luminosity and windBatteryStatus which are in the db schema
  • but I can't see how to determine what they map to by default
  • so I can't suggest which [[StringFormats]] edits to make in skin.conf
This is one where there might not be a simple example documented as far as I can tell.
  • how do you know which [Units] [[Groups]] category a db element is mapped to by default ?
  • how do you change which category a db element is mapped to ?
  • how can you (can you?) add a new units group if the default units don't have anything that matches your needs ?

an oldman

unread,
Mar 29, 2023, 2:08:09 PM3/29/23
to weewx-user
Hi
this is how i did it.
using WeeWX version: 4.10.1 Seasons version: 4.10.1 Python version: 3.10.10
in the user dir is a file extensions.py
i add
import weewx.units
weewx.units.obs_group_dict['windBatteryStatus'] = 'group_boolean'
weewx.units.obs_group_dict['luminosity'] = 'group_illuminance'
then restart weewx

hope this helps

Karen K

unread,
Mar 29, 2023, 2:52:23 PM3/29/23
to weewx-user
I guess `windBatteryStatus` is not a boolean value (i.e. true or false) but an integer or real value. So you may want to choose another observation group.

The decimal places are set in section [[[[StringFormats]]]] for the respective units (not observation groups).

Wayne Rademacher

unread,
Mar 29, 2023, 3:42:32 PM3/29/23
to weewx-user
It works!!!

Thanks everyone,
Wayne

Here are the required changes:
I added this to extensions.py as suggested by an oldman and Karen K
/usr/share/weewx/user extensions.py
import weewx.units
weewx.units.obs_group_dict['windBatteryStatus'] = ''group_volt'
weewx.units.obs_group_dict['luminosity'] = 'group_illuminance'


I changed the [[stringformats]] in the belchertown skin.conf to get the right amount of digits.
    [[StringFormats]]
        #volt                   = %.1f
        volt                    = %.2f

screen.PNG

vince

unread,
Mar 29, 2023, 4:03:45 PM3/29/23
to weewx-user
Wow - I never put the pieces together in my brain before.  Thanks for replying with what you did rather than just "solved".

Anybody willing to volunteer adding a brief wiki page for this one ?  It seems like a great example to use for mapping something to a particular units group, as well as editing the string format.

gjr80

unread,
Mar 29, 2023, 7:51:25 PM3/29/23
to weewx-user
Perhaps not in the exact words of this issue, but the Customising units and unit group section in the Customisation Guide covers pretty much everything in this thread.

Gary

Wayne Rademacher

unread,
Mar 29, 2023, 11:26:49 PM3/29/23
to weewx-user
I had previously looked through the customization guide but failed to realize the usefulness of the information.    After working through this practical exercise, I revisited the customization guide and a light bulb came on!    I now have a much better understanding of the weewx customization innerworkings.

Perhaps this exercise will help others that are struggling with system customization.

Wayne
Reply all
Reply to author
Forward
0 new messages