Page 1 of 1
MQTT-connect event
Posted: 08 Mar 2018, 13:03
by Micha_he
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

Re: MQTT-connect event
Posted: 08 Mar 2018, 13:32
by TD-er
Currently there is no such event, but I think there should be one.
Re: MQTT-connect event
Posted: 08 Mar 2018, 14:21
by Micha_he
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.

Re: MQTT-connect event
Posted: 08 Mar 2018, 15:07
by fraeggle
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
Re: MQTT-connect event
Posted: 08 Mar 2018, 15:44
by Micha_he
Yes, that's maybe a way.
But I need the Vcc-option from the latest firmware for my project. That's the stalemate!
Re: MQTT-connect event
Posted: 08 Mar 2018, 17:50
by fraeggle
VCC-Option?
What exactly does that mean.
Re: MQTT-connect event
Posted: 09 Mar 2018, 00:49
by TD-er
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)
Re: MQTT-connect event
Posted: 09 Mar 2018, 14:18
by Micha_he
Thanks for that. I'll look at the new version with the additinal events....
Re: MQTT-connect event
Posted: 09 Mar 2018, 18:54
by Micha_he
Is it possible, that the 'send to controller'-function from the device-categorie, fires the publish before the 'MQTT#Connected'-event ?
Re: MQTT-connect event
Posted: 09 Mar 2018, 19:29
by TD-er
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.
Re: MQTT-connect event
Posted: 10 Mar 2018, 12:14
by Micha_he
Any hint to find the correct position in the ESPEasy sourcecode, where the Function 'Send To Controller' is triggered

Re: MQTT-connect event
Posted: 10 Mar 2018, 18:28
by TD-er
Controller.ino, the function void sendData(struct EventStruct *event)
Re: MQTT-connect event
Posted: 10 Mar 2018, 20:58
by Micha_he
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 (62.04 KiB) Viewed 12183 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

Re: MQTT-connect event
Posted: 12 Mar 2018, 08:14
by Micha_he
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 ?
Re: MQTT-connect event
Posted: 12 Mar 2018, 10:02
by spachal
Hi, that's really great, THANK YOU, very useful!! :]