How to set remotely a variable (RAM) on another Tasmota (same MQTT broker)?

847 views
Skip to first unread message

Laurentp

unread,
Jul 1, 2021, 3:55:30 AM7/1/21
to TasmotaUsers
Hi there,
I have Sonoff Basic that measures temperatures in kitchen & fridge.
Now I want to set a variable on another (Tasmotized) Sonoff to reflect one of temperatures.
(I need this to make decision to switch on/off AC).
How to do it?

on "temperature#..." do publish "xxx/yyy/cmnd varX Y ?

Laurent

Philip Knowles

unread,
Jul 1, 2021, 5:58:04 AM7/1/21
to Laurentp, TasmotaUsers

You can also use WebSend

 

WebSend [192.168.0.1] var1 1

 

Might be slightly faster

 

Regards

 

Phil K

 

 

Sent from Mail for Windows 10

--
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/849fa392-10a4-4974-badf-ccf14836fa20n%40googlegroups.com.

 

sfromis

unread,
Jul 1, 2021, 6:15:23 AM7/1/21
to TasmotaUsers
The preferred way is indeed something like 
publish cmnd/otherdevice/VarX Y
While WebSend also can work, it is slower and less reliable than MQTT.


Philip Knowles

unread,
Jul 1, 2021, 6:43:16 AM7/1/21
to sfromis, TasmotaUsers

Websend is less reliable (but only if the QOS is set correctly and you are relying on 4 devices working correctly)  but there is no way that it can be slower.

MQTT = MQTT > Router > Broker > Router > Device

WebSend = Command > Router > Device

 

So I did a test using WebSend to send var1 to another device with a rule to WebSend it back. The round trip was 176ms.

11:30:31.420 CMD: websend [192.168.2.120] var1 3

11:30:31.525 MQT: stat/ZigBee/RESULT = {"WebSend":"Done"}

11:30:31.596 MQT: stat/ZigBee/RESULT = {"Var1":"3"}

I then repeated with MQTT – round trip 442ms.

11:33:39.354 CMD: publish cmnd/Sonoff-Pump/var1 6

11:33:39.359 MQT: cmnd/Sonoff-Pump/var1 = 6

11:33:39.796 MQT: stat/ZigBee/RESULT = {"Var1":"6"}

 

Regards

 

Phil K

Sent from Mail for Windows 10

 

--

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.

sfromis

unread,
Jul 1, 2021, 6:56:16 AM7/1/21
to TasmotaUsers
I've verified WebSend to be slower, across a longer sequence of commands. One single test proves nothing, as there can be variability for many reasons.

The reason is that it wastes time establishing a new session every time, while you keep the same session with MQTT. With HTTP there are more packets and more latency. This is much more of a factor than the roundtrip via the broker, unless you have a really crappy place to run a broker.

sfromis

unread,
Jul 1, 2021, 7:18:52 AM7/1/21
to TasmotaUsers
It also looks like your output is merging console from sending and receiving device. Do not expect devices to be precisely synchronized at the millisecond level. I'm often seeing deviations over 0.5 seconds, both ways.

Philip Knowles

unread,
Jul 1, 2021, 7:28:30 AM7/1/21
to sfromis, TasmotaUsers

That’s the output from the single device which originated the message and the time (on the same device) of the return message sent from the second device. It was consistent over 10 messages

The original person asked how to set a variable on one device from another – not a longer series of commands

Sent from Mail for Windows 10

 

From: sfromis
Sent: 01 July 2021 12:18
To: TasmotaUsers
Subject: Re: How to set remotely a variable (RAM) on another Tasmota (same MQTT broker)?

 

It also looks like your output is merging console from sending and receiving device. Do not expect devices to be precisely synchronized at the millisecond level. I'm often seeing deviations over 0.5 seconds, both ways.

 

--

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.

sfromis

unread,
Jul 1, 2021, 7:44:30 AM7/1/21
to TasmotaUsers
You won't see the output of the remote command back on the original device, neither with WebSend nor with Publish.

To avoid this, I'm sending a command back to the originator

13:30:13.804 CMD: websend [device2] Websend [device1] Time
13:30:14.038 MQT: device1/stat/WEBSEND = {"WebSend":"Done"}
13:30:14.077 MQT: device1/stat/TIME = {"Time":"2021-07-01T13:30:14.073+02:00"}

13:30:34.080 CMD: publish device2/cmnd/Publish device1/cmnd/Time
13:30:34.086 MQT: device2/cmnd/Publish = device1/cmnd/Time
13:30:34.181 MQT: device1/stat/TIME = {"Time":"2021-07-01T13:30:34.178+02:00"}

269 ms vs 98 ms. This is a consistent trend, while deviations means that some test shots get similar times for both.
WebSend is slower, on average. Which is perfectly understandable with all the extra traffic. 
Your MQTT timing look badly slow, something in your network is not running well.

Automater

unread,
Jul 1, 2021, 8:09:28 AM7/1/21
to TasmotaUsers
I use websend and it works very reliably even through VPN.

ON ENERGY#Power DO Var1 %value% ENDON

ON Var1#State>20 DO EVENT PublishTemp ENDON

ON Event#PublishTemp DO WebSend [192.168.1.2] Var1 %Var1% ENDON

Philip Knowles

unread,
Jul 1, 2021, 8:31:39 AM7/1/21
to sfromis, TasmotaUsers

I’m sorry but I’m not an idiot. I set up a rule on the second device to send the variable back to check the round trip time

This is the ‘publish’ rule

13:28:50.445 MQT: stat/Sonoff-Pump/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Length":54,"Free":457,"Rules":"on var1#state do publish cmnd/ZigBee/var1 %var1% endon"}

 

Sent from Mail for Windows 10

 

From: sfromis
Sent: 01 July 2021 12:44
To: TasmotaUsers
Subject: Re: How to set remotely a variable (RAM) on another Tasmota (same MQTT broker)?

 

You won't see the output of the remote command back on the original device, neither with WebSend nor with Publish.

--

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.

sfromis

unread,
Jul 1, 2021, 11:42:31 AM7/1/21
to TasmotaUsers
Your additional info does not change the fact that your anecdotal numbers are just for your setup, not due to to HTTP per se being faster than MQTT, which has less network roundtrips.

Reply all
Reply to author
Forward
0 new messages