Page 1 of 1

Read temperature via web command on D1 with SHT30 installed

Posted: 19 Dec 2018, 22:46
by mattlward
I am running several D1's with the latest nightly build and SHT30's onboard. I need send an HTTP command that will read the temperature... How in the world do I do that?

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 19 Dec 2018, 23:45
by grovkillen
Please explain more.

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 20 Dec 2018, 05:08
by mattlward
I have placed a few of these in network closets for testing at work. The problem is, traditional network monitors do not use MQTT and ESP's do not use SNMP and I need to get the data from the devices. If I can ask the device a question via HTTP that responds with a simple numerical answer, I can directly import that value. I would likely ask the device every minute or so, but not likely an more frequently than that.

I had hoped to use the control?cmd/status for it, but it does not appear to provide more than a question mark for the answer. I could ask for /json, but that is very difficult to break down and out in a probe. Unless I can ask for a very specific variable with an extension to the json command.

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 20 Dec 2018, 06:09
by grovkillen
You can filter the JSON request but not down to a single value. I guess it could be useful. Please open a new feature request on GitHub.

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 20 Dec 2018, 10:37
by Domosapiens
How about this:
make an Event in Rules
Event contains a SendToHTTP with the temperature
Someting like (example to Domoticz):

Code: Select all

on testevent do
  SendToHTTP,x.x.x.x,8080,/json.htm?type=command&param=udevice&idx=385&nvalue=0&svalue=[SHT30#Temperature]
endon
Call that Event from outside

Code: Select all

http://x.x.x.x/control?cmd=event,testevent

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 20 Dec 2018, 17:46
by mattlward
I can't run software or remote commands on the system that does the monitoring. I really just need the ESP to generate a web page with the numerical temperature.

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 20 Dec 2018, 18:16
by grovkillen
mattlward wrote: 20 Dec 2018, 17:46 I can't run software or remote commands on the system that does the monitoring. I really just need the ESP to generate a web page with the numerical temperature.
Please, open a feature request on GitHub.

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 22 Dec 2018, 04:02
by ThomasB
I really just need the ESP to generate a web page with the numerical temperature.
FanOfHue is developing a plugin that might solve your problem.
See viewtopic.php?f=6&t=6098&p=33332

- Thomas

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 22 Dec 2018, 13:04
by Wiki
Just an idea how to solve your task instantly.

Assuming you have a webserver running on your monitoring system just place a small php-script named survey.php on it:

Code: Select all

<?php
isset($_GET['value']) ? $value=$_GET['value'] : $value='';
isset($_GET['ID']) ? $ID=$_GET['ID'] : $ID='';
$now = time();
$date = date("d.m.Y", $now);
$time = date("H:i:s", $now);
$page = "Temperature".$ID.".html";
$handle = fopen($page, 'w');
fwrite($handle,"<html>");
fwrite($handle,"<body>");
fwrite($handle,"<p>".$date."</p>");
fwrite($handle,"<p>".$time."</p>");
fwrite($handle,"<p>".$value."</p>");
fwrite($handle,"</body>");
fwrite($handle,"</html>");
fclose($handle);
?>
Define the webserver as Generic HTTP Controller in ESPEasy with Controller Publish "survey.php?value=%value%&ID=%unit%", enable the controller in device settings.

The php script will generate a neat small individual webpage containing date, time and value of each of your different devices named "TemperatureXY.html" (XY=unit no. of the device). On your monitoring system you're now able to call the individual pages using "http://localhost/TemperatureXY.html".

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 26 Dec 2018, 10:54
by iron
Do not forget the custom web pages.

Just upload an .htm file (http://ip_of_your_device/upload) that returns just the value you want and then call that file within your call url e.g. :

http://<ip of you device/return1.htm

-D

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 26 Dec 2018, 14:21
by Wiki
iron wrote: 26 Dec 2018, 10:54 Do not forget the custom web pages.

Just upload an .htm file (http://ip_of_your_device/upload) that returns just the value you want and then call that file within your call url e.g. :

http://<ip of you device/return1.htm

-D
Interesting. I didn't read about this possibility anything. Do you have some links for documentation?

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 26 Dec 2018, 15:32
by iron
Wiki wrote: 26 Dec 2018, 14:21
iron wrote: 26 Dec 2018, 10:54 Do not forget the custom web pages.

Just upload an .htm file (http://ip_of_your_device/upload) that returns just the value you want and then call that file within your call url e.g. :

http://<ip of you device/return1.htm

-D
Interesting. I didn't read about this possibility anything. Do you have some links for documentation?
https://www.letscontrolit.com/wiki/inde ... _Dashboard

but all you have to do is upload your own .htm file that posts the value you wish as a response. and then call that url. That's all.

If you extend your file as .esp the system will be doing some parsing as in the example in the link.
if you extend it as .htm there will be no parsing.

Whichever works the best for you.

-D

Re: Read temperature via web command on D1 with SHT30 installed

Posted: 26 Dec 2018, 18:56
by Wiki
Wow, that's cute.

Thank you for this information. I think this is exactly what mattlward was looking for - and at least, me, too.