Read the statement by Michael Teeuw here.
JSON request module
-
@ELMAGO You can NOT enter the url directly into the Command module. You need to call a valid Shell Command.
In your case I will suggestcurl
.The full command will be:
curl -vs http://192.168.100.244:3000/TEMPSALLE2
So the command configuration should be something like:
{ module: "MMM-CommandToNotification", disabled: false, config: { updateInterval: 10, commands: [ { script: "/usr/bin/curl", args: "-vs http://192.168.100.244:3000/TEMPSALLE2", timeout: 5, notifications: [ "TEMPSALLE", ], }, ] }, },
As a result the output of the curl command will be send as notification “TEMPSALE”.
You can test the curl command in a terminal.
-
@wishmaster270 said in JSON request module:
Good evening(I am in France)
Thanks for your answer but I still have the same result.
//TEMPERATURE MAISON { module: "MMM-CommandToNotification", disabled: false, config: { updateInterval: 10, commands: [ { script: "/usr/bin/curl", args: "-vs http://192.168.100.244:3000/TEMPSALLE", timeout: 5, notifications: [ "TEMPSALLE", ], }, ] }, }, // AFFICHAGE { module: "MMM-ValuesByNotification", position: "top_right", header: "TEMPERATURE MAISON", config: { groups: [ { items: [ { notification: "TEMPSALLE", itemTitle: "TEMPSALLE", values: [ { valueTitle: "TEMPSALLE", valueUnit: "C", jsonpath: "data", }, ] }, ] }, ] }, },
I have to miss something but I don’t see what
-
@ELMAGO Hi, no problem let’s dive deeper. Can you please run the curl command manually on the console and paste the result here, please.
-
There she is
-
@ELMAGO
Sorry, my fault.
Can you please remove thev
option of the curl command. It needs to becurl -s ...
. -
It’s same
//TEMPERATURE MAISON { module: "MMM-CommandToNotification", disabled: false, config: { updateInterval: 10, commands: [ { script: "/usr/bin/curl", args: "-s http://192.168.100.244:3000/TEMPSALLE", timeout: 5, notifications: [ "TEMPSALLE", ], }, ] }, }, // AFFICHAGE { module: "MMM-ValuesByNotification", position: "top_right", header: "TEMPERATURE MAISON", config: { groups: [ { items: [ { notification: "TEMPSALLE", itemTitle: "TEMPSALLE", values: [ { valueTitle: "TEMPSALLE", valueUnit: "C", jsonpath: "data", }, ] }, ] }, ] }, },
-
@ELMAGO
Sorry, took me a moment to set up a test environment…
I think if your webserver is not very very fast you need to increase the timeout value in the command module.
The timeout is in milliseconds and you configured5
. I guess it should be5000
.
This config works fine in my development environment.{ module: "MMM-CommandToNotification", disabled: false, config: { updateInterval: 60, commands: [ { script: "/usr/bin/curl", args: "-s http://192.168.100.244:3000/TEMPSALLE", timeout: 5000, notifications: [ "TEMPSALLE", ], }, ] }, }, { module: "MMM-ValuesByNotification", position: "top_right", header: "TEMPERATURE MAISON", config: { groups: [ { items: [ { notification: "TEMPSALLE", itemTitle: "TEMPSALLE", values: [ { valueTitle: "TEMPSALLE", valueUnit: "C", jsonpath: "data", }, ] }, ] }, ] }, },
Edit: I increased the
updateInterval
to60
-
@wishmaster270
You are phenomenal…but I still have three problems:
1 - When I look for several values, it only shows me the first one.
2- The Celsius symbol does not seem to be accepted3- 3- If I may abuse…is it possible to do the same formatting as this one. CSS and me…
Here is my code :
//TEMPERATURE MAISON { module: "MMM-CommandToNotification", disabled: false, config: { updateInterval: 60, commands: [ { script: "/usr/bin/curl", args: "-s http://192.168.100.244:3000/TEMPSALLE", timeout: 5000, notifications: [ "TEMPSALLE", ], }, ] }, }, { module: "MMM-CommandToNotification", disabled: false, config: { updateInterval: 60, commands: [ { script: "/usr/bin/curl", args: "-s http://192.168.100.244:3000/TEMPBUREAU", timeout: 5000, notifications: [ "TEMPBUREAU", ], }, ] }, }, // AFFICHAGE { module: "MMM-ValuesByNotification", position: "top_right", header: "TEMPERATURE MAISON", config: { groups: [ { items: [ { notification: "TEMPSALLE", values: [ { valueTitle: "SALLE A MANGER", valueUnit: "°C", jsonpath: "data", }, ] }, { notification: "TEMPBUREAU", values: [ { valueTitle: "BUREAU", valueUnit: "°C", jsonpath: "data", }, ] }, ] }, ] }, },
Once again thank you for everything.
-
@ELMAGO Step by Step closer to the goal😉
1: You can/need to use one instance of the command module to fetch the data of the to urls.
2: I use the Celsius sign in my setup without any problems but it may depend of the encoding of your operating system and Browser. You can try to use the html encoding°
instead.//TEMPERATURE MAISON { module: "MMM-CommandToNotification", disabled: false, config: { updateInterval: 60, commands: [ { script: "/usr/bin/curl", args: "-s http://192.168.100.244:3000/TEMPSALLE", timeout: 5000, notifications: [ "TEMPSALLE", ], }, { script: "/usr/bin/curl", args: "-s http://192.168.100.244:3000/TEMPBUREAU", timeout: 5000, notifications: [ "TEMPBUREAU", ], }, ] }, }, // AFFICHAGE { module: "MMM-ValuesByNotification", position: "top_right", header: "TEMPERATURE MAISON", config: { groups: [ { items: [ { notification: "TEMPSALLE", values: [ { valueTitle: "SALLE A MANGER", valueUnit: "°C", jsonpath: "data", }, ] }, { notification: "TEMPBUREAU", values: [ { valueTitle: "BUREAU", valueUnit: "°C", jsonpath: "data", }, ] }, ] }, ] }, },
3: I provided a lot examples with screenshots in the modules
doc
directory (screenshots). You will find the corresponding config and css of each screenshot in the configs. Maybe there is a styling included you like. If not feel free to ask again. -
This post is deleted!