Solved: 8 push buttons should send 8 different HTTP REST API calls

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mikel
New user
Posts: 2
Joined: 29 Jan 2023, 10:38

Solved: 8 push buttons should send 8 different HTTP REST API calls

#1 Post by mikel » 29 Jan 2023, 11:08

Hi,

is this possible?

More detailed explanation:
I have 8 small buttons, these should directly control 8 devices.

Ex:
- Button 1 pressed should send http://ipaddress:8087/set/device.1?value=true
- Button 2 pressed should send http://ipaddress:8087/toggle/device.2

My steps:
- I flashed on an ESP32 mega-20221224_35f2ff8.
- Under Controllers I added a Generic HTTP device.
- Controller IP and Port filled out es needed.
- In Controler Publish i added %value%

- Under Devices I added 8 times Switch input - Switch
And now I hoped that under each Value of the Switch Device I enter the rest of the URl. So for example set/javascript.0.test?value=1 (and so on for each Button)
But that doesn't work, because no special characters like % / etc. are allowed.

I wonder, if this is possible?

Regards,
mike
Last edited by mikel on 29 Jan 2023, 19:35, edited 1 time in total.

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

Re: 8 push buttons should send 8 different HTTP REST API calls

#2 Post by TD-er » 29 Jan 2023, 12:43

For this you should use the rules.
In tools->Advanced page you can enable the rules (almost at the top)
After saving, you need to open some other tab to see the rules option appear at the top.

Then you can act on events sent by each switch task.
In this block you can define a command using sendToHttp.

Just to be sure, you're not trying to call the same ESPEasy node in these calls, right?

Let's assume you named your switch task Button1:

Code: Select all

on Button1#State=1 do
 sendToHttp,ipaddress,8087,/set/device.1?value=true
endon

mikel
New user
Posts: 2
Joined: 29 Jan 2023, 10:38

Re: 8 push buttons should send 8 different HTTP REST API calls

#3 Post by mikel » 29 Jan 2023, 19:32

Thanks a lot! This is working very well.

I had never worked with the "rules" before.
Powerful tool.
Everything works fine in my test environment.

Regards
Mike

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

Re: 8 push buttons should send 8 different HTTP REST API calls

#4 Post by TD-er » 29 Jan 2023, 19:34

See for more inspiration: https://espeasy.readthedocs.io/en/lates ... Rules.html
:)

Glad it is working.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests