Skip to content

Commit

Permalink
Merge pull request #398 from rhuss/patch-1
Browse files Browse the repository at this point in the history
Enhance JSON in apps.md for readability
  • Loading branch information
Blueforcer authored Nov 19, 2023
2 parents 60a6ecc + daf5696 commit c647354
Showing 1 changed file with 176 additions and 2 deletions.
178 changes: 176 additions & 2 deletions docs/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details>
<summary>Example for adding a Youtube App as NodeRED flow</summary>

```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": ""
}
]
```
</details>

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:

Expand Down

0 comments on commit c647354

Please sign in to comment.