Action depending on 2 different MQTT messages

Via MQTT there are two outputs/messages from my Sonoff (Tasmota) Dual R3:

tele/Fietsen/STATE = {"Time":"2022-09-18T11:21:07","Uptime":"0T18:50:17","UptimeSec":67817,"Heap":151,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":14,"Berry":{"HeapUsed":3,"Objects":40},"POWER1":"ON","POWER2":"OFF","Wifi":{"AP":1,"SSId":"TIS","BSSId":"2C:91:AB:D4:57:79","Channel":6,"Mode":"11n","RSSI":88,"Signal":-56,"LinkCount":14,"Downtime":"0T00:02:55"}}

and

tele/Fietsen/SENSOR = {"Time":"2022-09-18T11:21:08","Switch1":"ON","Switch2":"ON","ENERGY":{"TotalStartTime":"2022-04-17T10:26:15","Total":13.403,"Yesterday":0.090,"Today":0.000,"Period":[ 0, 0],"Power":[ 0, 0],"ApparentPower":[ 0, 0],"ReactivePower":[ 0, 0],"Factor":[0.00,0.00],"Voltage": 0,"Current":[0.000,0.000]},"ESP32":{"Temperature":57.2},"TempUnit":"C"}

When payload.ENERGY.Current[0] < 0.1 and payload.POWER1 = ON the text must be generated and displayed.

Unfortunately I can't do this, can someone tell me how to do this?

This is my flow so far:

[{"id":"a3b360bc9233ce8f","type":"tab","label":"NR Forum","disabled":false,"info":"","env":[]},{"id":"47f83ff477748825","type":"switch","z":"a3b360bc9233ce8f","name":"1 ON?","property":"payload.Switch2","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":100,"wires":[["1b35cf0f6baaa7df"]]},{"id":"1b35cf0f6baaa7df","type":"switch","z":"a3b360bc9233ce8f","name":"< 100 watt?","property":"payload.ENERGY.Current[1]","propertyType":"msg","rules":[{"t":"lt","v":"0.100","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":100,"wires":[["639c130714546083"]]},{"id":"639c130714546083","type":"change","z":"a3b360bc9233ce8f","name":"Text","rules":[{"t":"set","p":"payload","pt":"msg","to":"Current < 0.100 and Power ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":100,"wires":[["ec3b2d98358287e7"]]},{"id":"263716800d132df3","type":"mqtt in","z":"a3b360bc9233ce8f","name":"tele/Fietsen/STATE","topic":"tele/Fietsen/STATE","qos":"2","datatype":"auto-detect","broker":"41cfb26be5b19e42","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":140,"wires":[[]]},{"id":"436f1b8b0c791370","type":"mqtt in","z":"a3b360bc9233ce8f","name":"tele/Fietsen/SENSOR","topic":"tele/Fietsen/SENSOR","qos":"2","datatype":"auto-detect","broker":"41cfb26be5b19e42","nl":false,"rap":true,"rh":0,"inputs":0,"x":140,"y":80,"wires":[[]]},{"id":"ec3b2d98358287e7","type":"debug","z":"a3b360bc9233ce8f","name":"Show result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":100,"wires":[]},{"id":"41cfb26be5b19e42","type":"mqtt-broker","name":"MQTT NAS-B","broker":"192.168.2.155","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

You would need to join the messages, you can use the unique topics to do this.
e.g.

[{"id":"436f1b8b0c791370","type":"mqtt in","z":"a3b360bc9233ce8f","name":"tele/Fietsen/SENSOR","topic":"tele/Fietsen/SENSOR","qos":"2","datatype":"auto-detect","broker":"41cfb26be5b19e42","nl":false,"rap":true,"rh":0,"x":140,"y":40,"wires":[["b0f06c4.3955d9"]]},{"id":"b0f06c4.3955d9","type":"join","z":"a3b360bc9233ce8f","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":270,"y":100,"wires":[["47f83ff477748825"]]},{"id":"263716800d132df3","type":"mqtt in","z":"a3b360bc9233ce8f","name":"tele/Fietsen/STATE","topic":"tele/Fietsen/STATE","qos":"2","datatype":"auto-detect","broker":"41cfb26be5b19e42","nl":false,"rap":true,"rh":0,"x":130,"y":160,"wires":[["b0f06c4.3955d9"]]},{"id":"47f83ff477748825","type":"switch","z":"a3b360bc9233ce8f","name":"1 ON?","property":"payload[\"tele/Fietsen/STATE\"].Switch2","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":100,"wires":[["1b35cf0f6baaa7df"]]},{"id":"1b35cf0f6baaa7df","type":"switch","z":"a3b360bc9233ce8f","name":"< 100 watt?","property":"payload[\"tele/Fietsen/SENSOR\"].ENERGY.Current[1]","propertyType":"msg","rules":[{"t":"lt","v":"0.100","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":100,"wires":[["639c130714546083"]]},{"id":"639c130714546083","type":"change","z":"a3b360bc9233ce8f","name":"Text","rules":[{"t":"set","p":"payload","pt":"msg","to":"Current < 0.100 and Power ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":100,"wires":[["ec3b2d98358287e7"]]},{"id":"ec3b2d98358287e7","type":"debug","z":"a3b360bc9233ce8f","name":"Show result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":100,"wires":[]},{"id":"41cfb26be5b19e42","type":"mqtt-broker","name":"MQTT NAS-B","broker":"192.168.2.155","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

Thanks for helping, learning every day. With some help... :wink:

Unfortunately things are not going well, maybe I misunderstood you. Below the flow and the debug 3 and 4 output, there is no debug 5 output while the conditions (power ON and current < 0.1) are met.

Would you like to take another look?

[{"id":"26a523fefdd4341a","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"49cdfcb4852b929f","type":"mqtt in","z":"26a523fefdd4341a","name":"tele/Fietsen/SENSOR","topic":"tele/Fietsen/SENSOR","qos":"2","datatype":"auto-detect","broker":"41cfb26be5b19e42","nl":false,"rap":true,"rh":0,"inputs":0,"x":140,"y":180,"wires":[["1a394eab18482427","b0b85f463f1ee569"]]},{"id":"1a394eab18482427","type":"join","z":"26a523fefdd4341a","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":370,"y":240,"wires":[["945cf718583b56ee"]]},{"id":"5ece88a78273142c","type":"mqtt in","z":"26a523fefdd4341a","name":"tele/Fietsen/STATE","topic":"tele/Fietsen/STATE","qos":"2","datatype":"auto-detect","broker":"41cfb26be5b19e42","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":300,"wires":[["1a394eab18482427","36b27acc454ce23e"]]},{"id":"945cf718583b56ee","type":"switch","z":"26a523fefdd4341a","name":"1 ON?","property":"payload.POWER1","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":490,"y":240,"wires":[["bfff93ad9d9dda61"]]},{"id":"bfff93ad9d9dda61","type":"switch","z":"26a523fefdd4341a","name":"< 100 watt?","property":"payload.ENERGY.Current[0]","propertyType":"msg","rules":[{"t":"lt","v":"0.100","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":240,"wires":[["0bfb2149f6546b97"]]},{"id":"0bfb2149f6546b97","type":"change","z":"26a523fefdd4341a","name":"Text","rules":[{"t":"set","p":"payload","pt":"msg","to":"Current < 0.100 and Power ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":240,"wires":[["ba4a6c6941499981"]]},{"id":"b0b85f463f1ee569","type":"debug","z":"26a523fefdd4341a","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":380,"y":180,"wires":[]},{"id":"36b27acc454ce23e","type":"debug","z":"26a523fefdd4341a","name":"debug 4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":380,"y":300,"wires":[]},{"id":"ba4a6c6941499981","type":"debug","z":"26a523fefdd4341a","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":900,"y":240,"wires":[]},{"id":"41cfb26be5b19e42","type":"mqtt-broker","name":"MQTT NAS-B","broker":"192.168.2.155","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

You have not looked at my example fully, if you had you would see that the switch node properties are different.
payload["tele/Fietsen/STATE"].POWER1
payload["tele/Fietsen/SENSOR"].ENERGY.Current[0]
Due to the joining.

The inject node simulate your mqtt nodes.

[{"id":"2717a9ab.e2bcee","type":"inject","z":"26a523fefdd4341a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"tele/Fietsen/SENSOR","payload":"{\"Time\":\"2022-09-18T11:21:08\",\"Switch1\":\"ON\",\"Switch2\":\"ON\",\"ENERGY\":{\"TotalStartTime\":\"2022-04-17T10:26:15\",\"Total\":13.403,\"Yesterday\":0.090,\"Today\":0.000,\"Period\":[ 0, 0],\"Power\":[ 0, 0],\"ApparentPower\":[ 0, 0],\"ReactivePower\":[ 0, 0],\"Factor\":[0.00,0.00],\"Voltage\": 0,\"Current\":[0.000,0.000]},\"ESP32\":{\"Temperature\":57.2},\"TempUnit\":\"C\"}","payloadType":"json","x":100,"y":100,"wires":[["1a394eab18482427"]]},{"id":"1a394eab18482427","type":"join","z":"26a523fefdd4341a","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":370,"y":240,"wires":[["945cf718583b56ee","b0b85f463f1ee569"]]},{"id":"ed62b708.1472d","type":"inject","z":"26a523fefdd4341a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"tele/Fietsen/STATE","payload":"{\"Time\":\"2022-09-18T11:21:07\",\"Uptime\":\"0T18:50:17\",\"UptimeSec\":67817,\"Heap\":151,\"SleepMode\":\"Dynamic\",\"Sleep\":50,\"LoadAvg\":19,\"MqttCount\":14,\"Berry\":{\"HeapUsed\":3,\"Objects\":40},\"POWER1\":\"ON\",\"POWER2\":\"OFF\",\"Wifi\":{\"AP\":1,\"SSId\":\"TIS\",\"BSSId\":\"2C:91:AB:D4:57:79\",\"Channel\":6,\"Mode\":\"11n\",\"RSSI\":88,\"Signal\":-56,\"LinkCount\":14,\"Downtime\":\"0T00:02:55\"}}","payloadType":"json","x":120,"y":360,"wires":[["1a394eab18482427"]]},{"id":"945cf718583b56ee","type":"switch","z":"26a523fefdd4341a","name":"1 ON?","property":"payload[\"tele/Fietsen/STATE\"].POWER1","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":490,"y":240,"wires":[["bfff93ad9d9dda61"]]},{"id":"b0b85f463f1ee569","type":"debug","z":"26a523fefdd4341a","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":160,"wires":[]},{"id":"bfff93ad9d9dda61","type":"switch","z":"26a523fefdd4341a","name":"< 100 watt?","property":"payload[\"tele/Fietsen/SENSOR\"].ENERGY.Current[0]","propertyType":"msg","rules":[{"t":"lt","v":"0.100","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":630,"y":240,"wires":[["0bfb2149f6546b97"]]},{"id":"0bfb2149f6546b97","type":"change","z":"26a523fefdd4341a","name":"Text","rules":[{"t":"set","p":"payload","pt":"msg","to":"Current < 0.100 and Power ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":240,"wires":[["ba4a6c6941499981"]]},{"id":"ba4a6c6941499981","type":"debug","z":"26a523fefdd4341a","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":900,"y":240,"wires":[]}]
1 Like

Have you looked at the results of the various STATUS commands on the Sonoff?
It is possible that you can get both values in a single message directly from Tasmota.
Unlike Tele messages, you have to request Status.
For example status 10:
Untitled 1

[{"id":"486b206dd3334970","type":"inject","z":"a32120f79694632f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"cmnd/Fiesten/status","payload":"10","payloadType":"num","x":280,"y":120,"wires":[["1f5b6b65b060ed1f"]]},{"id":"b32364b61827573a","type":"mqtt in","z":"a32120f79694632f","name":"","topic":"stat/Fietsen/STATUS10","qos":"2","datatype":"json","broker":"41cfb26be5b19e42","nl":false,"rap":true,"rh":0,"inputs":0,"x":280,"y":160,"wires":[["7af69738603ee66c"]]},{"id":"1f5b6b65b060ed1f","type":"mqtt out","z":"a32120f79694632f","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"41cfb26be5b19e42","x":530,"y":120,"wires":[]},{"id":"7af69738603ee66c","type":"debug","z":"a32120f79694632f","name":"Status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":160,"wires":[]},{"id":"41cfb26be5b19e42","type":"mqtt-broker","name":"MQTT NAS-B","broker":"192.168.2.155","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

https://tasmota.github.io/docs/Commands/#status

Sorry, I didn't really look closely. With your help it works now, thank you very much!

[{"id":"26a523fefdd4341a","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"49cdfcb4852b929f","type":"mqtt in","z":"26a523fefdd4341a","name":"tele/Fietsen/SENSOR","topic":"tele/Fietsen/SENSOR","qos":"2","datatype":"auto-detect","broker":"41cfb26be5b19e42","nl":false,"rap":true,"rh":0,"inputs":0,"x":140,"y":200,"wires":[["1a394eab18482427"]]},{"id":"1a394eab18482427","type":"join","z":"26a523fefdd4341a","name":"Join Topics","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":350,"y":240,"wires":[["945cf718583b56ee"]]},{"id":"5ece88a78273142c","type":"mqtt in","z":"26a523fefdd4341a","name":"tele/Fietsen/STATE","topic":"tele/Fietsen/STATE","qos":"2","datatype":"auto-detect","broker":"41cfb26be5b19e42","nl":false,"rap":true,"rh":0,"inputs":0,"x":130,"y":280,"wires":[["1a394eab18482427"]]},{"id":"945cf718583b56ee","type":"switch","z":"26a523fefdd4341a","name":"1 ON?","property":"payload[\"tele/Fietsen/STATE\"].POWER1","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":470,"y":300,"wires":[["bfff93ad9d9dda61"]]},{"id":"bfff93ad9d9dda61","type":"switch","z":"26a523fefdd4341a","name":"< 100 mw?","property":"payload[\"tele/Fietsen/SENSOR\"].ENERGY.Current[0]","propertyType":"msg","rules":[{"t":"lt","v":"0.100","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":360,"wires":[["0bfb2149f6546b97"]]},{"id":"0bfb2149f6546b97","type":"change","z":"26a523fefdd4341a","name":"Text","rules":[{"t":"set","p":"payload","pt":"msg","to":"Current < 0.100 and Power ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":420,"wires":[["ba4a6c6941499981"]]},{"id":"ba4a6c6941499981","type":"debug","z":"26a523fefdd4341a","name":"Show text","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":820,"y":480,"wires":[]},{"id":"41cfb26be5b19e42","type":"mqtt-broker","name":"MQTT NAS-B","broker":"192.168.2.155","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

Thanks for your advice! The Dual R3 is fairly new and based on an ESP32. Flashing and working with Tasmota is not as easy as with the ESP8266 based hardware. I don't have much experience with it yet and maybe future versions of Tasmota will work better on this hardware. However, my problem has been solved with E1cid's advice.

It's nice to see that I always get good and fast help on this forum!

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