Fix report system to work with Gitea

#30
This commit is contained in:
2025-03-22 19:40:51 -04:00
parent e1b910c3c9
commit b55715d2a9
2 changed files with 24 additions and 407 deletions

View File

@ -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",