This flow was submitted before accounts existed, so nobody owns it yet. If you submitted it, open the edit link you were given — it still works — and you can attach the flow to an account from there. There is no deadline, and attaching it retires the link for good.
Year progress
Shows the current progress of the year in %
| System | Node-RED |
|---|---|
| Firmware | AWTRIX 3 |
| Topic | Miscellaneous |
| Built by | Blueforcer |
| File | MYjJZA67oyrL.json · 3.2 KB |
| Icons | 1 |
| Published | 11 May 2023 · updated 11 May 2023 |
| Downloads | 37 |
Shows the current progress of the year in %.
You dont need any addtional settings. Just change your mqtt prefix or replace it with a http node .
MYjJZA67oyrL.json
[
{
"id": "cb8adff659c25a9b",
"type": "group",
"z": "54b42d8d.cda474",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"cff2934586245f16",
"b3c104ae61987f63",
"e0e75b8673550866"
],
"x": 34,
"y": 919,
"w": 652,
"h": 82
},
{
"id": "cff2934586245f16",
"type": "inject",
"z": "54b42d8d.cda474",
"g": "cb8adff659c25a9b",
"name": "",
"props": [],
"repeat": "3600",
"crontab": "",
"once": true,
"onceDelay": "5",
"topic": "",
"x": 130,
"y": 960,
"wires": [
[
"b3c104ae61987f63"
]
]
},
{
"id": "b3c104ae61987f63",
"type": "function",
"z": "54b42d8d.cda474",
"g": "cb8adff659c25a9b",
"name": "Calculation",
"func": "// Create current timestamp\nconst now = new Date();\n\n// Determine first day of current year\nconst startOfYear = new Date(now.getFullYear(), 0, 1);\n\n// Calculate difference in milliseconds between current timestamp and first day of year\nconst diffInMillis = now.getTime() - startOfYear.getTime();\n\n// Calculate total number of milliseconds in the year (including leap year)\nconst totalMillis = (now.getFullYear() % 4 === 0) ? 31622400000 : 31536000000;\n\n// Calculate percentage progress\nconst progress = Math.floor((diffInMillis / totalMillis) * 100);\n\nmsg.payload = {\"text\": progress + \"%\", \"icon\": \"y2023\"};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 310,
"y": 960,
"wires": [
[
"e0e75b8673550866"
]
]
},
{
"id": "e0e75b8673550866",
"type": "mqtt out",
"z": "54b42d8d.cda474",
"g": "cb8adff659c25a9b",
"name": "",
"topic": "awtrix/custom/yearprogress",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "346df2a95aac5785",
"x": 540,
"y": 960,
"wires": []
},
{
"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": ""
}
]
These icons belong on the device, in /ICONS. Each one is at
most 32×8
pixels — shown here magnified, at their real proportions.
8×8 px
More flows for Node-RED or Miscellaneous
Something wrong with this flow? Report it.