Problem with SendToHTTP

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
HermannDerUser
New user
Posts: 8
Joined: 20 Feb 2019, 10:05

Problem with SendToHTTP

#1 Post by HermannDerUser » 20 Feb 2019, 10:28

Hello together,
I'm new with the ESPeasy and have a problem with the SendToHTTP command. At the moment I use 'ESP_Easy_mega-20190212_normal_ESP8266_1024' on a Sonoff basic. In the rules tab I create a rule like this:

Code: Select all

on Intern#Taster do
 if [Intern#Taster]=3                             // bei Doppelklick
    SendToHTTP 192.168.69.202,80,/?relais=2
    Pulse,13,0,100                                // 3x kurz blinken
    Pulse,13,1,100
    Pulse,13,0,100
    Pulse,13,1,100
    Pulse,13,0,100
    Pulse,13,1,100                             
    endif
endon
and its work well. But if I change the SentToHTTP command to

Code: Select all

SendToHTTP 192.168.69.15,80,/api/device/fsb/buttonPressed?buttonId=fs
nothing happens. The command push a button over the API from pimatic. If I enter the command

Code: Select all

http://192.168.69.15:80/api/device/fsb/buttonPressed?buttonId=fs
in the address line of my browser, it works well.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Problem with SendToHTTP

#2 Post by grovkillen » 20 Feb 2019, 11:56

What does the log state when your rule is executed?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

HermannDerUser
New user
Posts: 8
Joined: 20 Feb 2019, 10:05

Re: Problem with SendToHTTP

#3 Post by HermannDerUser » 20 Feb 2019, 13:30

Here the log with loglevel "debug":

Code: Select all

15039519: EVENT: Clock#Time=Wed,13:24
15039549: EVENT: Clock#Time=Wed,13:24 Processing time:30 milliSeconds
15044532: SendToHTTP 192.168.69.15,80,/api/device/fsb/buttonPressed?buttonId=fs
15044532: SendToHTTP: Host: 192.168.69.15 port: 80
15044533: SendToHTTP: Path: /api/device/fsb/buttonPressed?buttonId=fs
15044548: GET /api/device/fsb/buttonPressed?buttonId=fs HTTP/1.1^^Host: 192.168.69.15^^User-Agent: ESP Easy/20103/Feb 12 2019 03:11:27^^C
15044549: GET /api/device/fsb/buttonPressed?buttonId=fs HTTP/1.1^^Host: 192.168.69.15^^User-Agent: ESP Easy/20103/Feb 12 2019 03:11:27^^C
15044551: HTTP : Command_HTTP_SendToHTTP written to client (147/147)
15044551: HTTP : Command_HTTP_SendToHTTP closing connection
15044591: Lev.2: [if 1=1]=true
15044593: ACT  : Pulse,13,1,100
15044697: SW   : GPIO 13 Pulsed for 100 mS
15044702: ACT  : Pulse,13,0,100
15044805: SW   : GPIO 13 Pulsed for 100 mS
15044809: ACT  : Pulse,13,1,100
15044912: SW   : GPIO 13 Pulsed for 100 mS
15044959: ACT  : Pulse,13,0,100
15045063: SW   : GPIO 13 Pulsed for 100 mS
15045067: ACT  : Pulse,13,1,100
15045170: SW   : GPIO 13 Pulsed for 100 mS
15045174: ACT  : Pulse,13,0,100
15045277: SW   : GPIO 13 Pulsed for 100 mS
15045281: Lev.2: [else]=false
15045331: Lev.1: [if 3=11]=false
15045375: EVENT: Intern#Taster=3.00 Processing time:893 milliSeconds
15045379: SW  : GPIO=13 State=1 Output value=1
15045387: EVENT: LED#LED=1.00
15045420: EVENT: LED#LED=1.00 Processing time:33 milliSeconds
When I type the command into the tools->command field I get: ok; but nothing happens too

User avatar
iron
Normal user
Posts: 221
Joined: 24 Sep 2016, 08:37
Location: Greece
Contact:

Re: Problem with SendToHTTP

#4 Post by iron » 20 Feb 2019, 14:37

SendToHTTP,url.com,80,/xyz is the syntax

you have space instead of coma after SendToHTTP

-D
-D

HermannDerUser
New user
Posts: 8
Joined: 20 Feb 2019, 10:05

Re: Problem with SendToHTTP

#5 Post by HermannDerUser » 20 Feb 2019, 14:51

Now I try with comma, but that doesn't work either. On the other hand, the command

Code: Select all

SendToHTTP 192.168.69.202,80,/?relais=2
works with the space perfect. :?:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Problem with SendToHTTP

#6 Post by grovkillen » 20 Feb 2019, 15:16

Regarding spaces, we allowed them before but not officially anymore.

BUT most likely only the first space will work in future builds.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

HermannDerUser
New user
Posts: 8
Joined: 20 Feb 2019, 10:05

Re: Problem with SendToHTTP

#7 Post by HermannDerUser » 20 Feb 2019, 15:32

Okay, I switched from space to comma, but...
...it's still not working.

Does anyone have any idea why this command doesn't work?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Problem with SendToHTTP

#8 Post by grovkillen » 20 Feb 2019, 17:27

Use something like "wireshark" or "fiddle" to see what headers is being sent by the ESP Easy unit. Your receiving end might want something that the ESP isn't sending?

What is on the receiving end?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

HermannDerUser
New user
Posts: 8
Joined: 20 Feb 2019, 10:05

Re: Problem with SendToHTTP

#9 Post by HermannDerUser » 20 Feb 2019, 18:56

hi,

I just tried to execute the command via the browser on another computer. I noticed that a user/password query is prompted. Is it possible to specify a user/password for the SentToHTTP command.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Problem with SendToHTTP

#10 Post by grovkillen » 20 Feb 2019, 19:07

Topically you do it like this:

http://USERNAME:PASSWORD@domain.com...
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

HermannDerUser
New user
Posts: 8
Joined: 20 Feb 2019, 10:05

Re: Problem with SendToHTTP

#11 Post by HermannDerUser » 20 Feb 2019, 19:22

I adjusted my rule. In the log file I now find the following entries:

Code: Select all

1695435: SendToHTTP user:Password@192.168.69.15,80,/api/device/fsb/buttonPressed?buttonId=fs
1695436: SendToHTTP: Host: user:password@192.168.69.15 port: 80
1695436: SendToHTTP: Path: /api/device/fsb/buttonPressed?buttonId=fs
My password is case-sensitive but in the HTTP request everything is lower case.
How can I change that?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Problem with SendToHTTP

#12 Post by grovkillen » 20 Feb 2019, 19:26

That is probably not possible right now (all commands are set to lower case). You need to open a feature request for that... Sorry.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Problem with SendToHTTP

#13 Post by grovkillen » 20 Feb 2019, 19:30

As suggested by TD-er (on slack):

"user:pAsSwRd@host:port"

So, that is double quotes on each side...
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

HermannDerUser
New user
Posts: 8
Joined: 20 Feb 2019, 10:05

Re: Problem with SendToHTTP

#14 Post by HermannDerUser » 20 Feb 2019, 19:45

Thank you very much for the prompt reply, but it doesn't work. I tried

Code: Select all

SendToHTTP "user:Password@192.168.69.15",80,/api/device/fsb/buttonPressed?buttonId=fs

Code: Select all

SendToHTTP "user:Password@192.168.69.15,80",/api/device/fsb/buttonPressed?buttonId=fs

Code: Select all

SendToHTTP 'user:Password@192.168.69.15',80,/api/device/fsb/buttonPressed?buttonId=fs

Code: Select all

SendToHTTP 'user:Password@192.168.69.15,80',/api/device/fsb/buttonPressed?buttonId=fs
but the log said for the first example:

Code: Select all

3391935: SendToHTTP 'user:Password@192.168.69.15',80,/api/device/fsb/buttonPressed?buttonId=fs
3391936: SendToHTTP: Host: user:password@192.168.69.15 port: 80
3391937: SendToHTTP: Path: /api/device/fsb/buttonPressed?buttonId=fs

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

Re: Problem with SendToHTTP

#15 Post by TD-er » 20 Feb 2019, 19:54

I guess it is a bug then.
The parsing of the rules is a bit too complicated every now and then.
Comparing commands is done case-insensitive, but the parameters should be sent case sensitive.
Or else strings sent to a display for example can not have a mix of lower and upper case letters.

HermannDerUser
New user
Posts: 8
Joined: 20 Feb 2019, 10:05

Re: Problem with SendToHTTP

#16 Post by HermannDerUser » 20 Feb 2019, 20:09

Thanks for the help, then I will temporarily change my password for testing.

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Problem with SendToHTTP

#17 Post by gregoinc » 09 May 2020, 14:16

HermannDerUser wrote: 20 Feb 2019, 19:45 Thank you very much for the prompt reply, but it doesn't work. I tried

Code: Select all

SendToHTTP "user:Password@192.168.69.15",80,/api/device/fsb/buttonPressed?buttonId=fs

Code: Select all

SendToHTTP "user:Password@192.168.69.15,80",/api/device/fsb/buttonPressed?buttonId=fs

Code: Select all

SendToHTTP 'user:Password@192.168.69.15',80,/api/device/fsb/buttonPressed?buttonId=fs

Code: Select all

SendToHTTP 'user:Password@192.168.69.15,80',/api/device/fsb/buttonPressed?buttonId=fs
but the log said for the first example:

Code: Select all

3391935: SendToHTTP 'user:Password@192.168.69.15',80,/api/device/fsb/buttonPressed?buttonId=fs
3391936: SendToHTTP: Host: user:password@192.168.69.15 port: 80
3391937: SendToHTTP: Path: /api/device/fsb/buttonPressed?buttonId=fs
I am having the same problem as the OP, trying to use the SendToHTTP command to login and send a string. Did this issue ever get resolved, or are there other syntax examples I could follow? Appreciate the help.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Problem with SendToHTTP

#18 Post by grovkillen » 09 May 2020, 15:01

I guess it depends on the host, if nothing is passed in the header and the host expects the authorization to be in there (not only in the URL) I guess the host will deny access.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Problem with SendToHTTP

#19 Post by gregoinc » 10 May 2020, 02:29

grovkillen wrote: 09 May 2020, 15:01 I guess it depends on the host, if nothing is passed in the header and the host expects the authorization to be in there (not only in the URL) I guess the host will deny access.
This is the syntax of the HTTP command directly from the user manual: http://admin:12345678@192.168.0.50/Set. ... ower+P60=1

The command above works fine when entered into a browser, so I am seeking to translate the command into the ESPEasy rules to send the HTTP command under particular conditions.

Like the OP I've tried numerous combinations of the commands entered by the OP without success. Interestingly I tried using a Generic HTTP controller, which achieved partial success, but presented other types of issues. But using the HTTP controller partially proved the HTTP command was being sent and received.

Any advice greatly appreciated. Thanks, Mark

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Problem with SendToHTTP

#20 Post by gregoinc » 13 May 2020, 01:49

Any further ideas on above appreciated :D

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Problem with SendToHTTP

#21 Post by ThomasB » 13 May 2020, 05:26

Any further ideas on above appreciated
The OP's SendToHTTP statement did not work because the rules parser coverts the statement to lower case letters. That caused the OP's mixed-case password credentials to fail.

I see that your example HTTP URL has some uppercase in it:

Code: Select all

http://admin:12345678@192.168.0.50/Set.cmd?CMD=SetPower+P60=1
Looking at the OP's logs, it seems only the host info (credentials with IP address) is affected by the parser. Fortunately the Path remains unchanged. So if your web credentials have uppercase then you should change them to all lower case. That should get you going.

- Thomas

gregoinc
Normal user
Posts: 65
Joined: 21 Jan 2019, 06:08
Location: Australia

Re: Problem with SendToHTTP

#22 Post by gregoinc » 13 May 2020, 08:43

ThomasB wrote: 13 May 2020, 05:26
Any further ideas on above appreciated
The OP's SendToHTTP statement did not work because the rules parser coverts the statement to lower case letters. That caused the OP's mixed-case password credentials to fail.

I see that your example HTTP URL has some uppercase in it:

Code: Select all

http://admin:12345678@192.168.0.50/Set.cmd?CMD=SetPower+P60=1
Looking at the OP's logs, it seems only the host info (credentials with IP address) is affected by the parser. Fortunately the Path remains unchanged. So if your web credentials have uppercase then you should change them to all lower case. That should get you going.

- Thomas
Hi Thomas,

Thank you. After reading the posts in this thread I checked and the login name: admin is lower case, and the password I am using is lower case with a few numbers. Only part of the web string which has upper case is

Code: Select all

Set.cmd?CMD=SetPower+P60=1
which is part of the inbuilt commands of the power switching unit and I doubt I can change it? So I might be stuck :(

Thanks, Grego

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Problem with SendToHTTP

#23 Post by ThomasB » 13 May 2020, 18:15

I checked and the login name: admin is lower case, and the password I am using is lower case with a few numbers. Only part of the web string which has upper case is ...[the path]
If you review the logs from the OP, his path string remained unchanged. So that optimistically suggests you might be able to make it work. To determine if this is happening I suggest you review your ESPEasy log output to see what is being sent via SendToHTTP. This will allow you to confirm if the path string is not being altered.

Regardless of what you find, this unwanted case conversion bug deserves to be fixed. You or the OP need to create a issue ticket in ESPEasy's Github.

- Thomas

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests