MQTT-connect event

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

MQTT-connect event

#1 Post by Micha_he » 08 Mar 2018, 13:03

Is there an event like 'MQTT#Connected' or 'Controller#Connected' ?

I would like to publish a modified/logical-calculated state on boot, but with 'On System#Boot do' the publish is too early (MQTT connect is a moment later) and with a timer the solution is unhappy :(

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

Re: MQTT-connect event

#2 Post by TD-er » 08 Mar 2018, 13:32

Currently there is no such event, but I think there should be one.

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: MQTT-connect event

#3 Post by Micha_he » 08 Mar 2018, 14:21

Or alternatively an event like 'System#IsBooted' at the end of the boot-process ;)

I'd like to help and try to add it, but currently the self-compiled images do not work on my PUYA-ESP-01. So I can't test anything on it. :(

fraeggle
Normal user
Posts: 21
Joined: 20 Nov 2017, 20:12

Re: MQTT-connect event

#4 Post by fraeggle » 08 Mar 2018, 15:07

I went back to Mega 20180104. In this version the on system#boot do works.
Hope it will be fixed in later releases again
In the ne versions the ESP is also connected to the MQTT with ESP_"MACADRESS" and not with the name given in the SW ex: ESP_TAB4

Peter

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: MQTT-connect event

#5 Post by Micha_he » 08 Mar 2018, 15:44

Yes, that's maybe a way.
But I need the Vcc-option from the latest firmware for my project. That's the stalemate!

fraeggle
Normal user
Posts: 21
Joined: 20 Nov 2017, 20:12

Re: MQTT-connect event

#6 Post by fraeggle » 08 Mar 2018, 17:50

VCC-Option?
What exactly does that mean.

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

Re: MQTT-connect event

#7 Post by TD-er » 09 Mar 2018, 00:49

I just added a number of new events to be used in rules.
See Pull Request: https://github.com/letscontrolit/ESPEasy/pull/1032

These will be in the next build, which will be made around 5 am (in about 4 hours)

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: MQTT-connect event

#8 Post by Micha_he » 09 Mar 2018, 14:18

Thanks for that. I'll look at the new version with the additinal events....

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: MQTT-connect event

#9 Post by Micha_he » 09 Mar 2018, 18:54

Is it possible, that the 'send to controller'-function from the device-categorie, fires the publish before the 'MQTT#Connected'-event ?

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

Re: MQTT-connect event

#10 Post by TD-er » 09 Mar 2018, 19:29

Micha_he wrote: 09 Mar 2018, 18:54 Is it possible, that the 'send to controller'-function from the device-categorie, fires the publish before the 'MQTT#Connected'-event ?
Yep, that's possible and probably that 'send to controller' event will never reach the MQTT broker, since the controller plugins will stop trying if there is no connection.

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: MQTT-connect event

#11 Post by Micha_he » 10 Mar 2018, 12:14

Any hint to find the correct position in the ESPEasy sourcecode, where the Function 'Send To Controller' is triggered :?:

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

Re: MQTT-connect event

#12 Post by TD-er » 10 Mar 2018, 18:28

Controller.ino, the function void sendData(struct EventStruct *event)

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: MQTT-connect event

#13 Post by Micha_he » 10 Mar 2018, 20:58

I'll see, if I can fix it :)

I often use only the single bootstate-publish of the devices. Afterwards, the ESP goes into deep sleep again. Here you see, what I mean...
Bootstate_too_early.jpg
Bootstate_too_early.jpg (62.04 KiB) Viewed 10268 times

Edit:

That's too high for me ! I don't understand the process with the boot-state-event and the initial publish from it.
I can live with it: Re-publish the state with the MQTT#Connected-event ;)

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: MQTT-connect event

#14 Post by Micha_he » 12 Mar 2018, 08:14

In my opinion it's, because we have the following init-sequence:

1. PluginInit() (included the _P001_Switch, which try to send the boot-state)
2. WifiConnect
3. MQTTConnect

But how it should be send at Pos. 1 ?

spachal
Normal user
Posts: 55
Joined: 22 Feb 2018, 22:11

Re: MQTT-connect event

#15 Post by spachal » 12 Mar 2018, 10:02

TD-er wrote: 09 Mar 2018, 00:49 I just added a number of new events to be used in rules.
See Pull Request: https://github.com/letscontrolit/ESPEasy/pull/1032

These will be in the next build, which will be made around 5 am (in about 4 hours)
Hi, that's really great, THANK YOU, very useful!! :]
Please excuse my English, thanks!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 28 guests