Hi I would like to know if you can make your warming limits change dynamically. Basically I have a sensor that shows me the temperature of a room. I also have another temperature that is not the REAL temperature of the room, but rather a reference of what that room should be (real tmp is 10, but reference tmp says it should be 8 for example).

These both temperatures i get them from a database by inputing their address in the database, so both temperatures i can get them okay. Now my question. Can I make that the limits warning in the real temperature sensor be the reference temperature? So I would have in the sensor: the real tmp (eg. 10ºC) and the limits would be smth like (min tmp :reference tmp - 2 and max tmp: reference tmp + 2) .

My sensors are Modbus TCP, and I think if done, it has to be with some API or smth but I´m a bit lost. But yeah, I want to make the limits a dynamic value that I could get from a database. Thanks!


Article Comments

Hello Diego,

Thank you for your message.

Regarding what you would like to achieve, you indeed have to use the API of PRTG via a custom script as a scheduled task for example, which will get the reference temperature from the database (or from a sensor which has that value) and then execute the API calls to set the limits to the Modbus sensors.

In the current case, you need to use the following API calls:

  • Upper error limit
/api/setobjectproperty.htm?id=SENSORID&subtype=channel&subid=CHANNELID&name=limitmaxerror&value=VALUE&username=USERNAME&passhash=PASSHASH
  • Lower Error limit
/api/setobjectproperty.htm?id=SENSORID&subtype=channel&subid=CHANNELID&name=limitminerror&value=VALUE&username=USERNAME&passhash=PASSHASH

To get the value of an existing sensor, you can use the request below:

/api/table.json?content=channels&columns=objid,name,lastvalue&count=*&showhide=1&id=SENSORID&username=USERNAME&passhash=PASSHASH

If you have questions, do not hesitate.

Regards.


Feb, 2022 - Permalink

Hi, yes, it´s what I wanted to edit, and it works fine when calling that URL from the browser, now I´m trying to use cURL in php but i dont know why, its not working for me:

$cliente = curl_init();
curl_setopt($cliente, CURLOPT_URL, "https://xxxx/api/setobjectproperty.htm?id=2105&subtype=channel&subid=0&name=limitmaxerror&value=300&username=xxx&passhash=xxxx");
curl_setopt($cliente, CURLOPT_HEADER, 0);
curl_setopt($cliente, CURLOPT_RETURNTRANSFER, true); 

$contenido = curl_exec($cliente);
curl_close($cliente);

echo "$contenido";

The parameters are correct, I just used xxx for privacy purpouses, but in theory, this code should do it, it´s just the same that I use on my browser call, but it does nothing, it doesnt print me anything. What is happening?


Feb, 2022 - Permalink

Hi Diego,

Thank you for your feedback.

Unfortunately, I can provide limited support only here regarding the script.

Nevertheless, to understand where the issue might comes from, I invite you to check the HTTP headers, response code and payload returned by PRTG when executing your code.

To do so, I would recommend to modify the script to return those information as well as check the webserver logs of PRTG which are located under <data folder>\Logs\webserver where <data folder> is the path displayed in PRTG Administration Tool > PRTG Core server (on the PRTG server). The files CoreWebServer.log and WebServer.log might contain indication about the issue.

Maybe someone with some experience with Curl can also help here?


Feb, 2022 - Permalink