[Solved] MQTT status feedback

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

[Solved] MQTT status feedback

#1 Post by xbmcnut » 05 Aug 2016, 07:43

Can't seem to find this anywhere. Does ESPEasy publish a status message when a request to change a GPIO state is received? I'm running R105 on NodeMCU.
Last edited by xbmcnut on 12 Aug 2016, 14:33, edited 2 times in total.
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: MQTT status feedback

#2 Post by JR01 » 05 Aug 2016, 08:09

What is linked to the GPIO ?

If a Switch, you can let it send info, and it will come back on the MQTT channel.
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

Re: MQTT status feedback

#3 Post by xbmcnut » 05 Aug 2016, 11:00

JR01 wrote:What is linked to the GPIO ?

If a Switch, you can let it send info, and it will come back on the MQTT channel.
Thanks but nope, GPIO out for relay control. I'm publishing to /ESP01/gpio/14 with 0 or 1 which flips the relay but I expect a reply back on /ESP01/status... or /ESP01/gpio/14/status. Is this a thing? Without status replies, don't know whether module got the command.
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

Re: [Partly solved] MQTT status feedback

#4 Post by xbmcnut » 10 Aug 2016, 00:22

OK. I have configured the same GPIO pin I'm using to drive a LED and controlled with

Code: Select all

/ESP/01/gpio/14
(0 or 1) as a switch. I've set the name to relay14 and the value name 1 to 'state'. Now, when I control the output with

Code: Select all

/ESP/01/gpio/14
, I get a message back if I subscribe to

Code: Select all

/ESP01/relay14/state
which is awesome.

Problem is, the published message for the switch input does not contain the 'retain' flag. So if the client disconnects and reconnects, the last know state is not read which does not make it Home Automation friendly. Anyone got a workaround or is it possible to add the retain flag to the MQTT code and recompile?
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

Martinus

Re: [Partly solved] MQTT status feedback

#5 Post by Martinus » 11 Aug 2016, 11:43

The next build will have the option to globally enable the MQTT retain flag (tools/advanced menu). Off by default.
Hope this will help.

(I don't use MQTT so i'm sort of a newbie on that stuff...)

xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

Re: [Partly solved] MQTT status feedback

#6 Post by xbmcnut » 11 Aug 2016, 11:46

Wow, that is awesome, thank you. That will save me much grief. I'll keep an eye out.
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

Martinus

Re: [Partly solved] MQTT status feedback

#7 Post by Martinus » 11 Aug 2016, 20:35

Could you check R121 on github and verify if this solves anything?
I've only done some basic tests with the MQTT.fx tool and it seems to work.
You need to enable the retain stuff first on /tools/advanced.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: [Partly solved] MQTT status feedback

#8 Post by JR01 » 12 Aug 2016, 08:52

I also use mqtt extensively, xbmcnut, could you please guve us sine more info in when tobuse this new option in R121, and when not - to 'retain' ?
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

Re: [Partly solved] MQTT status feedback

#9 Post by xbmcnut » 12 Aug 2016, 14:35

Martinus wrote:Could you check R121 on github and verify if this solves anything?
I've only done some basic tests with the MQTT.fx tool and it seems to work.
You need to enable the retain stuff first on /tools/advanced.
You Sir are a legend. It is working a treat now and has saved me countless hours of grief. Thank you so much. This makes ESPEasy super home automation friendly now.
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

xbmcnut
Normal user
Posts: 49
Joined: 17 Mar 2016, 08:49
Location: Auckland, NZ
Contact:

Re: [Partly solved] MQTT status feedback

#10 Post by xbmcnut » 12 Aug 2016, 14:40

JR01 wrote:I also use mqtt extensively, xbmcnut, could you please guve us sine more info in when tobuse this new option in R121, and when not - to 'retain' ?
If you do not publish the 'retain' flag, when a MQTT client connects, it does not know what state the subscribed devices are in until their state changes. With it on, it checks the broker for the last know status and updates the subscription instantly. Great for home automation switches when the HA server (a.k.a MQTT client) reboots for any reason.
Numerous Sonoff's and Shelly's, Home Assistant on Intel NUC i3, Aeotec Z-Stick (Gen 5), deCONZ Zigbee Stick, 3 x Echo Dot's and 5 x Google Home

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

Re: [Solved] MQTT status feedback

#11 Post by JR01 » 12 Aug 2016, 16:20

Makes sense! Tx
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

Post Reply

Who is online

Users browsing this forum: No registered users and 56 guests