Sending commands from function node to Tasmota node

Hello All,

I wondered if anyone would be able to help or direct me to somewhere where it explains how to do this as I can't find anything.

I have a sensor data coming in from a humidity sensor. I want to send ON/OFF commands to the Tasmota node from a function node depending on what the reading is. As in under 65 OFF - over 65 ON.

From a separate function node I also want to send an ON if it is under 65 and OFF 5 seconds later.

This is what I've tried but totally wrong it seems.

Thank you if anyone has time to show me what I'm doing wrong.

As you can see by the red crosses, there's a syntax error in your condition statements and the number of opening/closing brackets don't match.

Try this in your function node...

let h = msg.payload.col11;
let hh = (h * 100);

if (hh >= 65) msg.payload = "ON";
if (hh < 65 ) msg.payload = "OFF";

return msg;

You could also write it as... (which is a bit neater and slightly faster)

let h = msg.payload.col11;
let hh = (h * 100);

if (hh >= 65) msg.payload = "ON";
else if (hh < 65 ) msg.payload = "OFF";
return msg;
1 Like

Or even shorter still....

let hh = msg.payload.col11 * 100;

if (hh >= 65) msg.payload = "ON";
else if (hh < 65 ) msg.payload = "OFF";
return msg;

@btbr take note how @dynamicdave has dealt with the situation where the reading is exactly 65.
In your description, the criteria would not accommodate it being exactly 65.

2 Likes

Thank you very much Dynamicdave!

Need to sort the payload message as it doesn't like it but it's sending it. Thank you very much.

Do you know of any way that I can do something similar and turn it back off after x amount of seconds? It's for a humidifier so just want to give it little blasts until it gets back to what it is supposed to be.

Thanks for your help

Nice one Paul. Yes I did see that he had put equals or greater than.

Not sure why the tasmota node isn't taking the command as it should be the same as the inject node I was testing it with.

Thanks for your help.
Screen Shot 2022-06-25 at 17.50.55

I send commands to my Tasmota (S20 switches) like this...

tasmota_sat_a

tasmota_sat_b

tasmota_sat_c

Please share your flow so we may be able to help you.

I try to use Tasmota's 'Backlog feature' in similar circumstances, because if the humidifier is switched ON, and you lose signal/raspberry Pi crashes/interference etc, you may not successfully receive the 'OFF' signal, leaving the humidifier switched 'ON'.

Backlog Example

let hh = msg.payload.col11 * 100;
if (hh >= 65){
// All of the following commands are passed to the Tasmota, which
// then executes them in order. (Delay 600 = 60 seconds)
msg.payload = "Power ON; Delay 600; Power OFF"
// Change wemos1 to whatever topic name you've set in Tasmota MQTT config
msg.topic = "cmnd/wemos1/Backlog"
node.send(msg)
}
else {return}

tas

Leave the topic blank in the MQTT node (because it has been set in the function node)

topic

I dont use the function node I use a switch node to do the same thing with tasmota
here is my flow so you can se how switch and send via mqtt to the tasmota device.
hope it helps.

