SendToHTTP to its own environment does not work

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

SendToHTTP to its own environment does not work

#1 Post by joost d » 26 Sep 2022, 10:47

It looks like that the SendToHTTP -in Rules- does not work for hiss own ESPeasy-environment .

To test this isseu, I used the commands:

SendToHTTP 192.168.2.10,80,/control?cmd=pcd8544cmd,backlight,1
SendToHTTP 192.168.2.10,80,/control?cmd=GPIO,12,1

192.168.2.10 is the ip of the environment of the Rules.

Result in the log is:
1075861: ACT : SendToHTTP 192.168.2.10,80,/control?cmd=pcd8544cmd,backlight,1
1080868: HTTP : SendToHTTP 192.168.2.10 GET... failed HTTP code: -1 connection refused
1080872: ACT : SendToHTTP 192.168.2.10,80,/control?cmd=GPIO,12,1
1085879: HTTP : SendToHTTP 192.168.2.10 GET... failed HTTP code: -1 connection refused

If i use the ip of another ESPeasy then the SendToHTTP command works correct and the result in the log is :

902971: ACT : SendToHTTP 192.168.2.7,80,/control?cmd=pcd8544cmd,backlight,1
903016: HTTP : SendToHTTP 192.168.2.7 GET... HTTP code: 200
903026: ACT : SendToHTTP 192.168.2.7,80,/control?cmd=GPIO,12,1
903080: HTTP : SendToHTTP 192.168.2.7 GET... HTTP code: 200
903092: EVENT: http#192.168.2.7=200
903106: EVENT: http#192.168.2.7=200

A bug......?!

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SendToHTTP to its own environment does not work

#2 Post by TD-er » 26 Sep 2022, 11:04

Not sure if this can be considered a bug...
Problem is, we're running this all single threaded.
So when handling a call to a SendToHTTP command, we're not handling the actual request via the web server and vice verse.

Also I don't really see the purpose for this as these commands can all be run from within the rules anyway, so why add such a rather extreme overhead?

The only thing I can think of how this might be working is when the sendtohttp command is made aware of whether it is calling itself. But that's probably a lot of work to then hook into the webserver and fetching the result etc.
And what to do with other commands like sendto which is used to send data to other nodes via the p2p layer?

So in short, no I don't think this should be considered a bug.

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: SendToHTTP to its own environment does not work

#3 Post by joost d » 26 Sep 2022, 11:46

"Also I don't really see the purpose for this as these commands can all be run from within the rules anyway, so why add such a rather extreme overhead?""

Well, I tried to find a way to change a plugin-setting-value (P141, backlight) to switch te backlight automatically on/off. The only way i found, is to do this by the SendToHTTP command.....

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SendToHTTP to its own environment does not work

#4 Post by Ath » 26 Sep 2022, 11:49

The pcd8544cmd,backlight,<value> command can be used directly from the rules, without the http... prefix. I already wrote that in my email... ;)
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SendToHTTP to its own environment does not work

#5 Post by TD-er » 26 Sep 2022, 11:52

Both of these below call the same command:

Code: Select all

SendToHTTP 192.168.2.7,80,/control?cmd=pcd8544cmd,backlight,1
pcd8544cmd,backlight,1
However, the SendToHTTP version does allow to call the command on another unit.

The actual command is then included in an URL right after the "?cmd=" part.

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: SendToHTTP to its own environment does not work

#6 Post by Ath » 26 Sep 2022, 11:54

Similar to this?

Code: Select all

on APDS9960#Light do
  if %eventvalue1%>100
    pcd8544cmd,backlight,0 // Backlight off
  else
    pcd8544cmd,backlight,30 // Backlight on
  endif
endon
/Ton (PayPal.me)

joost d
Normal user
Posts: 53
Joined: 24 Dec 2020, 17:55
Location: Netherlands/ Haarlem

Re: SendToHTTP to its own environment does not work

#7 Post by joost d » 26 Sep 2022, 12:23

Great.
I misunderstand your(Ath) advise by mail. I thought that with " http prefix" the start of the URL was meant.
Now I'm using pcd8544cmd,backlight,0. Thats works great :-)

Thanks

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 39 guests