check if the mqqt server is present

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
edstobi
Normal user
Posts: 41
Joined: 28 May 2020, 20:33

check if the mqqt server is present

#1 Post by edstobi » 26 May 2024, 17:02

Hello
I would like to equip my ESP 32 with a safety function.
I am using a WT32-eth01 with LAN and if this is not present then wifi.
Now I want to check if the mqqt server is present. If the server is not reachable because of a malfunction or newnetwork problems, all gpios which control relays, have to go into a defined position to prevent damage.
GPIO,4,1
GPIO,5,1
GPIO,14,1
GPIO,15,1

Can I make a ping request or a secure request to the MQTT server and initiate the shutdown process if this is not answered?

I am running ESP_Easy_mega_20230930_normal_ESP32_4M316k_ETH.

trying a ping I am getting
Command unknown: ping 10.10.10.10 // IP from MQTT it responds on pin from PC

User avatar
Ath
Normal user
Posts: 3647
Joined: 10 Jun 2018, 12:06
Location: NL

Re: check if the mqqt server is present

#2 Post by Ath » 26 May 2024, 20:53

For this purpose there are the MQTT#Connected and MQTT#Disconnected events.
When receiving the mqtt#disconnected event you can start any precautious measures needed, and revert them once the server is connected again.
/Ton (PayPal.me)

edstobi
Normal user
Posts: 41
Joined: 28 May 2020, 20:33

Re: check if the mqqt server is present

#3 Post by edstobi » 26 May 2024, 21:48

thank you
that sounds like the right way to go
how can i query this in a rule?
can I simply do this with:
On MQTT#Disconnected Do
GPIO,4,1
GPIO,5,1
GPIO,14,1
GPIO,15,1
Endon

I have just found the answer to this question myself in the help section.

But I do not check the differentes between MQTTimport#Disconnected and MQTT#Disconnected :(

User avatar
Ath
Normal user
Posts: 3647
Joined: 10 Jun 2018, 12:06
Location: NL

Re: check if the mqqt server is present

#4 Post by Ath » 26 May 2024, 21:59

MQTTImport#Disconnected has to do with the MQTT Import plugin P037, and is, sort of, independent from the MQTT#Disconnected event. (IMHO) you can ignore the MQTTImport events for this.
/Ton (PayPal.me)

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

Re: check if the mqqt server is present

#5 Post by TD-er » 26 May 2024, 22:00

mqtt#disconnected as also MQTT import uses the MQTT broker settings of the first enabled MQTT controller.

jgrad
Normal user
Posts: 105
Joined: 29 Aug 2016, 22:03
Location: Slovenia

Re: check if the mqqt server is present

#6 Post by jgrad » 27 May 2024, 13:08

there is also system variable %ismqtt%

User avatar
Ath
Normal user
Posts: 3647
Joined: 10 Jun 2018, 12:06
Location: NL

Re: check if the mqqt server is present

#7 Post by Ath » 27 May 2024, 14:23

jgrad wrote: 27 May 2024, 13:08 there is also system variable %ismqtt%
Well, when would you check that variable? You'd have to add some repeating event to check that, so responding to the original event seems more natural and appropriate.
/Ton (PayPal.me)

jgrad
Normal user
Posts: 105
Joined: 29 Aug 2016, 22:03
Location: Slovenia

Re: check if the mqqt server is present

#8 Post by jgrad » 27 May 2024, 15:17

I just wanted to add if events are not enough that related to this topic there is also system variable available....

User avatar
Ath
Normal user
Posts: 3647
Joined: 10 Jun 2018, 12:06
Location: NL

Re: check if the mqqt server is present

#9 Post by Ath » 27 May 2024, 15:47

;)
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest