How can I reboot ESPEasy using MQTT?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

How can I reboot ESPEasy using MQTT?

#1 Post by sheppy » 19 Jan 2018, 00:25

I have several ESP8266's running ESPEasy Build 132 and Build 147. I would like to reboot them using MQTT.

If I have a device subscribed to topic "MyDevice" with an ip of "192.168.123.123"

I can send "curl 192.168.123.123/?cmd=reboot" and it reboots

How can I get this to work with MQTT. I have tried

Publishing "reboot" to topic "MyDevice"
Publishing "reboot" to topic "MyDevice/cmd"
Publishing "cmd=reboot" to both topics

Is there an easy way of getting an MQTT reboot? If I need to update to later firmware is there a stable version that I can send over the air?

Thanks

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

Re: How can I reboot ESPEasy using MQTT?

#2 Post by grovkillen » 19 Jan 2018, 06:03

I use mqtt import and rules for that.

Code: Select all

on System#Boot do
 Publish %sysname%/status,Booted
 Publish %sysname%/IP,%ip%
endon

on sniff#cmdMQTT=1 do
  Publish %sysname%/IP,%ip%
endon

on sniff#cmdMQTT=2 do
  Publish %sysname%/Time,%systime%
endon

on sniff#cmdMQTT=3 do
 Publish %sysname%/status,Rebooting
 Reboot
endon
So I just publish a number to the topic

Code: Select all

cmdMQTT
and all my units will respond.
Attachments
device_3.png
device_3.png (3.19 MiB) Viewed 7877 times
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:

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: How can I reboot ESPEasy using MQTT?

#3 Post by sheppy » 24 Jan 2018, 20:24

Thanks for the reply, which version do I need to upgrade to for this to work? The builds I have look totally different and don't have MQTT import as an option.

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

Re: How can I reboot ESPEasy using MQTT?

#4 Post by grovkillen » 24 Jan 2018, 20:50

2.0.0+

You find the links on the wiki https://www.letscontrolit.com/wiki/index.php/ESPEasy
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:

sheppy
Normal user
Posts: 49
Joined: 28 Jun 2016, 05:53

Re: How can I reboot ESPEasy using MQTT?

#5 Post by sheppy » 24 Jan 2018, 21:04

Thanks, I'll keep an eye out for when the V2 release arrives as I have a lot of these to update.

mattlward
Normal user
Posts: 70
Joined: 24 Jan 2018, 15:20

Re: How can I reboot ESPEasy using MQTT?

#6 Post by mattlward » 25 Jan 2018, 15:04

So, I am trying to make this work and can't even make it work with MQTTfx. I am subscribing to my HA server with # as my subsciption. I am publishing cmdMQTT/1, /cmdMQTT/1 and never see a response in MQTTfx nor do I see the value change in the devices list on the ESPEasy Wemos D1. I am seeing the above as published in MQTTfx. What am I doing wrong?

mattlward
Normal user
Posts: 70
Joined: 24 Jan 2018, 15:20

Re: How can I reboot ESPEasy using MQTT?

#7 Post by mattlward » 25 Jan 2018, 15:04

BTW, I am running v2.0-20180121

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

Re: How can I reboot ESPEasy using MQTT?

#8 Post by grovkillen » 25 Jan 2018, 17:40

Topic: "cmdMQTT"
Payload/message : "1"

You try to send a blank message to topic "cmdMQTT/1"
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:

mattlward
Normal user
Posts: 70
Joined: 24 Jan 2018, 15:20

Re: How can I reboot ESPEasy using MQTT?

#9 Post by mattlward » 25 Jan 2018, 18:53

That did it! Now, need to find out if I can set up a topic collector in home assistant to grab the responses to verify the IP to name and set a button to reboot in the interface when I want to.

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests