@PeteKnight
Salut Pete
Is there a better interpretation for this flow (a simplified version) ?
I need a “Countdown function” so I can see the remaining time on blynk LCD.
Clipboard copy.
[
{
"id": "6367c3d6.b0177c",
"type": "mqtt in",
"z": "bc3b6538.ad0c48",
"name": "PIR @ pin D1",
"topic": "cmnd/sonoff34/PIR/POWER2",
"qos": "1",
"broker": "8a72da15.bf29b8",
"x": 250,
"y": 600,
"wires": [
[
"494cfb77.d9ccc4",
"67a2744.4069f8c"
]
],
"outputLabels": [
"ON / OFF"
]
},
{
"id": "9712ba88.f25298",
"type": "trigger",
"z": "bc3b6538.ad0c48",
"op1": "1",
"op2": "0",
"op1type": "str",
"op2type": "str",
"duration": "3",
"extend": true,
"units": "min",
"reset": "Auto",
"bytopic": "all",
"name": "",
"x": 610,
"y": 600,
"wires": [
[
"f03a60ed.f0863"
]
],
"outputLabels": [
"1/0"
]
},
{
"id": "b4ddff7b.d38d",
"type": "mqtt out",
"z": "bc3b6538.ad0c48",
"name": "LIGHT Relay @ pin D6",
"topic": "cmnd/sonoff34/POWER",
"qos": "1",
"retain": "true",
"broker": "8a72da15.bf29b8",
"x": 1220,
"y": 600,
"wires": []
},
{
"id": "67a2744.4069f8c",
"type": "switch",
"z": "bc3b6538.ad0c48",
"name": "ON",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "ON",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 430,
"y": 600,
"wires": [
[
"9712ba88.f25298"
]
]
},
{
"id": "4f27669.d202598",
"type": "function",
"z": "bc3b6538.ad0c48",
"name": "Override",
"func": "var over=global.get('overrideMain');\nif (msg.topic.includes(\"OVERRIDE\") || msg.topic.includes(\"alexa\")) {\n if (msg.payload==\"Auto\"){\n over=\"AUTO\";\n global.set('overrideMain',over);\n node.status({fill:\"blue\",shape:\"dot\",text:\"Override: \"+over}); \n return msg;\n } else {\n if (msg.payload==\"1\") {\n over=\"ON\";\n node.status({fill:\"yellow\",shape:\"dot\",text:\"Override: \"+over});\n msg.payload=\"ON\"\n }\n if (msg.payload==\"0\") {\n over=\"OFF\";\n node.status({fill:\"grey\",shape:\"dot\",text:\"Override: \"+over});\n msg.payload=\"OFF\"\n }\n global.set('overrideMain',over);\n return msg;\n }\n} else {\n if (over==\"ON\") msg.payload=\"1\";\n if (over==\"OFF\") msg.payload=\"0\";\n return msg;\n}",
"outputs": 1,
"noerr": 0,
"x": 980,
"y": 600,
"wires": [
[
"b4ddff7b.d38d",
"d981f2c4.da54f",
"334bd5ad.1d3a9a"
]
]
},
{
"id": "494cfb77.d9ccc4",
"type": "function",
"z": "bc3b6538.ad0c48",
"name": "PIR",
"func": "if (msg.payload==\"ON\") node.status({fill:\"yellow\",shape:\"ring\",text:msg.payload});\nelse node.status({fill:\"grey\",shape:\"ring\",text:msg.payload}); \nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 310,
"y": 680,
"wires": [
[
"d6d6c320.3b94"
]
]
},
{
"id": "d981f2c4.da54f",
"type": "debug",
"z": "bc3b6538.ad0c48",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 1210,
"y": 660,
"wires": []
},
{
"id": "22699b.4547a666",
"type": "ui_button",
"z": "bc3b6538.ad0c48",
"name": "OFF",
"group": "73ce4f22.05854",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"label": "OFF",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "0",
"payloadType": "str",
"topic": "MAIN/OVERRIDE/",
"x": 690,
"y": 300,
"wires": [
[
"4f27669.d202598",
"b286bb02.436018"
]
]
},
{
"id": "7727ade9.1d25f4",
"type": "ui_button",
"z": "bc3b6538.ad0c48",
"name": "ON",
"group": "73ce4f22.05854",
"order": 2,
"width": "3",
"height": "1",
"passthru": true,
"label": "ON",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "1",
"payloadType": "str",
"topic": "MAIN/OVERRIDE/",
"x": 690,
"y": 260,
"wires": [
[
"4f27669.d202598"
]
]
},
{
"id": "93e292b1.7b363",
"type": "ui_button",
"z": "bc3b6538.ad0c48",
"name": "AUTO",
"group": "73ce4f22.05854",
"order": 1,
"width": 0,
"height": 0,
"passthru": true,
"label": "AUTO",
"color": "",
"bgcolor": "",
"icon": "",
"payload": "Auto",
"payloadType": "str",
"topic": "MAIN/OVERRIDE/",
"x": 690,
"y": 340,
"wires": [
[
"4f27669.d202598",
"9712ba88.f25298",
"2a16eb9a.9d1d84"
]
]
},
{
"id": "803b78b6.3b58f8",
"type": "ui_audio",
"z": "bc3b6538.ad0c48",
"name": "",
"group": "73ce4f22.05854",
"voice": "en-GB",
"always": true,
"x": 1220,
"y": 700,
"wires": []
},
{
"id": "47ab51ee.edf15",
"type": "Sonoff device",
"z": "bc3b6538.ad0c48",
"mode": "0",
"broker": "8a72da15.bf29b8",
"device": "sonoff34",
"name": "Tasmota sonoff-34",
"onValue": "ON",
"offValue": "OFF",
"cmdPrefix": "cmnd",
"statPrefix": "stat",
"telePrefix": "tele",
"x": 1170,
"y": 300,
"wires": [
[]
]
},
{
"id": "f2c8bb00.2c8fd8",
"type": "inject",
"z": "bc3b6538.ad0c48",
"name": "ON",
"topic": "",
"payload": "ON",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 250,
"y": 260,
"wires": [
[
"7727ade9.1d25f4",
"dbc3c1cc.e3062"
]
]
},
{
"id": "6b40b1cb.73071",
"type": "inject",
"z": "bc3b6538.ad0c48",
"name": "OFF",
"topic": "",
"payload": "OFF",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 250,
"y": 300,
"wires": [
[
"22699b.4547a666",
"dbc3c1cc.e3062"
]
]
},
{
"id": "825f08a8.6a1848",
"type": "inject",
"z": "bc3b6538.ad0c48",
"name": "AUTO",
"topic": "",
"payload": "AUTO",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 250,
"y": 340,
"wires": [
[
"93e292b1.7b363",
"dbc3c1cc.e3062"
]
]
},
{
"id": "d14328e4.7184a8",
"type": "blynk-ws-in-write",
"z": "bc3b6538.ad0c48",
"name": "PB-ON",
"pin": "1",
"pin_all": 0,
"client": "554f52d0.f2beac",
"x": 230,
"y": 80,
"wires": [
[
"30fb5265.91086e"
]
]
},
{
"id": "30fb5265.91086e",
"type": "change",
"z": "bc3b6538.ad0c48",
"name": "Change from 1 to ON",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "1",
"fromt": "str",
"to": "ON",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 440,
"y": 100,
"wires": [
[
"1fb6c432.e8d51c"
]
]
},
{
"id": "1fb6c432.e8d51c",
"type": "switch",
"z": "bc3b6538.ad0c48",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "ON",
"vt": "str"
},
{
"t": "eq",
"v": "OFF",
"vt": "str"
},
{
"t": "eq",
"v": "AUTO",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 670,
"y": 140,
"wires": [
[
"dbc3c1cc.e3062",
"7727ade9.1d25f4"
],
[
"22699b.4547a666",
"dbc3c1cc.e3062"
],
[
"93e292b1.7b363",
"dbc3c1cc.e3062"
]
]
},
{
"id": "91b07712.6efb08",
"type": "blynk-ws-out-write",
"z": "bc3b6538.ad0c48",
"name": "LED PIR",
"pin": "4",
"pinmode": 0,
"client": "554f52d0.f2beac",
"x": 760,
"y": 680,
"wires": []
},
{
"id": "d6d6c320.3b94",
"type": "change",
"z": "bc3b6538.ad0c48",
"name": "Change from ON/OFF to 255/0",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "ON",
"fromt": "str",
"to": "255",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "OFF",
"fromt": "str",
"to": "0",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 680,
"wires": [
[
"91b07712.6efb08"
]
]
},
{
"id": "18811f83.8514d",
"type": "blynk-ws-in-write",
"z": "bc3b6538.ad0c48",
"name": "PB-AUTO",
"pin": "3",
"pin_all": 0,
"client": "554f52d0.f2beac",
"x": 240,
"y": 200,
"wires": [
[
"8bc458cb.3dc628"
]
]
},
{
"id": "8bc458cb.3dc628",
"type": "change",
"z": "bc3b6538.ad0c48",
"name": "Change 1 to AUTO",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "1",
"fromt": "str",
"to": "AUTO",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 430,
"y": 180,
"wires": [
[
"1fb6c432.e8d51c"
]
]
},
{
"id": "78115651.ceaf68",
"type": "blynk-ws-in-write",
"z": "bc3b6538.ad0c48",
"name": "PB-OFF",
"pin": "2",
"pin_all": 0,
"client": "554f52d0.f2beac",
"x": 240,
"y": 140,
"wires": [
[
"5a8254b6.78f15c"
]
]
},
{
"id": "5a8254b6.78f15c",
"type": "change",
"z": "bc3b6538.ad0c48",
"name": "Change from 1 to OFF",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "1",
"fromt": "str",
"to": "OFF",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 440,
"y": 140,
"wires": [
[
"1fb6c432.e8d51c"
]
]
},
{
"id": "76bfb561.69da1c",
"type": "blynk-ws-out-write",
"z": "bc3b6538.ad0c48",
"name": "ON",
"pin": "1",
"pinmode": 0,
"client": "554f52d0.f2beac",
"x": 1190,
"y": 80,
"wires": []
},
{
"id": "dbc3c1cc.e3062",
"type": "function",
"z": "bc3b6538.ad0c48",
"name": "ON/OFF/AUTO Override",
"func": " if (msg.payload==\"ON\") {\n over=\"ON\";\n global.set('overrideMain',over);\n node.status({fill:\"yellow\",shape:\"dot\",text:\"Blynk Override: \"+over});\n// msg.payload=\"ON\"\n return [{'payload': '1' }, {'payload': '0' }, {'payload': '0' }]; \n }\n if (msg.payload==\"OFF\") {\n over=\"OFF\";\n node.status({fill:\"grey\",shape:\"dot\",text:\"Blynk Override: \"+over});\n// msg.payload=\"OFF\"\n return [{'payload': '0' }, {'payload': '1' }, {'payload': '0' }]; \n }\n if (msg.payload==\"AUTO\"){\n over=\"AUTO\";\n node.status({fill:\"blue\",shape:\"dot\",text:\"Blynk Override: \"+over}); \n return [{'payload': '0' }, {'payload': '0' }, {'payload': '1' }]; \n }\n//return msg;\n\n\nif (msg.command ==\"TurnOnRequest\")\n{\n// node.status({ text: \"ON\" }); \n node.status({fill:\"yellow\",shape:\"dot\",text:\"Alexa Override: ON\"});\n return [ {'payload': '1' }, {'payload': '0' }, {'payload': '0' }]; \n}\nif (msg.command ==\"TurnOffRequest\")\n{\n// node.status({ text: 'OFF' });\n node.status({fill:\"grey\",shape:\"dot\",text:\"Alexa Override: OFF\"});\n return [ {'payload': '0' }, {'payload': '1' }, {'payload': '0' }];\n}\n\n\nvar RF = msg.payload.RfReceived.Data;\nnode.status({text:RF});\n if (RF==\"5545C0\") { \n node.status({fill:\"yellow\",shape:\"dot\",text:\"RF ON \" + RF})\n return [{'payload': '1' }, {'payload': '0' }, {'payload': '0' }]; \n }\n if (RF== \"554530\") { \n node.status({fill:\"grey\",shape:\"dot\",text:\"RF OFF \" + RF}); \n return [{'payload': '0' }, {'payload': '1' }, {'payload': '0' }];\n } \n if (RF== \"55450C\") {\n node.status({fill:\"blue\",shape:\"dot\",text:\"RF AUTO \"+ RF}); \n return [{'payload': '0' }, {'payload': '0' }, {'payload': '1' }]; \n } \n//return msg; \n \n",
"outputs": 3,
"noerr": 0,
"x": 930,
"y": 140,
"wires": [
[
"76bfb561.69da1c"
],
[
"a2ea3fa0.860f4",
"b286bb02.436018"
],
[
"a5ce3d36.9ba9f"
]
]
},
{
"id": "a2ea3fa0.860f4",
"type": "blynk-ws-out-write",
"z": "bc3b6538.ad0c48",
"name": "OFF",
"pin": "2",
"pinmode": 0,
"client": "554f52d0.f2beac",
"x": 1190,
"y": 140,
"wires": []
},
{
"id": "a5ce3d36.9ba9f",
"type": "blynk-ws-out-write",
"z": "bc3b6538.ad0c48",
"name": "AUTO",
"pin": "3",
"pinmode": 0,
"client": "554f52d0.f2beac",
"x": 1190,
"y": 200,
"wires": []
},
{
"id": "66f39b21.8fbab4",
"type": "alexa-home",
"z": "bc3b6538.ad0c48",
"conf": "198887d9.6c0cc8",
"device": "35277",
"acknoledge": true,
"name": "Room",
"topic": "sonoff34/PIR/alexa",
"x": 230,
"y": 400,
"wires": [
[
"4f27669.d202598",
"dbc3c1cc.e3062"
]
]
},
{
"id": "4d7d5e0d.24bc2",
"type": "mqtt in",
"z": "bc3b6538.ad0c48",
"name": "RF @ pin D7",
"topic": "tele/sonoff34/RESULT",
"qos": "1",
"broker": "8a72da15.bf29b8",
"x": 250,
"y": 500,
"wires": [
[
"9bf73c71.30c8c"
]
]
},
{
"id": "9bf73c71.30c8c",
"type": "json",
"z": "bc3b6538.ad0c48",
"name": "",
"property": "payload",
"action": "obj",
"pretty": false,
"x": 450,
"y": 500,
"wires": [
[
"dbc3c1cc.e3062",
"44b33006.f419c"
]
]
},
{
"id": "44b33006.f419c",
"type": "function",
"z": "bc3b6538.ad0c48",
"name": "Data to ON/OFF/AUTO",
"func": "var RF = msg.payload.RfReceived.Data;\nnode.status({text:RF});\n\n if (RF==\"5545C0\") { \n node.status({fill:\"yellow\",shape:\"dot\",text:\"RF ON \" + RF})\n return [ {'payload': \"ON\" }, null , null ];\n }\n if (RF== \"554530\") { \n node.status({fill:\"grey\",shape:\"dot\",text:\"RF OFF \" + RF}); \n return [ null , {'payload': \"OFF\" }, null ];\n } \n if (RF== \"55450C\") {\n node.status({fill:\"blue\",shape:\"dot\",text:\"RF AUTO \"+ RF}); \n return [ null , null , {'payload': \"AUTO\" } ];\n } \nreturn [ null , null , null ];\n//return msg; \n \n",
"outputs": 3,
"noerr": 0,
"x": 670,
"y": 500,
"wires": [
[
"7727ade9.1d25f4"
],
[
"22699b.4547a666",
"b286bb02.436018"
],
[
"93e292b1.7b363"
]
],
"outputLabels": [
"ON",
"OFF",
"AUTO"
]
},
{
"id": "d0c8b977.e0ecb8",
"type": "comment",
"z": "bc3b6538.ad0c48",
"name": "BLYNK",
"info": "",
"x": 70,
"y": 140,
"wires": []
},
{
"id": "b71a0915.67ef48",
"type": "comment",
"z": "bc3b6538.ad0c48",
"name": "RF 315",
"info": "",
"x": 70,
"y": 500,
"wires": []
},
{
"id": "a9de0e0f.48367",
"type": "comment",
"z": "bc3b6538.ad0c48",
"name": "UI",
"info": "",
"x": 70,
"y": 300,
"wires": []
},
{
"id": "de1073da.e8551",
"type": "comment",
"z": "bc3b6538.ad0c48",
"name": "Alexa",
"info": "",
"x": 70,
"y": 400,
"wires": []
},
{
"id": "6f040b89.9b41b4",
"type": "comment",
"z": "bc3b6538.ad0c48",
"name": "PIR",
"info": "",
"x": 70,
"y": 600,
"wires": []
},
{
"id": "f03a60ed.f0863",
"type": "function",
"z": "bc3b6538.ad0c48",
"name": "CountDown",
"func": "\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 790,
"y": 600,
"wires": [
[
"4f27669.d202598"
]
]
},
{
"id": "20af90de.0afc9",
"type": "blynk-ws-out-lcd",
"z": "bc3b6538.ad0c48",
"name": "",
"pin": "7",
"client": "554f52d0.f2beac",
"x": 990,
"y": 520,
"wires": []
},
{
"id": "97b7693e.ca1318",
"type": "blynk-ws-out-write",
"z": "bc3b6538.ad0c48",
"name": "LED output",
"pin": "5",
"pinmode": 0,
"client": "554f52d0.f2beac",
"x": 1190,
"y": 480,
"wires": []
},
{
"id": "845ed4e2.8bbad8",
"type": "change",
"z": "bc3b6538.ad0c48",
"name": "Change from ON/OFF to 255/0",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "ON",
"fromt": "str",
"to": "255",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "OFF",
"fromt": "str",
"to": "0",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1110,
"y": 420,
"wires": [
[
"97b7693e.ca1318"
]
]
},
{
"id": "69a8593.a61daa8",
"type": "mqtt in",
"z": "bc3b6538.ad0c48",
"name": "",
"topic": "stat/sonoff34/POWER",
"qos": "1",
"broker": "8a72da15.bf29b8",
"x": 1100,
"y": 360,
"wires": [
[
"845ed4e2.8bbad8"
]
]
},
{
"id": "2a16eb9a.9d1d84",
"type": "change",
"z": "bc3b6538.ad0c48",
"name": "Send ON",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "Auto",
"fromt": "str",
"to": "ON",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 880,
"y": 340,
"wires": [
[]
]
},
{
"id": "b286bb02.436018",
"type": "function",
"z": "bc3b6538.ad0c48",
"name": "Reset",
"func": "msg.payload ='Auto';\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 870,
"y": 300,
"wires": [
[
"9712ba88.f25298"
]
]
},
{
"id": "334bd5ad.1d3a9a",
"type": "change",
"z": "bc3b6538.ad0c48",
"name": "change",
"rules": [
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "1",
"fromt": "str",
"to": "Motion",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "0",
"fromt": "str",
"to": " ",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1000,
"y": 700,
"wires": [
[
"bb80c38a.700dc",
"803b78b6.3b58f8"
]
]
},
{
"id": "bb80c38a.700dc",
"type": "googlehome-notify",
"z": "bc3b6538.ad0c48",
"server": "8884b30e.ec758",
"name": "Google Home",
"x": 1200,
"y": 760,
"wires": []
},
{
"id": "8a72da15.bf29b8",
"type": "mqtt-broker",
"z": "",
"name": "Mosquito",
"broker": "192.168.xxx.xxx",
"port": "1883",
"clientid": "Sonoff33",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "1",
"birthRetain": "true",
"birthPayload": "",
"closeTopic": "",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
},
{
"id": "73ce4f22.05854",
"type": "ui_group",
"z": "",
"name": "HALL",
"tab": "a5b4907f.531a6",
"disp": true,
"width": "3",
"collapse": false
},
{
"id": "554f52d0.f2beac",
"type": "blynk-ws-client",
"z": "",
"name": "PIR",
"path": "ws://xxx.xxx.xxx.xxx/websockets",
"key": "fa615fd8abd5444d9cce9a9aa6ec9a4b",
"dbg_all": false,
"dbg_read": false,
"dbg_write": false,
"dbg_notify": false,
"dbg_mail": false,
"dbg_prop": false,
"dbg_sync": false,
"dbg_bridge": false,
"dbg_low": false,
"dbg_pins": "",
"multi_cmd": false,
"proxy_type": "no",
"proxy_url": ""
},
{
"id": "198887d9.6c0cc8",
"type": "alexa-home-conf",
"z": "",
"username": "xxx"
},
{
"id": "8884b30e.ec758",
"type": "googlehome-config-node",
"z": "",
"ipaddress": "192.168.xxx.xxx",
"name": "",
"language": "en"
},
{
"id": "a5b4907f.531a6",
"type": "ui_tab",
"z": "bc3b6538.ad0c48",
"name": "Sonoff",
"icon": "dashboard",
"order": 1
}
]