know the status of esp, alive or not?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

know the status of esp, alive or not?

#1 Post by megamarco83 » 27 Oct 2018, 12:16

hi, is it possible to send and http command to nodemcu with espeasy to know if it's alive or not?
i would like to implement something that can respond as:

Code: Select all

{
"status": "ok",
"version": "3.403",
"request": {
"route": "/handshake"
},
"response": {
"homewizard": "yes",
"version": "3.403",
"firmwareupdateavailable": "no",
"appupdaterequired": "no",
"serial": "130103285"
}
}
nodemcu can react with something like this??
it would be better than to just send a ping
thanks :-)

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

Re: know the status of esp, alive or not?

#2 Post by grovkillen » 27 Oct 2018, 14:34

Using MQTT you get this feedback for free. But using HTTP you need to have the units push an answer (using rules) if an event is sent to it.
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
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: know the status of esp, alive or not?

#3 Post by dynamicdave » 27 Oct 2018, 14:37

I'm also interested,
Please enlighten me as to how you do it with MQTT.

Cheers from David

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

Re: know the status of esp, alive or not?

#4 Post by grovkillen » 27 Oct 2018, 14:45

If the LWT isn't published then the broker believes that the unit is still alive and kicking. To be even more sure about it's state you either use a heartbeat topic or have it respond on events.
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:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: know the status of esp, alive or not?

#5 Post by megamarco83 » 27 Oct 2018, 15:10

grovkillen wrote: 27 Oct 2018, 14:45 If the LWT isn't published then the broker believes that the unit is still alive and kicking. To be even more sure about it's state you either use a heartbeat topic or have it respond on events.
thanks for answer, could you please provide an example of rule and the mqtt string to ask if it's alive or not?
thanks

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: know the status of esp, alive or not?

#6 Post by megamarco83 » 28 Oct 2018, 22:49

any help on examples rule and request? :D
thanks

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

Re: know the status of esp, alive or not?

#7 Post by grovkillen » 28 Oct 2018, 23:21

I do this with MQTT import.

I have all my nodes subscribing to "cmdMQTT" and I send an integer (number) 1...4 to that topic and all will reply to that.

So in the rules I have this

Code: Select all

On cmdMQTT#Code=1 Do
  Publish,%sysname%/Time,%systime%
EndOn

On cmdMQTT#Code=2 Do
  Publish,%sysname%/IP,%ip%
EndOn

On cmdMQTT#Code=3 Do
  Publish,%sysnam%/Status,Reconnecting Wifi
  Wifidisconnect
  Wificonnect
EndOn

On cmdMQTT#Code=4 Do
  Publish,%sysname%/Status,Rebooting
  Reboot
EndOn
A heartbeat rule is explained here: https://www.letscontrolit.com/wiki/inde ... using_MQTT
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:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: know the status of esp, alive or not?

#8 Post by megamarco83 » 29 Oct 2018, 00:16

grovkillen wrote: 28 Oct 2018, 23:21 I do this with MQTT import.

I have all my nodes subscribing to "cmdMQTT" and I send an integer (number) 1...4 to that topic and all will reply to that.

So in the rules I have this

Code: Select all

On cmdMQTT#Code=1 Do
  Publish,%sysname%/Time,%systime%
EndOn

On cmdMQTT#Code=2 Do
  Publish,%sysname%/IP,%ip%
EndOn

On cmdMQTT#Code=3 Do
  Publish,%sysnam%/Status,Reconnecting Wifi
  Wifidisconnect
  Wificonnect
EndOn

On cmdMQTT#Code=4 Do
  Publish,%sysname%/Status,Rebooting
  Reboot
EndOn
A heartbeat rule is explained here: https://www.letscontrolit.com/wiki/inde ... using_MQTT
thaks so much!
and the code MQTT that you send to have an interrogation from code 1..4 how is made?
could be:

Code: Select all

mosquitto_pub -h localhost -m '{ "code" : 1 }' -t 'cmdMQTT/in'

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

Re: know the status of esp, alive or not?

#9 Post by grovkillen » 29 Oct 2018, 06:23

I use MQTT Snooper for easier tests of MQTT communication. But you need to send the message as plain value.

Code: Select all

mosquitto_pub -h localhost -m '1' -t 'cmdMQTT'
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:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: know the status of esp, alive or not?

#10 Post by megamarco83 » 29 Oct 2018, 08:57

grovkillen wrote: 29 Oct 2018, 06:23 I use MQTT Snooper for easier tests of MQTT communication. But you need to send the message as plain value.

Code: Select all

mosquitto_pub -h localhost -m '1' -t 'cmdMQTT'
sorry...i'm a little bit lost
i create a device "generic MQTT like this:
device_9.png
device_9.png (36.72 KiB) Viewed 7523 times
then i create the rules:

Code: Select all

On cmdMQTT#Code=1 Do
  Publish,%sysname%/Time,%systime%
EndOn

On cmdMQTT#Code=2 Do
  Publish,%sysname%/IP,%ip%
EndOn
i download the android app mqtt snooper
i create the host of raspberry (where i have installed my mqtt broker)
now if i go inside the "in" and paste the code

Code: Select all

mosquitto_pub -h localhost -m '1' -t 'cmdMQTT'
i do not receive nothing...
is it correct?

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

Re: know the status of esp, alive or not?

#11 Post by grovkillen » 29 Oct 2018, 10:06

MQTT topic 1 should be cmdMQTT since that is the topic your sending to
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:

megamarco83
Normal user
Posts: 230
Joined: 13 Apr 2017, 23:09

Re: know the status of esp, alive or not?

#12 Post by megamarco83 » 29 Oct 2018, 10:23

ok thanks now understand!
i try the command and now i see that the variable is setted to 1 after send the mqtt string
now on my rules have:

Code: Select all

On cmdMQTT#Code=1 Do
  Publish,%sysname%/Time,%systime%
EndOn
so where i should see the responde of sysname?

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

Re: know the status of esp, alive or not?

#13 Post by grovkillen » 29 Oct 2018, 11:39

You see it if you listen to that topic on the other unit (may it be a server or whatever).
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:

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: know the status of esp, alive or not?

#14 Post by riker1 » 03 Mar 2019, 11:53

Hi

I trried this

but subscription is not working I think

please show your setting in :
controller subscription here:

thanks T

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

Re: know the status of esp, alive or not?

#15 Post by grovkillen » 03 Mar 2019, 12:27

MQTT import is it's own MQTT client so the topic(s) you type in the settings are the complete topic it will listen to.
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:

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: know the status of esp, alive or not?

#16 Post by riker1 » 03 Mar 2019, 12:47

ok thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 42 guests