Page 1 of 1

Send HTTP commands on remote (external) host when GPIO state changes

Posted: 04 Sep 2023, 09:58
by iz8mbw
Hello.
Is it possible to tell to ESPEasy to run a HTTP command (GET) on a GPIO state changes?
As example, send this HTTP GET "http://192.168.1.20/relay/0?turn=on" when GPIO 18 is High.

Thanks.

Re: Send HTTP commands on remote (external) host when GPIO state changes

Posted: 04 Sep 2023, 10:15
by TD-er
Yep, see "monitor": https://espeasy.readthedocs.io/en/lates ... o-commands

Make sure not to monitor pins that change very often as you may end up with a completely blocked ESPEasy unit.
The SendToHTTP call may take some time.

Another approach is to add a 'switch' task and configure debounce time on it.
This will then perform some basic filtering for you and generate an event on which you can act in the rules.

Re: Send HTTP commands on remote (external) host when GPIO state changes

Posted: 05 Sep 2023, 08:25
by iz8mbw
Thank you!
I'm using "SendToHTTP 192.168.1.20,80,/relay/0?turn=on" to send the HTTP GET.

Re: Send HTTP commands on remote (external) host when GPIO state changes

Posted: 05 Sep 2023, 08:37
by TD-er
It is just that any call to an external host may be blocking until that host replied.
So by definition such calls should not be called too often or else the ESP will become rather unresponsive.

Depending on a lot of factors, but as a rule of thumb, you should not call those more frequent than a few times a second.

So that's why I suggested to perhaps use the Switch plugin as it may offer some settings to perform filtering.

Re: Send HTTP commands on remote (external) host when GPIO state changes

Posted: 07 Sep 2023, 08:51
by iz8mbw
Thanks!