Simplify messaging flows with function nodes

This commit is contained in:
2023-03-27 21:06:16 -04:00
parent fa85a9e62a
commit 52ffbb42ba

View File

@ -685,9 +685,7 @@
"37f1c11c59a6ce16" "37f1c11c59a6ce16"
], ],
"x": 94, "x": 94,
"y": 339, "y": 339
"w": 1872,
"h": 622
}, },
{ {
"id": "39a7ac02f2727f1d", "id": "39a7ac02f2727f1d",
@ -734,7 +732,9 @@
"1c98de289e42377f" "1c98de289e42377f"
], ],
"x": 14, "x": 14,
"y": 719 "y": 719,
"w": 1292,
"h": 642
}, },
{ {
"id": "e065b1ed4938b477", "id": "e065b1ed4938b477",
@ -806,7 +806,9 @@
"a3ef2faca9922113" "a3ef2faca9922113"
], ],
"x": 14, "x": 14,
"y": 19 "y": 19,
"w": 2112,
"h": 682
}, },
{ {
"id": "5c50443a84910fb7", "id": "5c50443a84910fb7",
@ -846,18 +848,16 @@
}, },
"nodes": [ "nodes": [
"a4c477269b22f766", "a4c477269b22f766",
"155b26ba197473e4",
"3153371fe2de6f8e",
"9cafa6212280b2d5", "9cafa6212280b2d5",
"5095d45c90d5304f", "5095d45c90d5304f",
"3ae21589dd88c080", "3ae21589dd88c080",
"93b7bee28a7e896e", "93b7bee28a7e896e",
"91c224b7d6f0d32e", "b2bc83c9195efe0f",
"b2bc83c9195efe0f" "f4bfbaca4d7fb1df"
], ],
"x": 14, "x": 14,
"y": 39, "y": 39,
"w": 872, "w": 792,
"h": 142 "h": 142
}, },
{ {
@ -870,8 +870,6 @@
}, },
"nodes": [ "nodes": [
"f803c6af3a30eb66", "f803c6af3a30eb66",
"c3dc3b15f1261b9f",
"3c0e9baa492b618a",
"3bd7704103dbfc20", "3bd7704103dbfc20",
"a6234b2047ba3116", "a6234b2047ba3116",
"788eb0a1551db9b8", "788eb0a1551db9b8",
@ -880,9 +878,9 @@
"3c03edd9c35f85f8" "3c03edd9c35f85f8"
], ],
"x": 14, "x": 14,
"y": 219, "y": 199,
"w": 1012, "w": 712,
"h": 202 "h": 142
}, },
{ {
"id": "fbbe69a14cbe0236", "id": "fbbe69a14cbe0236",
@ -930,7 +928,9 @@
"febc179b34c8cf71" "febc179b34c8cf71"
], ],
"x": 34, "x": 34,
"y": 39 "y": 39,
"w": 692,
"h": 682
}, },
{ {
"id": "46275dd0f9461013", "id": "46275dd0f9461013",
@ -948,7 +948,9 @@
"ca88f85ba00a6744" "ca88f85ba00a6744"
], ],
"x": 34, "x": 34,
"y": 739 "y": 739,
"w": 472,
"h": 202
}, },
{ {
"id": "ff6d8150e8d5e606", "id": "ff6d8150e8d5e606",
@ -1108,26 +1110,18 @@
"nodes": [ "nodes": [
"98626a8f2b59bde3", "98626a8f2b59bde3",
"47bc783fd78f5aa8", "47bc783fd78f5aa8",
"95652a59518e2767",
"3d5448e57ef666a0",
"5de6d772e1ecdd22",
"c684d82a2abea389",
"ba18895fef9810bd",
"20666f8c1488d423",
"db6d955c039873be", "db6d955c039873be",
"e3ef7fe6bcad3b74",
"d2fec32d385dae8c", "d2fec32d385dae8c",
"0145961e8276c53e", "0145961e8276c53e",
"fd623c46a558a01a", "fd623c46a558a01a",
"926fc60ea00ddfb0",
"c52cae79eb97bcc0", "c52cae79eb97bcc0",
"b2d2662449cd647d", "6b039ef7895476e2",
"6b039ef7895476e2" "f44427c5a493c428"
], ],
"x": 14, "x": 14,
"y": 499, "y": 359,
"w": 1252, "w": 1012,
"h": 362 "h": 222
}, },
{ {
"id": "eeafd13be593ae69", "id": "eeafd13be593ae69",
@ -1197,9 +1191,7 @@
"37bdac2c9a4e2837" "37bdac2c9a4e2837"
], ],
"x": 54, "x": 54,
"y": 39, "y": 39
"w": 1652,
"h": 382
}, },
{ {
"id": "8aee4d340a136bac", "id": "8aee4d340a136bac",
@ -1219,9 +1211,7 @@
"b281061a4b08d2eb" "b281061a4b08d2eb"
], ],
"x": 14, "x": 14,
"y": 539, "y": 539
"w": 612,
"h": 202
}, },
{ {
"id": "550e5b2d99316b12", "id": "550e5b2d99316b12",
@ -1362,7 +1352,9 @@
"51d05298561cfddb" "51d05298561cfddb"
], ],
"x": 754, "x": 754,
"y": 39 "y": 39,
"w": 672,
"h": 262
}, },
{ {
"id": "b708cb6d93f40dee", "id": "b708cb6d93f40dee",
@ -1378,9 +1370,7 @@
"e59180a1a6ae0a90" "e59180a1a6ae0a90"
], ],
"x": 1094, "x": 1094,
"y": 839, "y": 839
"w": 632,
"h": 82
}, },
{ {
"id": "a705cecb0997a43a", "id": "a705cecb0997a43a",
@ -23163,85 +23153,7 @@
"y": 80, "y": 80,
"wires": [ "wires": [
[ [
"155b26ba197473e4" "f4bfbaca4d7fb1df"
]
]
},
{
"id": "155b26ba197473e4",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "477e752fcd2e2a19",
"name": "Message",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_text.tts_message",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 280,
"y": 80,
"wires": [
[
"3153371fe2de6f8e"
]
]
},
{
"id": "3153371fe2de6f8e",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "477e752fcd2e2a19",
"name": "Destination",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_select.tts_devices",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 450,
"y": 80,
"wires": [
[
"91c224b7d6f0d32e"
] ]
] ]
}, },
@ -23349,51 +23261,12 @@
"z": "ee67610b4a0578d2", "z": "ee67610b4a0578d2",
"g": "477e752fcd2e2a19", "g": "477e752fcd2e2a19",
"name": "", "name": "",
"x": 780, "x": 500,
"y": 80, "y": 80,
"wires": [ "wires": [
[] []
] ]
}, },
{
"id": "91c224b7d6f0d32e",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "477e752fcd2e2a19",
"name": "Voice",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_select.announcement_voice",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "voice",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 610,
"y": 80,
"wires": [
[
"93b7bee28a7e896e"
]
]
},
{ {
"id": "b2bc83c9195efe0f", "id": "b2bc83c9195efe0f",
"type": "api-call-service", "type": "api-call-service",
@ -23434,85 +23307,7 @@
"entityConfig": "675dd216a61c575b", "entityConfig": "675dd216a61c575b",
"outputProperties": [], "outputProperties": [],
"x": 110, "x": 110,
"y": 260, "y": 240,
"wires": [
[
"c3dc3b15f1261b9f"
]
]
},
{
"id": "c3dc3b15f1261b9f",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "50e4d951ee7b3e54",
"name": "Get Text",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_text.report_system",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "text",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 280,
"y": 260,
"wires": [
[
"3c0e9baa492b618a"
]
]
},
{
"id": "3c0e9baa492b618a",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "50e4d951ee7b3e54",
"name": "Get Type",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_select.report_type",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "type",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 440,
"y": 260,
"wires": [ "wires": [
[ [
"a6234b2047ba3116" "a6234b2047ba3116"
@ -23531,8 +23326,8 @@
"syntax": "mustache", "syntax": "mustache",
"template": "{\n \"content\": \"{{text}}\",\n \"project_id\": 2285967948,\n \"section_id\": {{type}}\n}", "template": "{\n \"content\": \"{{text}}\",\n \"project_id\": 2285967948,\n \"section_id\": {{type}}\n}",
"output": "str", "output": "str",
"x": 760, "x": 460,
"y": 260, "y": 240,
"wires": [ "wires": [
[] []
] ]
@ -23542,15 +23337,15 @@
"type": "function", "type": "function",
"z": "ee67610b4a0578d2", "z": "ee67610b4a0578d2",
"g": "50e4d951ee7b3e54", "g": "50e4d951ee7b3e54",
"name": "", "name": "Processing",
"func": "if (msg.type === \"New Idea\") {\n msg.type = \"81234669\"\n} else if (msg.type === \"Bug Report\") {\n msg.type = \"94865633\"\n}\nreturn msg;", "func": "var states = global.get('homeassistant.homeAssistant.states')\nvar text = states['input_text.report_system'].state\nvar type = states['input_select.report_type'].state\n\nmsg.text = text\n\nif (type === \"New Idea\") {\n msg.type = \"81234669\"\n} else if (type === \"Bug Report\") {\n msg.type = \"94865633\"\n}\nreturn msg;",
"outputs": 1, "outputs": 1,
"noerr": 0, "noerr": 0,
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"libs": [], "libs": [],
"x": 600, "x": 290,
"y": 260, "y": 240,
"wires": [ "wires": [
[ [
"3bd7704103dbfc20" "3bd7704103dbfc20"
@ -23582,11 +23377,10 @@
} }
], ],
"x": 110, "x": 110,
"y": 320, "y": 300,
"wires": [ "wires": [
[ [
"7674185d1e5ee489", "7674185d1e5ee489"
"427cc2991454bbf0"
] ]
] ]
}, },
@ -23613,9 +23407,11 @@
"outputProperties": [], "outputProperties": [],
"queue": "none", "queue": "none",
"x": 290, "x": 290,
"y": 320, "y": 300,
"wires": [ "wires": [
[] [
"427cc2991454bbf0"
]
] ]
}, },
{ {
@ -23640,8 +23436,8 @@
"mustacheAltTags": false, "mustacheAltTags": false,
"outputProperties": [], "outputProperties": [],
"queue": "none", "queue": "none",
"x": 290, "x": 470,
"y": 380, "y": 300,
"wires": [ "wires": [
[] []
] ]
@ -23677,10 +23473,10 @@
} }
], ],
"x": 120, "x": 120,
"y": 580, "y": 440,
"wires": [ "wires": [
[ [
"e3ef7fe6bcad3b74" "f44427c5a493c428"
] ]
] ]
}, },
@ -23715,204 +23511,10 @@
} }
], ],
"x": 140, "x": 140,
"y": 640,
"wires": [
[
"d2fec32d385dae8c",
"0145961e8276c53e",
"fd623c46a558a01a",
"6b039ef7895476e2"
]
]
},
{
"id": "95652a59518e2767",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "Message",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_text.text_notification",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 440,
"y": 580,
"wires": [
[
"b2d2662449cd647d"
]
]
},
{
"id": "3d5448e57ef666a0",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "Phones",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_select.select_phones",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "phones",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 760,
"y": 540, "y": 540,
"wires": [ "wires": [
[ [
"c684d82a2abea389" "d2fec32d385dae8c"
]
]
},
{
"id": "5de6d772e1ecdd22",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "TVs",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_select.select_tvs",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "tvs",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 750,
"y": 620,
"wires": [
[
"ba18895fef9810bd"
]
]
},
{
"id": "c684d82a2abea389",
"type": "switch",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "",
"property": "phones",
"propertyType": "msg",
"rules": [
{
"t": "neq",
"v": "None",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 875,
"y": 540,
"wires": [
[
"20666f8c1488d423"
]
],
"l": false
},
{
"id": "ba18895fef9810bd",
"type": "switch",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "",
"property": "tvs",
"propertyType": "msg",
"rules": [
{
"t": "neq",
"v": "None",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 875,
"y": 620,
"wires": [
[
"926fc60ea00ddfb0"
]
],
"l": false
},
{
"id": "20666f8c1488d423",
"type": "function",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "Formatting",
"func": "var phones = msg.phones.toLowerCase()\n\nmsg.phones = phones\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 540,
"wires": [
[
"db6d955c039873be"
] ]
] ]
}, },
@ -23936,51 +23538,12 @@
"mustacheAltTags": false, "mustacheAltTags": false,
"outputProperties": [], "outputProperties": [],
"queue": "none", "queue": "none",
"x": 1170, "x": 490,
"y": 540, "y": 400,
"wires": [ "wires": [
[] []
] ]
}, },
{
"id": "e3ef7fe6bcad3b74",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "Title",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_text.text_notification_title",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "title",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 290,
"y": 580,
"wires": [
[
"95652a59518e2767"
]
]
},
{ {
"id": "d2fec32d385dae8c", "id": "d2fec32d385dae8c",
"type": "api-call-service", "type": "api-call-service",
@ -24004,9 +23567,11 @@
"outputProperties": [], "outputProperties": [],
"queue": "none", "queue": "none",
"x": 350, "x": 350,
"y": 640, "y": 540,
"wires": [ "wires": [
[] [
"0145961e8276c53e"
]
] ]
}, },
{ {
@ -24031,10 +23596,12 @@
"mustacheAltTags": false, "mustacheAltTags": false,
"outputProperties": [], "outputProperties": [],
"queue": "none", "queue": "none",
"x": 350, "x": 530,
"y": 700, "y": 540,
"wires": [ "wires": [
[] [
"fd623c46a558a01a"
]
] ]
}, },
{ {
@ -24060,29 +23627,11 @@
"mustacheAltTags": false, "mustacheAltTags": false,
"outputProperties": [], "outputProperties": [],
"queue": "none", "queue": "none",
"x": 360, "x": 720,
"y": 760, "y": 540,
"wires": [
[]
]
},
{
"id": "926fc60ea00ddfb0",
"type": "function",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "Formatting",
"func": "const str = msg.tvs\nvar tvs = str.replaceAll(\" \", \"_\")\nvar tvLower = tvs.toLowerCase()\n\nmsg.tvs = tvLower\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 990,
"y": 620,
"wires": [ "wires": [
[ [
"c52cae79eb97bcc0" "6b039ef7895476e2"
] ]
] ]
}, },
@ -24106,52 +23655,12 @@
"mustacheAltTags": false, "mustacheAltTags": false,
"outputProperties": [], "outputProperties": [],
"queue": "none", "queue": "none",
"x": 1160, "x": 480,
"y": 620, "y": 480,
"wires": [ "wires": [
[] []
] ]
}, },
{
"id": "b2d2662449cd647d",
"type": "api-current-state",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "Priority",
"server": "9e87348d.9c1c48",
"version": 3,
"outputs": 1,
"halt_if": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_select.text_notification_priority_level",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "priority",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 600,
"y": 580,
"wires": [
[
"3d5448e57ef666a0",
"5de6d772e1ecdd22"
]
]
},
{ {
"id": "6b039ef7895476e2", "id": "6b039ef7895476e2",
"type": "api-call-service", "type": "api-call-service",
@ -24174,8 +23683,8 @@
"mustacheAltTags": false, "mustacheAltTags": false,
"outputProperties": [], "outputProperties": [],
"queue": "none", "queue": "none",
"x": 360, "x": 920,
"y": 820, "y": 540,
"wires": [ "wires": [
[] []
] ]
@ -24187,10 +23696,53 @@
"g": "50e4d951ee7b3e54", "g": "50e4d951ee7b3e54",
"name": "Create Task", "name": "Create Task",
"info": "", "info": "",
"x": 930, "x": 630,
"y": 260, "y": 240,
"wires": [] "wires": []
}, },
{
"id": "f4bfbaca4d7fb1df",
"type": "function",
"z": "ee67610b4a0578d2",
"g": "477e752fcd2e2a19",
"name": "Processing",
"func": "var states = global.get('homeassistant.homeAssistant.states')\nvar message = states['input_text.tts_message'].state\nvar who = states['input_select.tts_devices'].state\nvar voice = states['input_select.announcement_voice'].state\n\nmsg.payload = message\nmsg.topic = who\nmsg.voice = voice\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 290,
"y": 80,
"wires": [
[
"93b7bee28a7e896e"
]
]
},
{
"id": "f44427c5a493c428",
"type": "function",
"z": "ee67610b4a0578d2",
"g": "5595964c8367c984",
"name": "Processing",
"func": "var states = global.get('homeassistant.homeAssistant.states')\nvar title = states['input_text.text_notification_title'].state\nvar message = states['input_text.text_notification'].state\nvar priority = states['input_select.text_notification_priority_level'].state\nvar phones = states['input_select.select_phones'].state.toLowerCase()\nvar tvs = states['input_select.select_tvs'].state.toLowerCase()\n\nvar phoneMsg = {\n \"title\": title,\n \"payload\": message,\n \"priority\": priority,\n \"phones\": phones\n}\nvar tvsMsg = {\n \"title\": title,\n \"payload\": message,\n \"priority\": priority,\n \"tvs\": tvs\n}\n\nif (phones != 'none' && tvs != 'none') {\n return[phoneMsg,tvsMsg]\n} else if (phones === 'none' && tvs != 'none') {\n return[null,tvsMsg]\n} else if (phones != 'none' && tvs === 'none') {\n return[phoneMsg,null]\n} else {\n return null\n}",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 310,
"y": 440,
"wires": [
[
"db6d955c039873be"
],
[
"c52cae79eb97bcc0"
]
]
},
{ {
"id": "5d7c63526234945e", "id": "5d7c63526234945e",
"type": "api-render-template", "type": "api-render-template",