From daf56961312dce6ee02df5bb18bd2750d10f907b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Tue, 14 Nov 2023 21:06:56 +0100 Subject: [PATCH] Enhance JSON in apps.md for readability Hiding the big example in a `
` section and formatting the JSON properly. --- docs/apps.md | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 176 insertions(+), 2 deletions(-) diff --git a/docs/apps.md b/docs/apps.md index 097fd83f..be0cbfc3 100644 --- a/docs/apps.md +++ b/docs/apps.md @@ -25,10 +25,184 @@ https://flows.blueforcer.de/ [Node-RED](https://nodered.org/) serves as an ideal software solution for creating these applications. It is available as a standalone program or as a plugin for Home Assistant and ioBroker, allowing you to further enhance the capabilities of your AWTRIX Light system. -Here is a demo of an Youtube App as NodeRED Flow: +Here is a demo, please press the triangle to unfold. + +
+ Example for adding a Youtube App as NodeRED flow + ```json -[{"id":"2a59d30d07abe14f","type":"group","z":"54b42d8d.cda474","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["f0f17299.3736c","dc7878f9.4756c8","f234aae371d72680","555bb8624b88c9c3","69c388146e28049d","a349ade5a57f7537"],"x":34,"y":39,"w":892,"h":122},{"id":"f0f17299.3736c","type":"inject","z":"54b42d8d.cda474","g":"2a59d30d07abe14f","name":"","props":[],"repeat":"3600","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":130,"y":120,"wires":[["a349ade5a57f7537"]]},{"id":"dc7878f9.4756c8","type":"http request","z":"54b42d8d.cda474","g":"2a59d30d07abe14f","name":"","method":"GET","ret":"obj","paytoqs":"query","url":"https://youtube.googleapis.com/youtube/v3/channels","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":430,"y":120,"wires":[["f234aae371d72680"]]},{"id":"f234aae371d72680","type":"function","z":"54b42d8d.cda474","g":"2a59d30d07abe14f","name":"parser","func":"var json = msg.payload;\nvar subscriberCount = json.items[0].statistics.subscriberCount;\n\nmsg.payload = { \"text\": subscriberCount, \"icon\": 5029};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":120,"wires":[["555bb8624b88c9c3"]]},{"id":"555bb8624b88c9c3","type":"mqtt out","z":"54b42d8d.cda474","g":"2a59d30d07abe14f","name":"","topic":"ulanzi/custom/youtube","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"346df2a95aac5785","x":800,"y":120,"wires":[]},{"id":"69c388146e28049d","type":"comment","z":"54b42d8d.cda474","g":"2a59d30d07abe14f","name":"Youtube Follower","info":"Just enter your channelID and Youtube API key in the \"Data\" node and set your AWTRIX MQTT prefix.\nUses Icon 5029 (LM)","x":140,"y":80,"wires":[]},{"id":"a349ade5a57f7537","type":"function","z":"54b42d8d.cda474","g":"2a59d30d07abe14f","name":"Data","func":"msg.payload = { \"id\": \"UCpGLALzRO0uaasWTsm9M99w\", \"key\": \"XXX\", \"part\":\"statistics\"}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":120,"wires":[["dc7878f9.4756c8"]]},{"id":"346df2a95aac5785","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}] +[ + { + "id": "2a59d30d07abe14f", + "type": "group", + "z": "54b42d8d.cda474", + "style": { + "stroke": "#999999", + "stroke-opacity": "1", + "fill": "none", + "fill-opacity": "1", + "label": true, + "label-position": "nw", + "color": "#a4a4a4" + }, + "nodes": [ + "f0f17299.3736c", + "dc7878f9.4756c8", + "f234aae371d72680", + "555bb8624b88c9c3", + "69c388146e28049d", + "a349ade5a57f7537" + ], + "x": 34, + "y": 39, + "w": 892, + "h": 122 + }, + { + "id": "f0f17299.3736c", + "type": "inject", + "z": "54b42d8d.cda474", + "g": "2a59d30d07abe14f", + "name": "", + "props": [], + "repeat": "3600", + "crontab": "", + "once": true, + "onceDelay": 0.1, + "topic": "", + "x": 130, + "y": 120, + "wires": [ + [ + "a349ade5a57f7537" + ] + ] + }, + { + "id": "dc7878f9.4756c8", + "type": "http request", + "z": "54b42d8d.cda474", + "g": "2a59d30d07abe14f", + "name": "", + "method": "GET", + "ret": "obj", + "paytoqs": "query", + "url": "https://youtube.googleapis.com/youtube/v3/channels", + "tls": "", + "persist": false, + "proxy": "", + "insecureHTTPParser": false, + "authType": "", + "senderr": false, + "headers": [], + "x": 430, + "y": 120, + "wires": [ + [ + "f234aae371d72680" + ] + ] + }, + { + "id": "f234aae371d72680", + "type": "function", + "z": "54b42d8d.cda474", + "g": "2a59d30d07abe14f", + "name": "parser", + "func": "var json = msg.payload;\nvar subscriberCount = json.items[0].statistics.subscriberCount;\n\nmsg.payload = { \"text\": subscriberCount, \"icon\": 5029};\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 590, + "y": 120, + "wires": [ + [ + "555bb8624b88c9c3" + ] + ] + }, + { + "id": "555bb8624b88c9c3", + "type": "mqtt out", + "z": "54b42d8d.cda474", + "g": "2a59d30d07abe14f", + "name": "", + "topic": "ulanzi/custom/youtube", + "qos": "", + "retain": "", + "respTopic": "", + "contentType": "", + "userProps": "", + "correl": "", + "expiry": "", + "broker": "346df2a95aac5785", + "x": 800, + "y": 120, + "wires": [] + }, + { + "id": "69c388146e28049d", + "type": "comment", + "z": "54b42d8d.cda474", + "g": "2a59d30d07abe14f", + "name": "Youtube Follower", + "info": "Just enter your channelID and Youtube API key in the \"Data\" node and set your AWTRIX MQTT prefix.\nUses Icon 5029 (LM)", + "x": 140, + "y": 80, + "wires": [] + }, + { + "id": "a349ade5a57f7537", + "type": "function", + "z": "54b42d8d.cda474", + "g": "2a59d30d07abe14f", + "name": "Data", + "func": "msg.payload = { \"id\": \"UCpGLALzRO0uaasWTsm9M99w\", \"key\": \"XXX\", \"part\":\"statistics\"}\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 270, + "y": 120, + "wires": [ + [ + "dc7878f9.4756c8" + ] + ] + }, + { + "id": "346df2a95aac5785", + "type": "mqtt-broker", + "name": "", + "broker": "localhost", + "port": "1883", + "clientid": "", + "autoConnect": true, + "usetls": false, + "protocolVersion": "4", + "keepalive": "60", + "cleansession": true, + "birthTopic": "", + "birthQos": "0", + "birthPayload": "", + "birthMsg": {}, + "closeTopic": "", + "closeQos": "0", + "closePayload": "", + "closeMsg": {}, + "willTopic": "", + "willQos": "0", + "willPayload": "", + "willMsg": {}, + "userProps": "", + "sessionExpiry": "" + } +] ``` +
This Node-RED flow retrieves and displays the subscriber count of a specified YouTube channel on an AWTRIX light device. The flow consists of the following nodes: