From b55715d2a95d5833d822555503ef2e11e647188f Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Sat, 22 Mar 2025 19:40:51 -0400 Subject: [PATCH] Fix report system to work with Gitea #30 --- flows.json | 429 +++--------------------------------------------- flows_cred.json | 2 +- 2 files changed, 24 insertions(+), 407 deletions(-) diff --git a/flows.json b/flows.json index 45f3831..f4c6142 100644 --- a/flows.json +++ b/flows.json @@ -138,7 +138,7 @@ { "id": "873eb2575d6e9014", "type": "tab", - "label": "Github", + "label": "Gitea", "disabled": false, "info": "", "env": [] @@ -1750,17 +1750,15 @@ }, "nodes": [ "f803c6af3a30eb66", - "3bd7704103dbfc20", "a6234b2047ba3116", - "603140fef1e2edaf", "427cc2991454bbf0", "7674185d1e5ee489", "9e43408e18883dfe", - "0107164ee7ff63d6" + "84c8fd3cc1ab7cf1" ], "x": 34, "y": 19, - "w": 1072, + "w": 812, "h": 142 }, { @@ -3103,14 +3101,6 @@ "type": "add-todoist-api-token", "name": "Tony" }, - { - "id": "060e39a6519a8c4a", - "type": "github-api-config", - "appId": "377582", - "instId": "40829548", - "ua": "tm24fan8", - "name": "" - }, { "id": "1f10335891b41077", "type": "ha-device-config", @@ -3301,97 +3291,6 @@ "resend": false, "debugEnabled": false }, - { - "id": "accdce4dc47fb84a", - "type": "ha-device-config", - "name": "Github", - "hwVersion": "", - "manufacturer": "Node-RED", - "model": "", - "swVersion": "" - }, - { - "id": "cb877a8619b6d57e", - "type": "ha-entity-config", - "server": "9e87348d.9c1c48", - "deviceConfig": "accdce4dc47fb84a", - "name": "Github Main Repo - Issues", - "version": "6", - "entityType": "sensor", - "haConfig": [ - { - "property": "name", - "value": "Github Main Repo - Issues" - }, - { - "property": "icon", - "value": "mdi:github" - }, - { - "property": "entity_category", - "value": "" - }, - { - "property": "entity_picture", - "value": "" - }, - { - "property": "device_class", - "value": "" - }, - { - "property": "unit_of_measurement", - "value": "" - }, - { - "property": "state_class", - "value": "measurement" - } - ], - "resend": false, - "debugEnabled": false - }, - { - "id": "17a841239bc49473", - "type": "ha-entity-config", - "server": "9e87348d.9c1c48", - "deviceConfig": "accdce4dc47fb84a", - "name": "Node Red Repo - Issues", - "version": "6", - "entityType": "sensor", - "haConfig": [ - { - "property": "name", - "value": "Node Red Repo - Issues" - }, - { - "property": "icon", - "value": "mdi:github" - }, - { - "property": "entity_category", - "value": "" - }, - { - "property": "entity_picture", - "value": "" - }, - { - "property": "device_class", - "value": "" - }, - { - "property": "unit_of_measurement", - "value": "" - }, - { - "property": "state_class", - "value": "measurement" - } - ], - "resend": false, - "debugEnabled": false - }, { "id": "77c0d6f8dd47a65b", "type": "ha-entity-config", @@ -28578,37 +28477,17 @@ ] ] }, - { - "id": "3bd7704103dbfc20", - "type": "template", - "z": "873eb2575d6e9014", - "g": "50e4d951ee7b3e54", - "name": "", - "field": "payload", - "fieldType": "msg", - "format": "handlebars", - "syntax": "mustache", - "template": "{\n \"content\": \"{{text}}\",\n \"project_id\": 2285967948,\n \"section_id\": {{type}}\n}", - "output": "str", - "x": 840, - "y": 60, - "wires": [ - [ - "603140fef1e2edaf" - ] - ] - }, { "id": "a6234b2047ba3116", "type": "function", "z": "873eb2575d6e9014", "g": "50e4d951ee7b3e54", "name": "Processing", - "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst text = states['input_text.report_system'].state\nconst type = states['input_select.report_type'].state\nconst resetText = 'Type your report here'\nconst resetType = 'Bug Report'\n\nmsg.text = text\nmsg.typename = type\n\nmsg.reset_text = resetText\nmsg.reset_type = resetType\n\nif (type === \"New Idea\") {\n node.status({fill:\"green\",shape:\"dot\",text:\"New Idea\"});\n msg.type = \"114199257\"\n} else if (type === \"Bug Report\") {\n node.status({fill:\"green\",shape:\"dot\",text:\"Bug Report\"});\n msg.type = \"94865633\"\n}\nreturn msg;", + "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst text = states['input_text.report_system'].state\nconst type = states['input_select.report_type'].state\nconst resetText = 'Type your report here'\nconst resetType = 'Bug Report'\n\nmsg.text = text\nmsg.type = type\n\nmsg.reset_text = resetText\nmsg.reset_type = resetType\n\nif (type === \"New Idea\") {\n node.status({fill:\"green\",shape:\"dot\",text:\"New Idea\"})\n} else if (type === \"Bug Report\") {\n node.status({fill:\"green\",shape:\"dot\",text:\"Bug Report\"})\n} else if (type === \"Adjustment\") {\n node.status({fill:\"green\",shape:\"dot\",text:\"Adjustment\"})\n}\n\nreturn msg", "outputs": 1, "timeout": "", "noerr": 0, - "initialize": "", + "initialize": "const needsReponseLabel = 213\nconst typeBugLabel = 196\nconst typeEnhancementLabel = 198\nconst typeAdjustmentLabel = 208\n\nflow.set(\"needsReponseLabel\", needsReponseLabel, \"diskCon\")\nflow.set(\"typeBugLabel\", typeBugLabel, \"diskCon\")\nflow.set(\"typeEnhancementLabel\", typeEnhancementLabel, \"diskCon\")\nflow.set(\"typeAdjustmentLabel\", typeAdjustmentLabel, \"diskCon\")", "finalize": "", "libs": [], "x": 310, @@ -28621,20 +28500,6 @@ ], "icon": "node-red-contrib-cpu/cpu.png" }, - { - "id": "603140fef1e2edaf", - "type": "todoist-task-create", - "z": "873eb2575d6e9014", - "d": true, - "g": "50e4d951ee7b3e54", - "name": "", - "token": "81cb9d95d14a3e5a", - "x": 1010, - "y": 60, - "wires": [ - [] - ] - }, { "id": "427cc2991454bbf0", "type": "api-call-service", @@ -28664,9 +28529,7 @@ "x": 670, "y": 60, "wires": [ - [ - "3bd7704103dbfc20" - ] + [] ] }, { @@ -28709,7 +28572,7 @@ "z": "873eb2575d6e9014", "g": "50e4d951ee7b3e54", "name": "Prep API data", - "func": "const title = msg.text\nconst type = msg.typename\n\nlet labels = {}\n\nif (type === 'Bug Report') {\n labels = [\"bug\",\"needs-response\"]\n} else if (type === 'New Idea') {\n labels = [\"enhancement\",\"needs-response\"]\n}\n\nmsg.payload = {\n \"title\": title,\n \"assignees\":[\"tm24fan8\"],\n \"labels\":labels\n}\n\nreturn msg;", + "func": "const needsReponseLabel = flow.get(\"needsReponseLabel\", \"diskCon\")\nconst typeBugLabel = flow.get(\"typeBugLabel\", \"diskCon\")\nconst typeEnhancementLabel = flow.get(\"typeEnhancementLabel\", \"diskCon\")\nconst typeAdjustmentLabel = flow.get(\"typeAdjustmentLabel\", \"diskCon\")\nconst title = msg.text\nconst type = msg.type\n\nlet labels = [needsReponseLabel]\nlet formatType = {}\n\nif (type === 'Bug Report') {\n labels.push(typeBugLabel)\n formatType = \"[Bug]\"\n} else if (type === 'New Idea') {\n labels.push(typeEnhancementLabel)\n formatType = \"[Feature Request]\"\n} else if (type === 'Adjustment') {\n labels.push(typeAdjustmentLabel)\n formatType = \"[Adjustment Request]\"\n}\n\nlet newTitle = `${formatType}: ${title}`\n\nmsg.payload = {\n \"title\": newTitle,\n \"body\": \"This issue was submitted by the automated form on the main Home Assistant dashboard\",\n \"assignees\":[\"tm24fan8\"],\n \"labels\": labels\n}\n\nnode.status({fill:'green',shape:'dot',text:'API data prepped'})\nreturn msg", "outputs": 1, "timeout": "", "noerr": 0, @@ -28720,279 +28583,33 @@ "y": 120, "wires": [ [ - "0107164ee7ff63d6" + "84c8fd3cc1ab7cf1" ] ] }, { - "id": "0107164ee7ff63d6", - "type": "github-rest-api", + "id": "84c8fd3cc1ab7cf1", + "type": "http request", "z": "873eb2575d6e9014", "g": "50e4d951ee7b3e54", - "mediaType": "", - "endpoint": "POST /repos/tm24fan8/home-assistant-configs/issues", - "client": "060e39a6519a8c4a", - "name": "Post Issue", - "x": 670, + "name": "Gitea HTTP Request", + "method": "POST", + "ret": "obj", + "paytoqs": "ignore", + "url": "https://gitea.nerdhomeinc.com/api/v1/repos/home_automation/Home-Assistant-Configs/issues", + "tls": "", + "persist": false, + "proxy": "", + "insecureHTTPParser": false, + "authType": "basic", + "senderr": false, + "headers": [], + "x": 720, "y": 120, "wires": [ [] ] }, - { - "id": "e87dcfb1c693cd8e", - "type": "github-rest-api", - "z": "873eb2575d6e9014", - "mediaType": "", - "endpoint": "GET /repos/tm24fan8/home-assistant-configs/issues", - "client": "060e39a6519a8c4a", - "name": "Get Issues", - "x": 550, - "y": 260, - "wires": [ - [ - "d83e7b89126fdda1" - ] - ] - }, - { - "id": "10799a25d9271ce9", - "type": "function", - "z": "873eb2575d6e9014", - "name": "Prep API data", - "func": "let mainIssues = []\nlet nodeRedIssues = []\n\nflow.set(\"mainIssues\", mainIssues)\nflow.set(\"nodeRedIssues\", nodeRedIssues)\n\nmsg.payload = {\n \"state\":\"open\"\n}\n\nnode.status({fill:\"green\",shape:\"dot\",text:\"Sent\"})\nnode.send(msg)", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 340, - "y": 260, - "wires": [ - [ - "e87dcfb1c693cd8e" - ] - ] - }, - { - "id": "e2feabccad273758", - "type": "inject", - "z": "873eb2575d6e9014", - "name": "", - "props": [ - { - "p": "payload" - } - ], - "repeat": "", - "crontab": "", - "once": false, - "onceDelay": 0.1, - "topic": "", - "payload": "", - "payloadType": "date", - "x": 160, - "y": 260, - "wires": [ - [ - "10799a25d9271ce9" - ] - ] - }, - { - "id": "c96fb11627e0443d", - "type": "debug", - "z": "873eb2575d6e9014", - "name": "debug 30", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1140, - "y": 260, - "wires": [] - }, - { - "id": "7d3d014112db6fc4", - "type": "github-rest-api", - "z": "873eb2575d6e9014", - "mediaType": "", - "endpoint": "GET /repos/tm24fan8/ha-nerdflows/issues", - "client": "060e39a6519a8c4a", - "name": "Get Issues", - "x": 550, - "y": 320, - "wires": [ - [ - "c7bca169476e414e" - ] - ] - }, - { - "id": "d83e7b89126fdda1", - "type": "function", - "z": "873eb2575d6e9014", - "name": "function 2", - "func": "const payload = msg.payload\n\nlet mainIssues = []\n\nfor (let index = 0; index < payload.length; index++) {\n const element = payload[index];\n mainIssues.push(element.title)\n}\n\nmsg = {\n \"payload\": mainIssues.length,\n \"issues\": mainIssues.join(\", \")\n}\n\nnode.send(msg)", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 720, - "y": 260, - "wires": [ - [ - "076ecbfdb485ce9d" - ] - ] - }, - { - "id": "c7bca169476e414e", - "type": "function", - "z": "873eb2575d6e9014", - "name": "function 3", - "func": "const payload = msg.payload\n\nlet nodeRedIssues = []\n\nfor (let index = 0; index < payload.length; index++) {\n const element = payload[index];\n nodeRedIssues.push(element.title)\n}\n\nmsg = {\n \"payload\": nodeRedIssues.length,\n \"issues\": nodeRedIssues.join(\", \")\n}\n\nnode.send(msg)", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 720, - "y": 320, - "wires": [ - [ - "48f048636995cd6d" - ] - ] - }, - { - "id": "3a2dc7c13636cf4c", - "type": "function", - "z": "873eb2575d6e9014", - "name": "Prep API data", - "func": "let mainIssues = []\nlet nodeRedIssues = []\n\nflow.set(\"mainIssues\", mainIssues)\nflow.set(\"nodeRedIssues\", nodeRedIssues)\n\nmsg.payload = {\n \"state\":\"open\"\n}\n\nnode.status({fill:\"green\",shape:\"dot\",text:\"Sent\"})\nnode.send(msg)", - "outputs": 1, - "noerr": 0, - "initialize": "", - "finalize": "", - "libs": [], - "x": 340, - "y": 320, - "wires": [ - [ - "7d3d014112db6fc4" - ] - ] - }, - { - "id": "e84f9fb1779bf3f3", - "type": "inject", - "z": "873eb2575d6e9014", - "name": "", - "props": [ - { - "p": "payload" - } - ], - "repeat": "", - "crontab": "", - "once": false, - "onceDelay": 0.1, - "topic": "", - "payload": "", - "payloadType": "date", - "x": 160, - "y": 320, - "wires": [ - [ - "3a2dc7c13636cf4c" - ] - ] - }, - { - "id": "61e2d25bbe5011c4", - "type": "debug", - "z": "873eb2575d6e9014", - "name": "debug 31", - "active": true, - "tosidebar": true, - "console": false, - "tostatus": false, - "complete": "true", - "targetType": "full", - "statusVal": "", - "statusType": "auto", - "x": 1140, - "y": 320, - "wires": [] - }, - { - "id": "076ecbfdb485ce9d", - "type": "ha-sensor", - "z": "873eb2575d6e9014", - "name": "Main Repo Issues", - "entityConfig": "cb877a8619b6d57e", - "version": 0, - "state": "payload", - "stateType": "msg", - "attributes": [ - { - "property": "issues", - "value": "issues", - "valueType": "msg" - } - ], - "inputOverride": "allow", - "outputProperties": [], - "x": 930, - "y": 260, - "wires": [ - [ - "c96fb11627e0443d" - ] - ] - }, - { - "id": "48f048636995cd6d", - "type": "ha-sensor", - "z": "873eb2575d6e9014", - "name": "Node Red Repo - Issues", - "entityConfig": "17a841239bc49473", - "version": 0, - "state": "payload", - "stateType": "msg", - "attributes": [ - { - "property": "issues", - "value": "issues", - "valueType": "msg" - } - ], - "inputOverride": "allow", - "outputProperties": [], - "x": 950, - "y": 320, - "wires": [ - [ - "61e2d25bbe5011c4" - ] - ] - }, - { - "id": "f5d10b016afa6391", - "type": "comment", - "z": "873eb2575d6e9014", - "name": "Figure out how to get this data into a more presentable format", - "info": "", - "x": 640, - "y": 380, - "wires": [] - }, { "id": "5d7c63526234945e", "type": "api-render-template", diff --git a/flows_cred.json b/flows_cred.json index 9bbfe10..2b4c696 100644 --- a/flows_cred.json +++ b/flows_cred.json @@ -1,3 +1,3 @@ { - "$": "d37d16ff47af182904aefcb183e5f21fb7LCWDp4tnRaCWkjhi9Tmtt7fqCvGOKKdH0EDbVAHJ+L7K71DkexKgaKvgcIrbehQxGflGe5efbkNeYJ9wfSy8oMps1Pg8fZBG4NDkh0SpplNh5tEtBz2FBYCeyu6nwUXxWIVG+v52L66RbI1fsax8k7/dSKXUOojsoGyli4D1ApiNNeIga+u/KPR8lPU9+4Uus0ObQBBlhZ0zTZq5nEqk/HwIl6jCKiLDTbaTfXyTIDcFz4hcdOz6Nj/Pb02czI551X0oG+9JIhCJsHz5RuaUu6oN053xZk3AsFbmpI3/zuIUzIif8UH/21WWYKb31kiIdKZ7s6/lTH31ao+S0+ZSQ71Ykv2zvN6zUvE4xQAUxdPV630pHm7d1QNSkIJ9RC5DlnB9bHir1rjlNa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