How to send an initial MQTT message to get the status of a tasmota switch?

Yes, that is an example where you will have to query the alarm source on node-red startup, is that a problem? I note that the subject of the thread is about tasmota switches, which is not the same as an alarm.

That depends on the device and how you have programmed it. Some of my devices do exactly that.

I am not sure what you are asking for, are you asking for a standard way of telling connected devices to send their latest status? If so I don't see how this could be done generically, it has to be device dependent as it relies on the device sending the data.

I haven't fully read the other 40 posts above, so forgive me if I'm misunderstanding the question, But can't the user ask the device for a update via MQTT whenever one is required?

Just post;

msg.payload = ""
msg.topic = cmnd/tasmota_switch/POWER

result on topic stat/tasmota_switch/POWER = ON

Or to get a full status report...

msg.payload = 0
msg.topic = cmnd/tasmota_switch/Status

result on topic stat/tasmota_switch/STATUS
(with more status data on /STATUS1, /STATUS2, /STATUS3, up to /STATUS11 depending what you need)

So if the device is sleeping between updates then I don't see how you could query it from NR as it will not be able to respond ?

The trigger for Mqtt#Connected, can send the "current" state to NR as soon as mqtt connection is made.

This helps with most situations, if the tasmota device is rebooted, powered down, or even sleeping, or the mqtt server is down or Wi-Fi connection is lost, as soon as the connection is made it can send you the "current" state of the device (relay state, temperature, etc).

Or are you meaning that you want to know for example that a switch has changed state from open to closed and BACK again while offline ? So not the current state but, any events that may happened and havenā€™t been sent to mqtt ?

Yes, there are various ways of doing it with Tasmota devices, but the OP is asking, I think, for a general solution which works with any MQTT client.

1 Like

Ah OK, the topic title and the first post specifically asks about Tasmota??
Maybe we need some clarification about what the OP really wants.

Indeed, I did ask for that a few posts ago.

1 Like

Sry for the late answer.
I have reached the new user response limit. -.-
A little dumb on its own thread...

No thx, everything is working fine now.

Exactly, I'm just use the inject node with the auto trigger after 1s now.
And with this method I can force every MQTT device to update the state after a restart.

So question answered, thx @ all!

1 Like

What if the remote device is not running at this time or the network is down?

That's exactly what I'm doing, I had removed the automatic injection checkbox just to make the example and the screenshots. It's a shame, if I had known.
For important devices (ESP8266), like for example a pump that must imperatively empty a tank or it will overflow,
I use a watchdog that warns me via Telegram and my cell phone.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.