Read the statement by Michael Teeuw here.
JSON request module
-
Good evening,
I couldn’t wait…it’s almost great, I just have to find how to align the text on the left and the temperatures on the right.
Thank you very much for your help
-
@ELMAGO
Do you mean something like this…
We first define a width for the most outer wrapper. I choose 200px but can adjust it to the value you want:
.MMM-ValuesByNotification .vbn .groupsWrapper{ width: 200px; }
Then we configure the next two deeper wrappers to expand to the maximum width:
.MMM-ValuesByNotification .vbn .groupWrapper, .MMM-ValuesByNotification .vbn .itemsWrapper { width: 100%; }
And we tell the itemWrapper to expand to maximum width and justify its content by putting space around the items equally:
.MMM-ValuesByNotification .vbn .itemWrapper { flex-direction: row; line-height: 1.0; width: 100%; justify-content: space-between; }
The rest stays the same as before:
.MMM-ValuesByNotification .vbn .itemTitle { margin-top: 0px; margin-bottom: 0px; min-width: 60px; text-decoration: unset; color: white; } .MMM-ValuesByNotification .vbn .groupWrapper { border-style: none; }
-
-
Hello
sorry to bother you again but is it possible to display an answer following the answer of the request.
example :
The JSON request returns false I would like to display “NON” -
@ELMAGO Sorry, but i do not understand exactly what you mean. You can override the “na” value which is the one displayed if no value could be parsed in the JSON.
The config option is:
naValue: "NON"
There might also be a chance to do add a
valueFormat
which checks for the “false” value in the JSON but that would be a little more complex and i need to know the exact format of the output. -
@wishmaster270
HelloNo, not al all.
the returned value will be “false” or “true” and I would like to replace it with “Non” or “Oui” in French. -
@ELMAGO
You can usevalueFormat
for this purpose.valueFormat: "\"${value}\".replace(\"false\",\"Non\").replace(\"true\",\"Oui\")",
This will convert the value to a string (if needed) and replaces all “false” with “Non” and “true” with “Oui”.
-
great, thank you.
Is there a “lexicon” with these commands? -
@ELMAGO
I added some to the [documentation] (https://github.com/Tom-Hirschberger/MMM-ValuesByNotification/blob/main/doc/value.md) of the module.
As there can be used any build-in JavaScript function invalueFormat
there are nearly endless possibilities. -
good evening,
I tested the replace function:
{ module: "MMM-ValuesByNotification", position: "top_right", header: "INFORMATION MÉGANE", config: { updateInterval: 300, reuseCount: 100, addClassesRecursive: true, valueFormat: "\"${value}\".replace(\"false\",\"Non\").replace(\"true\",\"Oui\")", groups: [ { items: [ { notification: "AUTBATTMEGANE", itemTitle: "Autonomie ", values: [ { valueUnit: " Km", valueFormat: "Number(${value}).toFixed(2)", jsonpath: "data", }, ] }, { notification: "BATTMEGANE", itemTitle: "Charge batterie ", values: [ { valueUnit: " %", valueFormat: "Number(${value}).toFixed(2)", jsonpath: "data", }, ] }, { notification: "PLUGMEGANE", itemTitle: "Voirture branchée ", classes: "withIcons", valueFormat: "\"${value}\".replace(\"false\",\"Non\").replace(\"true\",\"Oui\")", values: [ { valueFormat: "Number(${value}).toFixed(2)", jsonpath: "data", }, ] }, ] }, ] }, },
But unfortunately it doesn’t work.
Would you know why?
Thanks