[{"id":"42679c25e0ab1dac","type":"group","z":"f6858fe416b029b9","name":"Temperature Control and Display","style":{"stroke":"#000000","fill":"#ff3f3f","fill-opacity":"0.5","label":true,"color":"#000000"},"nodes":["7b80bace1d0cd39c","61361f911b19a76e","4c217d7881d00220","3a2db2a0c7778fc8","881e4777b34ff769","5f1af4bdbb6329c1","f5fcd670b289ea0c","c1b01f876dc2ed36","a13f3a6176478861","bff7a59440748e61","ddf87a246001fa19","4a3d02db5f7634b3","f3ca0662edb2ae15","faf61f13c8219e63","41667d802010a9b4","73dc7c328fbbb9ef","bcaab2257d1000d8","3642f4dbd9bb6c6a","23c7fac620f2e72c","6e6da8a7b6f17e61","951c014c3ec56118","7ada087262a58bc0","f4cb4fb0be2e7308","3b552afa115ebb2a","6560000b22dea7bd"],"x":105.01174354553223,"y":508.68225145339966,"w":1572.445930480957,"h":315.0936346054077},{"id":"7b80bace1d0cd39c","type":"ui_digital_display","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","group":"10c36bea9197e264","order":3,"width":4,"height":1,"digits":5,"decimals":1,"x":849.5760822296143,"y":721.6171879768372,"wires":[]},{"id":"61361f911b19a76e","type":"change","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"set payload to Temperature value","rules":[{"t":"move","p":"payload.Temperature","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560.0207233428955,"y":632.6840825080872,"wires":[["7b80bace1d0cd39c","faf61f13c8219e63","73dc7c328fbbb9ef","bcaab2257d1000d8","3642f4dbd9bb6c6a"]]},{"id":"4c217d7881d00220","type":"split","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":312.1280879974365,"y":590.6588997840881,"wires":[["6e6da8a7b6f17e61","6560000b22dea7bd"]]},{"id":"3a2db2a0c7778fc8","type":"change","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"Wtarget","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":339.92217445373535,"y":767.1319766044617,"wires":[["881e4777b34ff769","5f1af4bdbb6329c1"]]},{"id":"881e4777b34ff769","type":"debug","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":511.3086795806885,"y":782.7758860588074,"wires":[]},{"id":"5f1af4bdbb6329c1","type":"change","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","rules":[{"t":"set","p":"Wtarget","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":526.9379825592041,"y":745.3046374320984,"wires":[[]]},{"id":"f5fcd670b289ea0c","type":"switch","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","property":"Wtarget","propertyType":"global","rules":[{"t":"gte","v":"Wambient","vt":"global"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1033.6908283233643,"y":755.1046147346497,"wires":[["c1b01f876dc2ed36","bff7a59440748e61"],["a13f3a6176478861"]]},{"id":"c1b01f876dc2ed36","type":"change","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1192.1393146514893,"y":743.1761479377747,"wires":[["ddf87a246001fa19","41667d802010a9b4"]]},{"id":"a13f3a6176478861","type":"change","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1187.3099689483643,"y":777.0070195198059,"wires":[["4a3d02db5f7634b3","41667d802010a9b4"]]},{"id":"bff7a59440748e61","type":"debug","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1148.9682941436768,"y":686.6391606330872,"wires":[]},{"id":"ddf87a246001fa19","type":"debug","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1416.4327716827393,"y":699.5537724494934,"wires":[]},{"id":"4a3d02db5f7634b3","type":"debug","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1561.4576740264893,"y":773.5910649299622,"wires":[]},{"id":"f3ca0662edb2ae15","type":"ui_dropdown","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","label":"","tooltip":"","place":"Select option","group":"10c36bea9197e264","order":5,"width":4,"height":1,"passthru":true,"multiple":false,"options":[{"label":"Lager","value":"55","type":"str"},{"label":"Ale","value":"68","type":"str"},{"label":"Dyacetal Rest","value":"70","type":"str"},{"label":"Cold crash","value":"38","type":"str"},{"label":"Off","value":"200","type":"str"},{"label":"kolsch","value":"65","type":"str"}],"payload":"","topic":"target_temperature","x":191.01174354553223,"y":766.6822962760925,"wires":[["3a2db2a0c7778fc8"]]},{"id":"faf61f13c8219e63","type":"change","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","rules":[{"t":"set","p":"Wambient","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":833.4967365264893,"y":756.5100102424622,"wires":[["f5fcd670b289ea0c"]]},{"id":"41667d802010a9b4","type":"change","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"cmnd/Wferm/POWER","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1411.5079669952393,"y":746.4166874885559,"wires":[["3b552afa115ebb2a"]]},{"id":"73dc7c328fbbb9ef","type":"ui_template","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","group":"10c36bea9197e264","name":"West Fermenter","order":12,"width":6,"height":6,"format":"<div id=\"{{'gauge_'+$id}}\" class=\"g-container\" style=\"--gauge-value:0; --container-size:6; --gn-distance:14; --ga-tick-count:10; --ga-subtick-count:100; --g-unit:''\">\n    <div id=\"bgr\" class=\"g-body\">\n        <div class=\"g-ring\">\n            <div class=\"g-rivets\">\n                <div class=g-rivet></div>\n                <div class=g-rivet></div>\n                <div class=g-rivet></div>\n                <div class=g-rivet></div>\n            </div>\n            <div class=\"g-plate\">\n                <div class=\"g-ticks\">\n                    <div class=\"g-tick\" style=\"--ga-tick:1;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:3;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:5;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:7;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:9;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:11;\"></div>\n                </div>\n                <div class=\"g-ticks\">\n                    <div class=\"g-subtick\" style=\"--ga-tick:11;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:31;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:51;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:71;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:91;\"></div>\n                </div>\n               <div class=\"g-nums\">\n                    <div class=\"g-num\" style=\"--ga-tick:1;\" >0</div>\n                    <div class=\"g-num\" style=\"--ga-tick:3;\">20</div>\n                    <div class=\"g-num\" style=\"--ga-tick:5;\">40</div>\n                    <div class=\"g-num\" style=\"--ga-tick:7;\">60</div>\n                    <div class=\"g-num\" style=\"--ga-tick:9;\">80</div>\n                    <div class=\"g-num\" style=\"--ga-tick:11;\">100</div>\n                </div>\n                <div class=\"g-label\">West Fermenter</div>\n                <div class=\"g-needle\"></div>\n                <div class=\"g-needle-ring\"></div>\n                <div id=\"{{'gauge_val_'+$id}}\" class=\"g-val\"></div>\n            </div>\n        </div>\n    </div>\n</div>\n<script>\n(function(scope) {\n    let min = 0;\n    let max = 100;\n  scope.$watch('msg', function(msg) {\n    if (msg) {\n      // Do something when msg arrives\n        const v = Math.floor(((msg.payload - min) / (max - min)) * 100);\n        document.getElementById('gauge_'+scope.$id).style.setProperty('--gauge-value', v);\n        document.getElementById('gauge_val_'+scope.$id).innerText = v+\"°F\";\n    }\n   \n  });\n})(scope);\n</script>\n","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","x":873.0204181671143,"y":688.6840214729309,"wires":[[]]},{"id":"bcaab2257d1000d8","type":"ui_digital_display","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","group":"3e395b874f5be5a8","order":3,"width":0,"height":0,"digits":5,"decimals":1,"x":806.0119953155518,"y":583.3489384651184,"wires":[]},{"id":"3642f4dbd9bb6c6a","type":"ui_template","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","group":"3e395b874f5be5a8","name":"4x4 - quater - top - left","order":4,"width":4,"height":4,"format":"<div class=\"g-wrapper g-wrapper-label-0\">\n\n<div id=\"{{'gauge_'+$id}}\" class=\"g-container\" style=\"--gauge-value:100; --container-size:4; --gn-distance:28; --ga-tick-count:10; --ga-subtick-count:100; --g-unit:'°F'\">\n    <div id=\"bgr\" class=\"g-body quarter-top-left\">\n        <div class=\"g-ring\">\n            <div class=\"g-plate\">\n                <div class=\"g-ticks\">\n                    <div class=\"g-tick\" style=\"--ga-tick:1;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:2;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:3;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:4;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:5;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:6;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:7;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:8;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:9;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:10;\"></div>\n                    <div class=\"g-tick\" style=\"--ga-tick:11;\"></div>\n                </div>\n                <div class=\"g-ticks\">\n                    <div class=\"g-subtick\" style=\"--ga-tick:2;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:3;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:4;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:5;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:6;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:7;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:8;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:9;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:10;\"></div>\n                    \n                    <div class=\"g-subtick\" style=\"--ga-tick:12;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:13;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:14;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:15;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:16;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:17;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:18;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:19;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:20;\"></div>\n                    \n                    <div class=\"g-subtick\" style=\"--ga-tick:22;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:23;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:24;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:25;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:26;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:27;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:28;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:29;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:30;\"></div>\n                    \n                    <div class=\"g-subtick\" style=\"--ga-tick:32;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:33;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:34;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:35;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:36;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:37;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:38;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:39;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:40;\"></div>\n                    \n                    <div class=\"g-subtick\" style=\"--ga-tick:42;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:43;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:44;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:45;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:46;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:47;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:48;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:49;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:50;\"></div>\n                    \n                    <div class=\"g-subtick\" style=\"--ga-tick:52;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:53;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:54;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:55;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:56;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:57;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:58;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:59;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:60;\"></div>\n                    \n                    <div class=\"g-subtick\" style=\"--ga-tick:62;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:63;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:64;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:65;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:66;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:67;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:68;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:69;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:70;\"></div>\n                    \n                    <div class=\"g-subtick\" style=\"--ga-tick:72;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:73;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:74;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:75;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:76;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:77;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:78;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:79;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:80;\"></div>\n                    \n                    <div class=\"g-subtick\" style=\"--ga-tick:82;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:83;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:84;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:85;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:86;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:87;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:88;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:89;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:90;\"></div>\n                    \n                    <div class=\"g-subtick\" style=\"--ga-tick:92;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:93;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:94;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:95;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:96;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:97;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:98;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:99;\"></div>\n                    <div class=\"g-subtick\" style=\"--ga-tick:100;\"></div>\n                </div>\n               <div class=\"g-nums\">\n                    <div class=\"g-num\" style=\"--ga-tick:1;\" >0</div>\n\n                    <div class=\"g-num\" style=\"--ga-tick:3;\">20</div>\n\n                    <div class=\"g-num\" style=\"--ga-tick:5;\">40</div>\n\n                    <div class=\"g-num\" style=\"--ga-tick:7;\">60</div>\n\n                    <div class=\"g-num\" style=\"--ga-tick:9;\">80</div>\n\n                    <div class=\"g-num\" style=\"--ga-tick:11;\">100</div>\n                </div>\n                <div class=\"g-label\">West FERM</div>\n                <div class=\"g-needle\"></div>\n                <div class=\"g-needle-ring\"></div>\n            </div>\n            <div class=\"g-val-ring\">\n                <div class=\"g-val-plate\"></div>\n                <div id=\"{{'gauge_val_'+$id}}\" class=\"g-val\"></div>\n            </div>\n        </div>\n    </div>\n</div>\n</div>\n<script>\n(function(scope) {\n    let min = 0;\n    let max = 100;\n  scope.$watch('msg', function(msg) {\n    if (msg) {\n      // Do something when msg arrives\n        const val = msg.payload\n        const v = max + (((val - min) / (max - min)) * 100);\n        document.getElementById('gauge_'+scope.$id).style.setProperty('--gauge-value', v);\n        document.getElementById('gauge_val_'+scope.$id).innerText = val.toFixed(1);\n    }\n   \n  });\n})(scope);\n</script>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":825.6783771514893,"y":618.3489384651184,"wires":[[]]},{"id":"23c7fac620f2e72c","type":"link in","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"Sensor In","links":["8d94228d93e5b07b"],"x":210.51173973083496,"y":589.6295418739319,"wires":[["4c217d7881d00220"]]},{"id":"6e6da8a7b6f17e61","type":"debug","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490.51175117492676,"y":569.6822514533997,"wires":[]},{"id":"951c014c3ec56118","type":"debug","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":465.5117435455322,"y":682.6822552680969,"wires":[]},{"id":"7ada087262a58bc0","type":"comment","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"Display Tab UI's","info":"","x":807.0117511749268,"y":549.6822514533997,"wires":[]},{"id":"f4cb4fb0be2e7308","type":"comment","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"Brewery Tab Ui's","info":"","x":906.0117511749268,"y":654.6822514533997,"wires":[]},{"id":"3b552afa115ebb2a","type":"link out","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"Wferm to mqtt out","mode":"link","links":["fdde7cd3d4a6c237"],"x":1596.2675800323486,"y":623.8759354820252,"wires":[]},{"id":"6560000b22dea7bd","type":"switch","z":"f6858fe416b029b9","g":"42679c25e0ab1dac","name":"West","property":"payload.Id","propertyType":"msg","rules":[{"t":"cont","v":"3C01D607FD9D","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":255.01172065734863,"y":647.0156073570251,"wires":[["61361f911b19a76e"],[]]},{"id":"10c36bea9197e264","type":"ui_group","name":"WestFermenter2new","tab":"a74ffe3d.4eb73","order":5,"disp":true,"width":24,"collapse":false},{"id":"3e395b874f5be5a8","type":"ui_group","name":"Fermenter West","tab":"b9dd4549c2e0e031","order":6,"disp":true,"width":"6","collapse":false},{"id":"a74ffe3d.4eb73","type":"ui_tab","name":"Brewery","icon":"dashboard","order":1,"disabled":false,"hidden":false},{"id":"b9dd4549c2e0e031","type":"ui_tab","name":"Display","icon":"dashboard","disabled":false,"hidden":false}]

Thank you everyone for getting back to me.

Works perfectly now.

Thanks Paul for the heads up on the backlog. I was worried about the very same thing, but didn't know doing it like that was even an option. Much better way of doing it.

Node red is excellent.

Another useful feature is getting some feedback from the Tasmota, by adding Status 1 to the command string, like this;

"Power ON; Status 1; Delay 600; Power OFF; Status 1"

The Tasmota will then send MQTT messages confirming that it's fulfilled each action, telling you that it's switched ON, then 60 seconds later, another message confirming that it's switched off.
That's useful to save in a logfile, or displaying it's status on a node-RED dashboard.

To listen for the messages from the Tasmota, you need to subscribe to the topic;
stat/wemos1/RESULT - of course changing 'wemos1' to whatever topic name you've set in Tasmota MQTT config.

My Tasmota smart plugs use PulseTime https://tasmota.github.io/docs/Commands/#control
That ensures that when the relay is turned ON it will definitely turn itself OFF after n seconds even if the Node-red server goes down.
Pretty sure I've checked that it turns OFF if the Wifi goes down too, which is excellent.
The relay default state at power up is OFF, so the whole setup is immune to powercuts too.

If I want to keep the relay ON, Node-red has to resend ON at an interval a bit less than the PulseTime setting.

Of course I can still send an explicit OFF.

That's very similar to Backlog @jbudd .
I tend to use Backlog in preference to PulseTime<x>, because other commands can be added into the string (example - Status mentioned above), but both seem to be safer options when you need to ensure that an appliance is switched off again.

No doubt Backlog offers more, I glanced at the documentation and was confused. I'm going to revisit it with the benefit of your example.

1 Like

Tasmota will send the status following a cmd without the need for an extra status cmd -
stat/Landing/RESULT = {"POWER":"OFF"}
stat/Landing/POWER = OFF

I used the Tasmota node to show the switch status. Just says on or off under it.

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