diff --git a/docs/custom/cheetah.md b/docs/custom/cheetah.md index 7ea9146a..c51f48f5 100644 --- a/docs/custom/cheetah.md +++ b/docs/custom/cheetah.md @@ -233,7 +233,7 @@ _`obstype`_ is an observation type, such as `barometer`. This type must appear e _`optional_unit_conversion`_ is an optional unit conversion tag. If provided, the results will be converted into the specified units, otherwise the default units specified in the skin configuration file (in section `[Units][[Groups]]`) will be used. See the section _[Unit conversion options](#unit-conversion-options)_. -_`optional_rounding`_ allows the results to be rounded to a fixed number of decimal digits. See the section _[Optional rounding](#optional-rounding)_. +_`optional_rounding`_ allows the results to be rounded to a fixed number of decimal digits. See the section _[Optional rounding options](#optional-rounding-options)_. _`optional_formatting`_ is a set of optional formatting tags, which control how the value will appear. See the section _[Formatting options](#formatting-options)_ below. @@ -269,7 +269,7 @@ _`aggregation`_ is an _aggregation type_. If you ask for `$month.outTemp.avg` yo _`optional_unit_conversion`_ is an optional unit conversion tag. If provided, the results will be converted into the specified units, otherwise the default units specified in the skin configuration file (in section `[Units][[Groups]]`) will be used. See the section _[Unit conversion options](#unit-conversion-options)_. -_`optional_rounding`_ allows the results to be rounded to a fixed number of decimal digits. See the section _[Optional rounding](#optional-rounding)_ +_`optional_rounding`_ allows the results to be rounded to a fixed number of decimal digits. See the section _[Optional rounding options](#optional-rounding-options)_ _`optional_formatting`_ is a set of optional formatting tags, which control how the value will appear. See the section _[Formatting options](#formatting-options)_ below. @@ -388,9 +388,9 @@ The _`$optional_ago`_ parameters can be useful for statistics farther in the pas -## Unit conversion options +### Unit conversion options -The tag _`optional_unit_conversion`_ can be used with either current observations or aggregations. If supplied, the results will be converted to the specified units. For example, if you have set `group_pressure` to inches of mercury (`inHg`), then the tag +The option _`optional_unit_conversion`_ can be used with either current observations or with aggregations. If supplied, the results will be converted to the specified units. For example, if you have set `group_pressure` to inches of mercury (`inHg`), then the tag Today's average pressure=$day.barometer.avg @@ -428,30 +428,40 @@ or in degrees C: $day.barometer.min.degree_C or in foobar units: $day.barometer.min.foobar -### Optional rounding +### Option `round()` The data in the resultant tag can be optionally rounded to a fixed number of decimal digits. This is useful when emitting raw data or JSON strings. It should _not_ be used with formatted data (using a [format string](#format_string) would be a better choice). -The structure of the tag is +The structure of the option is .round(ndigits=None) where `ndigits` is the number of decimal digits to retain. If `None` (the default), then all digits will be retained. -## Formatting options +### Formatting options -A variety of tags and arguments are available to you to customize the formatting of the final observation value. This table lists the tags: +A variety of options are available to you to customize the formatting of the final observation value. They can be used whenever a tag results in a [`ValueHelper`](../appendix#ValueHelper), which is almost all the time. This table summarizes the options:
| Optional formatting tag | +Formatting option | Comment | |
| .format(args) | -Format the value as a string, according to a set of optional args (see below). | ++ Format the value as a string, according to a set of optional args + (see below). + | +|
| .long_form(args) | ++ Format delta times in the "long form", according to a set of optional + args (see below). + | ||
| .ordinal_compass | @@ -460,16 +470,6 @@ A variety of tags and arguments are available to you to customize the formatting configuration file skin.conf.|||
| .long_form | -- Format delta times in the "long form". A "delta time" is the difference between two times. An - example is the amount of uptime (difference between start and current time). By default, this will - be formatted as the number of elapsed seconds (e.g., 45000 seconds). The "long form" breaks the time down into constituent time - elements (e.g., 12 hours, 30 minutes, 0 seconds). - | -||
| .json | @@ -480,14 +480,17 @@ A variety of tags and arguments are available to you to customize the formatting | .raw | Return the value "as is", without being converted to a string and without any formatting applied. This can be useful for doing arithmetic directly within the templates. You must be prepared to deal - with a potential None value. + with a potential value of None. |
WeeWX has been up $station.uptime
+``` + +will result in + +WeeWX has been up $station.uptime.long_form
+``` + +results in + +| Optional argument | +Comment | +
| format_string | ++ Use the supplied string to format the value. + | +
| None_string | ++ Should the observation value be NONE, then use the supplied + string to format the value (typically, something like "N/A"). + | +
WeeWX has been up $station.uptime.long_form(format_string="%(day)d%(day_label)s, %(hour)d%(hour_label)s, %(minute)d%(minute_label)s")
+``` + + +#### Formatting examples This section gives a number of example tags, and their expected output. The following values are assumed: @@ -568,6 +651,11 @@ This section gives a number of example tags, and their expected output. The foll