http send command or rule

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ingoiot
Normal user
Posts: 83
Joined: 15 Aug 2019, 22:09

http send command or rule

#1 Post by ingoiot » 21 Aug 2019, 21:43

hi,

i tried to send a http command to a Smartplug to switch it on and off with an app.
http://192.168.178.33/control?cmd=GPIO,14,0 works to switch the relais,
but i also want to swicht a status led. can i send 2 commands in one request?

i already have a rule that switches both relais and led with a physical button. can i trigger it per http?

Code: Select all

on Button#state do
  if [Relais#state]=0
    gpio,14,1
    gpio,13,0
  else
    gpio,14,0
    gpio,13,1
  endif
endon
i tried http://192.168.178.33/control?cmd=event,%20Button=1
but it doesnt work. the esp receives the message but doesnt react.

Code: Select all

111809: HTTP: event, Button=1
111861: EVENT:  Button=1

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

Re: http send command or rule

#2 Post by ThomasB » 21 Aug 2019, 22:25

A typical solution would be like this:

Code: Select all

on Button#state do
  if [Relais#state]=0
    event,RelayOn
  else
    event,RelayOff
  endif
endon

On RelayOn do
  gpio,14,1
  gpio,13,0
endon

On RelayOff do
  gpio,14,0
  gpio,13,1
endon
The http command to turn on your Relay & LED would be:

Code: Select all

http://IP_ADDRESS/control?cmd=event,RelayOn
- Thomas

ingoiot
Normal user
Posts: 83
Joined: 15 Aug 2019, 22:09

Re: http send command or rule

#3 Post by ingoiot » 21 Aug 2019, 23:18

tnx,

seems to work.

strangely it looks like if i`m triggering the event through the app the esp react relatively fast,
through the webbrowser it seems to slow down the esp quite a bit.

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

Re: http send command or rule

#4 Post by TD-er » 22 Aug 2019, 10:41

What do you mean by "the app" ?

ingoiot
Normal user
Posts: 83
Joined: 15 Aug 2019, 22:09

Re: http send command or rule

#5 Post by ingoiot » 22 Aug 2019, 16:58

i`m using an app to send the http request HTTP Request Shortcuts

when i send the command with this app, it switches pretty quick,
if i use a browser it reacts pretty slow.
(maybe the browser keeps state and blocks up the esp? dont know)

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

Re: http send command or rule

#6 Post by grovkillen » 22 Aug 2019, 18:40

If you surf in to the unit the unit has to do a ton more compared to when you just send a simple http request.

PS. you're use of that app suggests to me that you have the unit exposed to the internet?
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:

ingoiot
Normal user
Posts: 83
Joined: 15 Aug 2019, 22:09

Re: http send command or rule

#7 Post by ingoiot » 22 Aug 2019, 18:53

grovkillen wrote: 22 Aug 2019, 18:40 PS. you're use of that app suggests to me that you have the unit exposed to the internet?
no, i dont think so.
at least it have only entered a local ip..

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

Re: http send command or rule

#8 Post by grovkillen » 22 Aug 2019, 19:46

Aha, so it's only working when at home or connected through VPN?
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:

ingoiot
Normal user
Posts: 83
Joined: 15 Aug 2019, 22:09

Re: http send command or rule

#9 Post by ingoiot » 22 Aug 2019, 19:56

yes, thats enough for me for the moment.

maybe i try to get the temperature via http - dont know if that would work.

ingoiot
Normal user
Posts: 83
Joined: 15 Aug 2019, 22:09

Re: http send command or rule

#10 Post by ingoiot » 22 Aug 2019, 22:28

not sure if this fits this thread or if i should open a new one..
but when i try to send the command through the esp peer network,
it does not work.

sending esp rule:

Code: Select all

On ds18b20#Temperature Do
 If [ds18b20#Temperature]>-15
 sendTo,1,RelayOn
EndOn
gives

Code: Select all

345820: Command: sendto
360794: DS   : Temperature: 17.50 (xx-2-0-x-9a-xx-1-zz)
360798: EVENT: ds18b20#Temperature=17.50
360814: ACT  : sendTo,1,RelayOn
360821: Command: sendto
receiving esp rule as above

Code: Select all

on Button#state do
  if [Relais#state]=0
    event,RelayOn
  else
    event,RelayOff
  endif
endon

On RelayOn do
  gpio,14,1
  gpio,13,0
endon

On RelayOff do
  gpio,14,0
  gpio,13,1
endon
log:

Code: Select all

340900: Command: relayon
340900: Command unknown: 'relayon'
355892: Command: relayon
355892: Command unknown: 'relayon'

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

Re: http send command or rule

#11 Post by grovkillen » 23 Aug 2019, 05:43

You forgot to use the command event.

Code: Select all

sendTo,1,Event,RelayOn
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:

ingoiot
Normal user
Posts: 83
Joined: 15 Aug 2019, 22:09

Re: http send command or rule

#12 Post by ingoiot » 23 Aug 2019, 16:15

tnx, now it works :)

Post Reply

Who is online

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