| Option | Description | Type | Default |
|---|---|---|---|
| valueUnit | Specify the unit of the value here. | String | null |
| naValue | Specify a value that will be displayed if the notification has not been received or the information is to old. | String | "na" |
| valueTitle | Specify a string or a array of strings containing title(s) which will be added as element(s) to the value element. | String or Array of String | null |
| valueIcon | Specify one or more icon(s) you want to add to the value elment either as String (which contains the Fontawesome 4.7 or Iconify classes of the single icon) or a array of strings which do contain the classes. Look at in the section Icons for more information. | String or array of Strings | null |
| valueImgIcon | Specify one or more images that should be displayed as icon(s) instead of Fontawesome 4.7 or Iconify icon(s). This value needs to be either a string which contains the path to the icon or an array of strings containing the paths in each element. | String or array of Strings | null |
| valueFormat | Specify a pice of javascript code to re-format the value before displaying it. ${value} contains the value (i.e. "Number(${value}).toFixed(2)" will shorten a float value like 10.1234 to 10.12). | String | null |
| formatNaValue | Should the naValue be formatted as like it would be a regular value? | Boolean | false |
| jsonpath | Specify a jsonpath-plus path to select a value if your notification contains a json object. | String | null |
| newlineReplacement | Newline characters like \r and \n will be replaced with this string after a possible json is parsed but before the value gets formatted. Newlinepreplacement will only happen if valueFormat is set. If you want to use newlineReplacement but do not want to format the value use ${value} as valueFormat! |
String | " " |
| valueTransformers | Specify a array of functions that should be called before the valueFormat to transform the value in a more complex way (i.e. transform degrees to a point of the compass). The functions need to be specified in the configuration option transformerFunctions of the main configuration. |
Array of Strings | null |
| valuePositions | Specify in which order the elements should be added to the value element. t=title(s), i=icon(s), v=value, u=unit, d=dummy (empty element to act as placeholder), [] to create a sub wrapper. Look to Positions section to get more information. | String | "ti[vu]" |
| valueNaPositions | Specify in which order the elements should be added to the value element if naValue is used. t=title(s), i=icon(s), v=value, u=unit, d=dummy (empty element to act as placeholder), [] to create a sub wrapper. Look to Positions section to get more information. |
String | value of valuePositions
|
| unitSpace | If you want to have a small space added before the unit (between value and unit usually) and do not want to solve it with CSS you can set this option to true. |
Boolean | false |
| classes | Specify css classes here that will be configured to each element of the value element. The classes need to be specified space separated in a string. | String | null |
| thresholds | Specify a array of thresholds which can be used to add classes or manipulate the icons. Look to the Thresholds section to get more information. | Array | null |
| profiles | Specify a space separated list of profiles if you like this value element only to be displayed if a certain profile is active currently. | Stirng | null |
| automaticWrapperClassPrefix | If a wrapper is specified in the valuePositions option this class will be added to every wrapper. Additionally a class starting with this prefix and a number starting with 0 will be added. | String | null |
The options "valueUnit", "naValue", "valueTitle", "valueIcon", "valueImgIcon", "valueFormat", "unitSpace", "formatNaValue", "jsonpath", "newlineReplacement", "valuePositions", "thresholds" and "automaticWrapperClassPrefix" can be configured within the items or groups or general configuration as well. If multiple options are configured the deepest hirarchical option overrides the other ones. If for example a "naValue" is configured directly in the "config" section but there is one configured in the current item and current value the configured in the value will be used. In the following example "Value-1" will use the "naValue" "n3" while "Value-2" uses "n2". Both values use "valueUnit" "abc".
{
module: "MMM-ValuesByNotification",
position: "top_left",
header: "Module-1",
config: {
naValue: "n1",
valueUnit: "abc",
transformerFunctions: {
degToCompass: (num) => {
val = ((num/22.5)+.5) | 0;
arr = ["N","NNE","NE","ENE","E","ESE", "SE", "SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"];
res = arr[(val % 16)];
return res;
},
blaBlub: (value) => {
return "<p>foo</p><div>"+value+"</div><p>bar</p>"
}
},
groups: [
{
naValue: "n2",
items: [
{
notification: "TEST1",
itemTitle: "Item-1",
values: [
{
naValue: "n3"
valueTitle: "Value-1",
},
{
valueTitle: "Value-2",
},
{
valueTitle: "Value-3",
valueTransformers: ["degToCompass", "blaBlub"]
},
]
},
]
},
]
},
},As of version 0.0.10 of the module i suggest to use the transformer functions instead of valueFormat. But both will work!
Remeber that ${value} contains the actual value!
valueFormat: "Number(${value}).toFixed(2)"will lead to a float that is fixed to two fractions.
If the value of your notification looks something like:
Temp: 12.0
valueFormat: "\"${value}\".substring(6)"will remove the starting "Temp: ".
Lets say you get notifications with the following content:
dummy1
dummy2
value=12
dummy3
Cause newlines will be replaced with " " in default (see "newlineReplacement" option) the string will be converted to:
dummy1 dummy2 value=12 dummy3
We want to get the "12" behind the "value=" and we want to add numerically a 1 to it:
valueFormat: "Number(\"${value}\".replace(/.*value=(.*?) .*/g,\"$1\")) + 1",The result value will be:
13
As of version 0.0.10 of the module you can use the transformer functions feature to write your own javascript functions to transform the values.
In the example above the two tranformer functions degToCompass and blaBlub are defined a and the third value makes use of them cause valueTransformers is configured to ["degToCompass", "blaBlub"].
If i.e. a value of 20.0 will be processed by these functions the result will be:
<p>foo</p>
<div>NNE</div
><p>bar</p>If valueTransformers only had contained ["degToCompass"] the output would be a simple NNE.
In my case i get temperature and humidity information of my sensors via MQTT. The information is provided as JSON object with a structure like this:
{
"temperature": 20.15,
"humidity": 62.52
}The jsonpath to select the temperature is:
jsonpath="temperture",The jsonpath to select the humidity is:
jsonpath="humidity",That was easy!