Improve node status msg for main scene handlers

This commit is contained in:
2025-03-23 00:54:33 -04:00
parent 980d2f2321
commit c7c725dd17

View File

@ -5677,7 +5677,7 @@
"type": "function",
"z": "a4ee891237e460a2",
"name": "Routing",
"func": "const str = msg.payload\nconst scene = str.replaceAll(\"_\", \" \")\nconst dynamicRooms = global.get(\"dynamicRooms\", \"diskCon\")\nconst tvRooms = global.get(\"tvRooms\", \"diskCon\")\nconst room = msg.topic\n\nlet notify = {\n \"dest\": room,\n \"topic\": \"Lights Changed\",\n \"payload\": \"Lights changed to a new scene: \" + scene\n}\n\nlet statusMsg = {\n \"payload\": \"Lights changed to a new scene: \" + scene\n}\n\nif (dynamicRooms.includes(room)) {\n node.send([msg,null,null,null])\n} else {\n node.send([null,msg,null,null])\n}\n\nif (tvRooms.includes(room)) {\n node.send([null,null,notify,null])\n}\n\nnode.send([null,null,null,statusMsg])",
"func": "const str = msg.payload\nconst scene = str.replaceAll(\"_\", \" \")\nconst dynamicRooms = global.get(\"dynamicRooms\", \"diskCon\")\nconst tvRooms = global.get(\"tvRooms\", \"diskCon\")\nconst room = msg.topic\n\nlet notify = {\n \"dest\": room,\n \"topic\": \"Lights Changed\",\n \"payload\": `Lights changed to a new scene: ${scene}`\n}\n\nlet statusMsg = {\n \"status\": {\n \"fill\": \"green\",\n \"shape\": \"dot\",\n \"text\": `Lights changed to a new scene: ${scene}`\n }\n}\n\nif (dynamicRooms.includes(room)) {\n node.send([msg,null,null,null])\n} else {\n node.send([null,msg,null,null])\n}\n\nif (tvRooms.includes(room)) {\n node.send([null,null,notify,null])\n}\n\nnode.send([null,null,null,statusMsg])",
"outputs": 4,
"timeout": "",
"noerr": 0,
@ -5710,7 +5710,7 @@
"type": "function",
"z": "a4ee891237e460a2",
"name": "Routing",
"func": "const str = msg.payload\nconst scene = str.replaceAll(\"_\", \" \")\nconst states = global.get('homeassistant.homeAssistant.states')\nconst dynamicRooms = global.get(\"dynamicRooms\", \"diskCon\")\nconst tvRooms = global.get(\"tvRooms\", \"diskCon\")\nconst room = msg.topic\n\nlet notify = {\n \"dest\": room,\n \"topic\":\"Lights Changed\",\n \"payload\":\"Lights changed to a new scene: \" + scene\n}\n\nlet statusMsg = {\n \"payload\": \"Lights changed to a new scene: \" + scene\n}\n\nif (scene.includes(\"Nightlight\")) {\n msg.nightlight = \"on\"\n} else {\n msg.nightlight = \"off\"\n}\n\nif (dynamicRooms.includes(room)) {\n let inputBoolean = \"input_boolean.\" + room + \"_dynamic_scenes\"\n let boolState = states[inputBoolean].state\n if (boolState === 'on') {\n node.send([msg,null,null,null])\n } else {\n node.send([null,msg,null,null])\n }\n} else {\n node.send([null,msg,null,null])\n}\n\nif (tvRooms.includes(room)) {\n node.send([null,null,notify,null])\n}\n\nnode.send([null,null,null,statusMsg])",
"func": "const str = msg.payload\nconst scene = str.replaceAll(\"_\", \" \")\nconst states = global.get('homeassistant.homeAssistant.states')\nconst dynamicRooms = global.get(\"dynamicRooms\", \"diskCon\")\nconst tvRooms = global.get(\"tvRooms\", \"diskCon\")\nconst room = msg.topic\n\nlet notify = {\n \"dest\": room,\n \"topic\": \"Lights Changed\",\n \"payload\": `Lights changed to a new scene: ${scene}`\n}\n\nlet statusMsg = {\n \"status\": {\n \"fill\": \"green\",\n \"shape\": \"dot\",\n \"text\": `Lights changed to a new scene: ${scene}`\n }\n}\n\nif (scene.includes(\"Nightlight\")) {\n msg.nightlight = \"on\"\n} else {\n msg.nightlight = \"off\"\n}\n\nif (dynamicRooms.includes(room)) {\n let inputBoolean = \"input_boolean.\" + room + \"_dynamic_scenes\"\n let boolState = states[inputBoolean].state\n if (boolState === 'on') {\n node.send([msg,null,null,null])\n } else {\n node.send([null,msg,null,null])\n }\n} else {\n node.send([null,msg,null,null])\n}\n\nif (tvRooms.includes(room)) {\n node.send([null,null,notify,null])\n}\n\nnode.send([null,null,null,statusMsg])",
"outputs": 4,
"timeout": "",
"noerr": 0,
@ -5850,7 +5850,7 @@
"type": "function",
"z": "85c4f81ca9628aea",
"name": "Format",
"func": "const str = msg.payload\nlet scene = str.replaceAll(\"_\",\" \")\n\nmsg.dest = msg.topic\n\nmsg.topic = \"Lights Changed\"\nmsg.payload = ('Lights changed to a new scene: ' + scene)\n\nif (msg.payload === 'Lights changed to a new scene: Reset') {\n return null;\n} else {\n return msg;\n}",
"func": "const str = msg.payload\nlet scene = str.replaceAll(\"_\",\" \")\nlet topic = msg.topic\n\nlet statusMsg = {\n \"status\": {\n \"fill\": \"green\",\n \"shape\": \"dot\",\n \"text\": `Lights changed to a new scene: ${scene}`\n }\n}\n\nif (scene === 'Reset' || scene === 'Select') {\n return null\n} else {\n node.send(statusMsg)\n}",
"outputs": 1,
"timeout": "",
"noerr": 0,