How to make status of Sonoff (Tasmota) devices get updated in MQTT / OpenHAB2?

383 views
Skip to first unread message

Laurentp

unread,
Apr 4, 2021, 7:11:29 PM4/4/21
to TasmotaUsers
Hi there,
I am stuck with following problem:
- Tasmota devices send their LWT messages as "retained" (so device status in MQTT broker - Mosquitto) is ALWAYS "Online".

I want to see in OpenHAB2 REAL status of device, eg online / offline (did not send MQTT for some time).
How to do it?

Laurent

Philip Knowles

unread,
Apr 5, 2021, 2:11:41 AM4/5/21
to TasmotaUsers, Laurentp
The LWT statement shouldn't be 'Online'. It is the statement which is retained by the broker to send when the device disconnects from the broker. It must be retained so that it can be sent as the Last Will and Testament to tell the control system the device has gone.
Regards

Phil K


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Laurentp <wyszk...@gmail.com>
Sent: Monday, April 5, 2021 12:11:29 AM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: How to make status of Sonoff (Tasmota) devices get updated in MQTT / OpenHAB2?
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/bc1c4403-8b49-4672-8d7e-b0bced3965edn%40googlegroups.com.

Jon Eskdale

unread,
Apr 5, 2021, 5:16:50 AM4/5/21
to Laurentp, TasmotaUsers
I use my Tasmota device with Mosquitto and Node Red - With Node read configured to send me an email

image.png

This works brilliantly, I get an offline and online email as the device goes off and online

Jon

--

Philip Knowles

unread,
Apr 5, 2021, 9:04:07 AM4/5/21
to Laurentp, TasmotaUsers

If you create an item in a LWT.items file like this

String MiFloraLWT "MiFlora LWT" {channel="mqtt:topic:MiFlora:LWT"}

And then in your sitemap

Text item=MiFloraLWT label="Miflora LWT [%s]"

You will get this when the device is online

And this when it disconnects from mosquito

You can use the following in a rule

when

                Item MiForaLWT changed to “Offline”

then

                do something

end

 

You could also use the dynamic sitemap features

Text item=Flower_Moisture visibility=[MiFloraLWT == "Offline"] labelcolor=["red"] label="Moisture [Offline]" icon="Humidity"

Text item=Flower_Moisture visibility=[MiFloraLWT == "Online"] labelcolor=["green"] label="Moisture [%.0f %%]" icon="Humidity"

Which will give you the following when offline

and this when online

 

Regards

 

Phil K

Sent from Mail for Windows 10

 

From: Laurentp
Sent: 05 April 2021 00:11
To: TasmotaUsers
Subject: How to make status of Sonoff (Tasmota) devices get updated in MQTT / OpenHAB2?

 

Hi there,

--

Reply all
Reply to author
Forward
0 new messages