Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": "7e91b034.b1648",
- "type": "www-request",
- "z": "6af9e1fe.dad98",
- "name": "Download Details",
- "method": "GET",
- "ret": "txt",
- "url": "",
- "follow-redirects": true,
- "persistent-http": true,
- "tls": "",
- "x": 970,
- "y": 280,
- "wires": [
- [
- "67bfe62a.eb5338"
- ]
- ]
- },
- {
- "id": "67bfe62a.eb5338",
- "type": "xml",
- "z": "6af9e1fe.dad98",
- "name": "",
- "property": "payload",
- "attr": "$",
- "chr": "",
- "x": 1150,
- "y": 280,
- "wires": [
- [
- "61acb0f1.a4281"
- ]
- ]
- },
- {
- "id": "61acb0f1.a4281",
- "type": "function",
- "z": "6af9e1fe.dad98",
- "name": "Handle XML",
- "func": "$artist = msg.payload.RadioInfo.Table[0].DB_LEAD_ARTIST_NAME[0];\nif ($artist == \"\")\n{\n $artist = msg.payload.RadioInfo.Table[0].DB_RADIO_NAME[0];\n}\n\n$album = msg.payload.RadioInfo.Table[0].DB_ALBUM_NAME[0];\nif ($album == \"\")\n{\n $album = msg.payload.RadioInfo.Table[0].CLAIM[0];\n}\n\n$music = \"\";\nif (msg.payload.RadioInfo.Table[0].hasOwnProperty(\"DB_SONG_NAME\"))\n{\n $music = msg.payload.RadioInfo.Table[0].DB_SONG_NAME[0];\n}\nif ($music == \"\")\n{\n $music = msg.payload.RadioInfo.Table[0].DB_DALET_TITLE_NAME[0];\n}\n\n$image = msg.defaultImage;\n\n$imageValue = \"\";\nif (msg.payload.RadioInfo.Table[0].hasOwnProperty(\"DB_ALBUM_IMAGE\"))\n{\n $imageValue = msg.payload.RadioInfo.Table[0].DB_ALBUM_IMAGE[0];\n $alternativeImageValue = msg.payload.RadioInfo.Table[0].DB_ALT_COVER_IMAGE[0];\n}\n\n$alternativeImageValue = \"\";\nif (msg.payload.RadioInfo.Table[0].hasOwnProperty(\"DB_ALT_COVER_IMAGE\"))\n{\n $alternativeImageValue = msg.payload.RadioInfo.Table[0].DB_ALT_COVER_IMAGE[0];\n}\n\nif ($imageValue != \"\")\n{\n $image = msg.baseHost + \"upload/album/\" + $imageValue;\n}\n \nif ($imageValue == \"\" && $alternativeImageValue != \"\")\n{\n $image = msg.baseHost + $alternativeImageValue;\n}\n\nmsg.payload = \n{\n \"artist\":$artist, \n \"album\":$album, \n \"music\":$music,\n \"image\":$image\n};\n\nmsg.topic = \"radio/state\";\nmsg.retain = true;\nmsg.url = msg.payload.image;\n\nreturn msg;",
- "outputs": 1,
- "noerr": 0,
- "initialize": "",
- "finalize": "",
- "x": 1310,
- "y": 280,
- "wires": [
- [
- "4cd18af0.653dc4",
- "5ec1edc1.e72fb4"
- ]
- ]
- },
- {
- "id": "455b9287.4c32fc",
- "type": "server-state-changed",
- "z": "6af9e1fe.dad98",
- "name": "Radio On",
- "server": "55430927.517ce8",
- "version": 1,
- "exposeToHomeAssistant": false,
- "haConfig": [
- {
- "property": "name",
- "value": ""
- },
- {
- "property": "icon",
- "value": ""
- }
- ],
- "entityidfilter": "media_player.pmfernandes_s_echo_dot",
- "entityidfiltertype": "exact",
- "outputinitially": false,
- "state_type": "str",
- "haltifstate": "playing",
- "halt_if_type": "str",
- "halt_if_compare": "is",
- "outputs": 2,
- "output_only_on_state_change": false,
- "for": 0,
- "forType": "num",
- "forUnits": "minutes",
- "ignorePrevStateNull": false,
- "ignorePrevStateUnknown": false,
- "ignorePrevStateUnavailable": false,
- "ignoreCurrentStateUnknown": false,
- "ignoreCurrentStateUnavailable": false,
- "x": 80,
- "y": 340,
- "wires": [
- [
- "568314f6.7133ec"
- ],
- [
- "3fbbe837.59f468"
- ]
- ]
- },
- {
- "id": "3fbbe837.59f468",
- "type": "function",
- "z": "6af9e1fe.dad98",
- "name": "Stop Loop",
- "func": "msg.payload = \"stop\";\n\nreturn msg;",
- "outputs": 1,
- "noerr": 0,
- "initialize": "",
- "finalize": "",
- "x": 270,
- "y": 400,
- "wires": [
- [
- "c9ba5027.d8cfb",
- "568314f6.7133ec"
- ]
- ]
- },
- {
- "id": "a088b594.9cf488",
- "type": "switch",
- "z": "6af9e1fe.dad98",
- "name": "Check Radio",
- "property": "data.new_state.attributes.media_title",
- "propertyType": "msg",
- "rules": [
- {
- "t": "btwn",
- "v": "Radio Comercial",
- "vt": "str",
- "v2": "Cidade fm",
- "v2t": "str"
- },
- {
- "t": "else"
- }
- ],
- "checkall": "true",
- "repair": false,
- "outputs": 2,
- "x": 490,
- "y": 280,
- "wires": [
- [
- "8ce86cf3.0e031"
- ],
- [
- "3fbbe837.59f468"
- ]
- ]
- },
- {
- "id": "8ce86cf3.0e031",
- "type": "function",
- "z": "6af9e1fe.dad98",
- "name": "MediaCapial - Get BaseHost",
- "func": "if (msg.data.new_state.attributes.media_title == \"Radio Comercial\") {\n msg.baseHost = \"https://radiocomercial.iol.pt/\";\n msg.defaultImage = \"https://www.mcradios.pt/facebook/RadioComercial/images/webradios/webradiosRC_EMDIRETO.jpg\";\n}\n\nif (msg.data.new_state.attributes.media_title == \"Cidade fm\") {\n msg.baseHost = \"https://cidade.iol.pt/\";\n msg.defaultImage = \"https://cidade.iol.pt/images/logo_CIDADE_2020.png\";\n}\n\nif (msg.data.new_state.attributes.media_title == \"M80 Rádio\") {\n msg.baseHost = \"https://m80.iol.pt/\";\n msg.defaultImage = \"https://m80.iol.pt/upload/W/webradio-m80-fm1.jpg\";\n}\n\nmsg.url = msg.baseHost + \"nowplaying.xml\";\n\nreturn msg;",
- "outputs": 1,
- "noerr": 0,
- "initialize": "",
- "finalize": "",
- "x": 720,
- "y": 280,
- "wires": [
- [
- "7e91b034.b1648"
- ]
- ]
- },
- {
- "id": "568314f6.7133ec",
- "type": "looptimer",
- "z": "6af9e1fe.dad98",
- "duration": "15",
- "units": "Second",
- "maxloops": "24000",
- "maxtimeout": "10",
- "maxtimeoutunits": "Hour",
- "name": "",
- "x": 300,
- "y": 280,
- "wires": [
- [
- "a088b594.9cf488"
- ],
- []
- ]
- },
- {
- "id": "c9ba5027.d8cfb",
- "type": "function",
- "z": "6af9e1fe.dad98",
- "name": "Clean Radio Details",
- "func": "msg.payload = \n{\n \"artist\":\"Off\", \n \"album\":\"Off\", \n \"music\":\"Off\",\n};\n\nmsg.topic = \"radio/state\";\nmsg.retain = true;\nmsg.url = msg.payload.image;\n\nreturn msg;",
- "outputs": 1,
- "noerr": 0,
- "initialize": "",
- "finalize": "",
- "x": 560,
- "y": 400,
- "wires": [
- [
- "4cd18af0.653dc4"
- ]
- ]
- },
- {
- "id": "f2b2c0db.24e48",
- "type": "mqtt out",
- "z": "6af9e1fe.dad98",
- "name": "Publish Image",
- "topic": "radio/image",
- "qos": "",
- "retain": "true",
- "broker": "501d6e11.e1d5e",
- "x": 1700,
- "y": 280,
- "wires": []
- },
- {
- "id": "4cd18af0.653dc4",
- "type": "mqtt out",
- "z": "6af9e1fe.dad98",
- "name": "Publish Radio",
- "topic": "",
- "qos": "",
- "retain": "",
- "broker": "501d6e11.e1d5e",
- "x": 1540,
- "y": 400,
- "wires": []
- },
- {
- "id": "5ec1edc1.e72fb4",
- "type": "www-request",
- "z": "6af9e1fe.dad98",
- "name": "Get Image",
- "method": "GET",
- "ret": "bin",
- "url": "",
- "follow-redirects": true,
- "persistent-http": true,
- "tls": "",
- "x": 1490,
- "y": 280,
- "wires": [
- [
- "f2b2c0db.24e48"
- ]
- ]
- },
- {
- "id": "55430927.517ce8",
- "type": "server",
- "name": "Home Assistant",
- "legacy": false,
- "addon": true,
- "rejectUnauthorizedCerts": true,
- "ha_boolean": "y|yes|true|on|home|open",
- "connectionDelay": true,
- "cacheJson": true
- },
- {
- "id": "501d6e11.e1d5e",
- "type": "mqtt-broker",
- "name": "HomeAssistant",
- "broker": "localhost",
- "port": "1883",
- "clientid": "",
- "usetls": false,
- "compatmode": false,
- "keepalive": "60",
- "cleansession": true,
- "birthTopic": "",
- "birthQos": "0",
- "birthPayload": "",
- "closeTopic": "",
- "closeQos": "0",
- "closePayload": "",
- "willTopic": "",
- "willQos": "0",
- "willPayload": ""
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement