Last active
January 24, 2021 15:59
-
-
Save Luc3as/4c07d6aeec94706365c8fa1ca60a6ba4 to your computer and use it in GitHub Desktop.
NodeRED Flow pre vytiahnutie URL posledneho radiozurnalu RTVS, vysledok je sensor v HomeAssistant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "ead32ffc.71b4f", | |
"type": "tab", | |
"label": "Správy RTVS", | |
"disabled": false, | |
"info": "" | |
}, | |
{ | |
"id": "ffb87676.f49f98", | |
"type": "inject", | |
"z": "ead32ffc.71b4f", | |
"name": "Obnov URL", | |
"props": [ | |
{ | |
"p": "url", | |
"v": "https://www.rtvs.sk/radio/archiv?date=&ord=dt", | |
"vt": "str" | |
} | |
], | |
"repeat": "", | |
"crontab": "*/5 6-22 * * *", | |
"once": false, | |
"onceDelay": 0.1, | |
"topic": "", | |
"x": 110, | |
"y": 80, | |
"wires": [ | |
[ | |
"e4da34a.7e783c8" | |
] | |
] | |
}, | |
{ | |
"id": "45057253.1848ec", | |
"type": "debug", | |
"z": "ead32ffc.71b4f", | |
"name": "Dnesny", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"targetType": "full", | |
"statusVal": "", | |
"statusType": "auto", | |
"x": 680, | |
"y": 200, | |
"wires": [] | |
}, | |
{ | |
"id": "e4da34a.7e783c8", | |
"type": "http request", | |
"z": "ead32ffc.71b4f", | |
"name": "Zoznam relaci dnes", | |
"method": "GET", | |
"ret": "txt", | |
"paytoqs": "ignore", | |
"url": "", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"authType": "", | |
"x": 310, | |
"y": 120, | |
"wires": [ | |
[ | |
"b553750c.206488" | |
] | |
] | |
}, | |
{ | |
"id": "b553750c.206488", | |
"type": "function", | |
"z": "ead32ffc.71b4f", | |
"name": "Vytiahni posledny radiozurnal", | |
"func": "if (msg.payload !== \"\" && msg.payload !== null) {\n \n let regexRelacia = /(?<=title=\"Rádiožurnál .*? href=\")(.*?)(?=\")/gi;\n let urlRelacie = msg.payload.match(regexRelacia);\n \n if (urlRelacie !== \"\" && urlRelacie !== null) { // Mame nejaky dnesny zurnal\n msg.vsetkyZurnale = urlRelacie;\n msg.najnovsiZurnal = \"https://www.rtvs.sk\" + urlRelacie[urlRelacie.length - 1] ;\n \n return [msg,null];\n } else { // Nemame dnesny zurnal , skoc o den spat\n delete msg;\n msg = {};\n date = new Date();\n date.setDate(date.getDate() - 1)\n year = date.getFullYear()\n month = (\"0\" + (date.getMonth() + 1)).slice(-2)\n day = (\"0\" + date.getDate()).slice(-2);\n \n msg.url = \"https://www.rtvs.sk/radio/archiv?date=\" + year + \"-\" + month + \"-\" + day + \"&ord=dt\";\n \n return [null, msg];\n }\n}", | |
"outputs": 2, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"x": 340, | |
"y": 220, | |
"wires": [ | |
[ | |
"45057253.1848ec", | |
"cd2fc024.b10ed" | |
], | |
[ | |
"14da5f5e.91cee1", | |
"527c8ccd.169574" | |
] | |
] | |
}, | |
{ | |
"id": "c43690ec.2a83a", | |
"type": "http request", | |
"z": "ead32ffc.71b4f", | |
"name": "Najnovsi zurnal", | |
"method": "GET", | |
"ret": "txt", | |
"paytoqs": "ignore", | |
"url": "", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"authType": "", | |
"x": 300, | |
"y": 340, | |
"wires": [ | |
[ | |
"6f42a90.a012458" | |
] | |
] | |
}, | |
{ | |
"id": "cd2fc024.b10ed", | |
"type": "change", | |
"z": "ead32ffc.71b4f", | |
"name": "Daj URL", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "url", | |
"pt": "msg", | |
"to": "najnovsiZurnal", | |
"tot": "msg" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 280, | |
"y": 280, | |
"wires": [ | |
[ | |
"c43690ec.2a83a" | |
] | |
] | |
}, | |
{ | |
"id": "db9cc751.c8dcd8", | |
"type": "debug", | |
"z": "ead32ffc.71b4f", | |
"name": "Posledny", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"targetType": "full", | |
"statusVal": "", | |
"statusType": "auto", | |
"x": 680, | |
"y": 380, | |
"wires": [] | |
}, | |
{ | |
"id": "6f42a90.a012458", | |
"type": "function", | |
"z": "ead32ffc.71b4f", | |
"name": "Vytiahni subor radiozurnalu", | |
"func": "if (msg.payload !== \"\" && msg.payload !== null) {\n \n let regexRelacia = /(?<=var url = \"\\/\\/)(.*?)(?=&&)/i;\n let urlRelacie = msg.payload.match(regexRelacia);\n \n if (urlRelacie[0] !== \"\" && urlRelacie[0] !== null) {\n\n msg.najnovsiZurnal = urlRelacie[0] ;\n } \n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"initialize": "", | |
"finalize": "", | |
"x": 340, | |
"y": 400, | |
"wires": [ | |
[ | |
"db9cc751.c8dcd8", | |
"1c48cb98.c1bf54" | |
] | |
] | |
}, | |
{ | |
"id": "1c48cb98.c1bf54", | |
"type": "change", | |
"z": "ead32ffc.71b4f", | |
"name": "Daj URL", | |
"rules": [ | |
{ | |
"t": "set", | |
"p": "url", | |
"pt": "msg", | |
"to": "najnovsiZurnal", | |
"tot": "msg" | |
} | |
], | |
"action": "", | |
"property": "", | |
"from": "", | |
"to": "", | |
"reg": false, | |
"x": 280, | |
"y": 460, | |
"wires": [ | |
[ | |
"a9741212.87275" | |
] | |
] | |
}, | |
{ | |
"id": "a9741212.87275", | |
"type": "http request", | |
"z": "ead32ffc.71b4f", | |
"name": "Info o epizode", | |
"method": "GET", | |
"ret": "txt", | |
"paytoqs": "ignore", | |
"url": "", | |
"tls": "", | |
"persist": false, | |
"proxy": "", | |
"authType": "", | |
"x": 300, | |
"y": 520, | |
"wires": [ | |
[ | |
"c77d47f8.f6f908" | |
] | |
] | |
}, | |
{ | |
"id": "f72d4bfa.20f318", | |
"type": "debug", | |
"z": "ead32ffc.71b4f", | |
"name": "Final subor", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"targetType": "full", | |
"statusVal": "", | |
"statusType": "auto", | |
"x": 790, | |
"y": 500, | |
"wires": [] | |
}, | |
{ | |
"id": "c77d47f8.f6f908", | |
"type": "json", | |
"z": "ead32ffc.71b4f", | |
"name": "", | |
"property": "payload", | |
"action": "obj", | |
"pretty": true, | |
"x": 510, | |
"y": 520, | |
"wires": [ | |
[ | |
"f72d4bfa.20f318", | |
"16a57d77.67fd73" | |
] | |
] | |
}, | |
{ | |
"id": "16a57d77.67fd73", | |
"type": "ha-entity", | |
"z": "ead32ffc.71b4f", | |
"name": "Adresa správ RTVS", | |
"server": "74f8257b.77137c", | |
"version": 1, | |
"debugenabled": false, | |
"outputs": 1, | |
"entityType": "sensor", | |
"config": [ | |
{ | |
"property": "name", | |
"value": "Adresa správ RTVS" | |
}, | |
{ | |
"property": "device_class", | |
"value": "" | |
}, | |
{ | |
"property": "icon", | |
"value": "" | |
}, | |
{ | |
"property": "unit_of_measurement", | |
"value": "" | |
} | |
], | |
"state": "payload.playlist[0].sources[0].src", | |
"stateType": "msg", | |
"attributes": [ | |
{ | |
"property": "media_image", | |
"value": "payload.playlist[0].image", | |
"valueType": "msg" | |
} | |
], | |
"resend": true, | |
"outputLocation": "", | |
"outputLocationType": "none", | |
"inputOverride": "allow", | |
"x": 810, | |
"y": 540, | |
"wires": [ | |
[] | |
] | |
}, | |
{ | |
"id": "14da5f5e.91cee1", | |
"type": "debug", | |
"z": "ead32ffc.71b4f", | |
"name": "Vcerajsi", | |
"active": false, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"targetType": "full", | |
"statusVal": "", | |
"statusType": "auto", | |
"x": 680, | |
"y": 240, | |
"wires": [] | |
}, | |
{ | |
"id": "527c8ccd.169574", | |
"type": "delay", | |
"z": "ead32ffc.71b4f", | |
"name": "", | |
"pauseType": "rate", | |
"timeout": "5", | |
"timeoutUnits": "seconds", | |
"rate": "1", | |
"nbRateUnits": "1", | |
"rateUnits": "minute", | |
"randomFirst": "1", | |
"randomLast": "5", | |
"randomUnits": "seconds", | |
"drop": true, | |
"x": 110, | |
"y": 140, | |
"wires": [ | |
[ | |
"e4da34a.7e783c8" | |
] | |
] | |
}, | |
{ | |
"id": "74f8257b.77137c", | |
"type": "server", | |
"name": "Home Assistant", | |
"legacy": false, | |
"addon": true, | |
"rejectUnauthorizedCerts": true, | |
"ha_boolean": "y|yes|true|on|home|open", | |
"connectionDelay": true | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment