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

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
iz8mbw
Normal user
Posts: 35
Joined: 14 Apr 2023, 08:43
Location: Napoli, Italy

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

#1 Post by iz8mbw » 04 Sep 2023, 09:58

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.

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

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

#2 Post by TD-er » 04 Sep 2023, 10:15

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.

iz8mbw
Normal user
Posts: 35
Joined: 14 Apr 2023, 08:43
Location: Napoli, Italy

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

#3 Post by iz8mbw » 05 Sep 2023, 08:25

Thank you!
I'm using "SendToHTTP 192.168.1.20,80,/relay/0?turn=on" to send the HTTP GET.

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

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

#4 Post by TD-er » 05 Sep 2023, 08:37

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.

iz8mbw
Normal user
Posts: 35
Joined: 14 Apr 2023, 08:43
Location: Napoli, Italy

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

#5 Post by iz8mbw » 07 Sep 2023, 08:51

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests