Advertisement
pmfernandes

Alexa - Radio Information

Jan 18th, 2021
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 7.90 KB | None | 0 0
  1. [
  2.   {
  3.     "id": "7e91b034.b1648",
  4.     "type": "www-request",
  5.     "z": "6af9e1fe.dad98",
  6.     "name": "Download Details",
  7.     "method": "GET",
  8.     "ret": "txt",
  9.     "url": "",
  10.     "follow-redirects": true,
  11.     "persistent-http": true,
  12.     "tls": "",
  13.     "x": 970,
  14.     "y": 280,
  15.     "wires": [
  16.       [
  17.         "67bfe62a.eb5338"
  18.       ]
  19.     ]
  20.   },
  21.   {
  22.     "id": "67bfe62a.eb5338",
  23.     "type": "xml",
  24.     "z": "6af9e1fe.dad98",
  25.     "name": "",
  26.     "property": "payload",
  27.     "attr": "$",
  28.     "chr": "",
  29.     "x": 1150,
  30.     "y": 280,
  31.     "wires": [
  32.       [
  33.         "61acb0f1.a4281"
  34.       ]
  35.     ]
  36.   },
  37.   {
  38.     "id": "61acb0f1.a4281",
  39.     "type": "function",
  40.     "z": "6af9e1fe.dad98",
  41.     "name": "Handle XML",
  42.     "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;",
  43.     "outputs": 1,
  44.     "noerr": 0,
  45.     "initialize": "",
  46.     "finalize": "",
  47.     "x": 1310,
  48.     "y": 280,
  49.     "wires": [
  50.       [
  51.         "4cd18af0.653dc4",
  52.         "5ec1edc1.e72fb4"
  53.       ]
  54.     ]
  55.   },
  56.   {
  57.     "id": "455b9287.4c32fc",
  58.     "type": "server-state-changed",
  59.     "z": "6af9e1fe.dad98",
  60.     "name": "Radio On",
  61.     "server": "55430927.517ce8",
  62.     "version": 1,
  63.     "exposeToHomeAssistant": false,
  64.     "haConfig": [
  65.       {
  66.         "property": "name",
  67.         "value": ""
  68.       },
  69.       {
  70.         "property": "icon",
  71.         "value": ""
  72.       }
  73.     ],
  74.     "entityidfilter": "media_player.pmfernandes_s_echo_dot",
  75.     "entityidfiltertype": "exact",
  76.     "outputinitially": false,
  77.     "state_type": "str",
  78.     "haltifstate": "playing",
  79.     "halt_if_type": "str",
  80.     "halt_if_compare": "is",
  81.     "outputs": 2,
  82.     "output_only_on_state_change": false,
  83.     "for": 0,
  84.     "forType": "num",
  85.     "forUnits": "minutes",
  86.     "ignorePrevStateNull": false,
  87.     "ignorePrevStateUnknown": false,
  88.     "ignorePrevStateUnavailable": false,
  89.     "ignoreCurrentStateUnknown": false,
  90.     "ignoreCurrentStateUnavailable": false,
  91.     "x": 80,
  92.     "y": 340,
  93.     "wires": [
  94.       [
  95.         "568314f6.7133ec"
  96.       ],
  97.       [
  98.         "3fbbe837.59f468"
  99.       ]
  100.     ]
  101.   },
  102.   {
  103.     "id": "3fbbe837.59f468",
  104.     "type": "function",
  105.     "z": "6af9e1fe.dad98",
  106.     "name": "Stop Loop",
  107.     "func": "msg.payload = \"stop\";\n\nreturn msg;",
  108.     "outputs": 1,
  109.     "noerr": 0,
  110.     "initialize": "",
  111.     "finalize": "",
  112.     "x": 270,
  113.     "y": 400,
  114.     "wires": [
  115.       [
  116.         "c9ba5027.d8cfb",
  117.         "568314f6.7133ec"
  118.       ]
  119.     ]
  120.   },
  121.   {
  122.     "id": "a088b594.9cf488",
  123.     "type": "switch",
  124.     "z": "6af9e1fe.dad98",
  125.     "name": "Check Radio",
  126.     "property": "data.new_state.attributes.media_title",
  127.     "propertyType": "msg",
  128.     "rules": [
  129.       {
  130.         "t": "btwn",
  131.         "v": "Radio Comercial",
  132.         "vt": "str",
  133.         "v2": "Cidade fm",
  134.         "v2t": "str"
  135.       },
  136.       {
  137.         "t": "else"
  138.       }
  139.     ],
  140.     "checkall": "true",
  141.     "repair": false,
  142.     "outputs": 2,
  143.     "x": 490,
  144.     "y": 280,
  145.     "wires": [
  146.       [
  147.         "8ce86cf3.0e031"
  148.       ],
  149.       [
  150.         "3fbbe837.59f468"
  151.       ]
  152.     ]
  153.   },
  154.   {
  155.     "id": "8ce86cf3.0e031",
  156.     "type": "function",
  157.     "z": "6af9e1fe.dad98",
  158.     "name": "MediaCapial - Get BaseHost",
  159.     "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;",
  160.     "outputs": 1,
  161.     "noerr": 0,
  162.     "initialize": "",
  163.     "finalize": "",
  164.     "x": 720,
  165.     "y": 280,
  166.     "wires": [
  167.       [
  168.         "7e91b034.b1648"
  169.       ]
  170.     ]
  171.   },
  172.   {
  173.     "id": "568314f6.7133ec",
  174.     "type": "looptimer",
  175.     "z": "6af9e1fe.dad98",
  176.     "duration": "15",
  177.     "units": "Second",
  178.     "maxloops": "24000",
  179.     "maxtimeout": "10",
  180.     "maxtimeoutunits": "Hour",
  181.     "name": "",
  182.     "x": 300,
  183.     "y": 280,
  184.     "wires": [
  185.       [
  186.         "a088b594.9cf488"
  187.       ],
  188.       []
  189.     ]
  190.   },
  191.   {
  192.     "id": "c9ba5027.d8cfb",
  193.     "type": "function",
  194.     "z": "6af9e1fe.dad98",
  195.     "name": "Clean Radio Details",
  196.     "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;",
  197.     "outputs": 1,
  198.     "noerr": 0,
  199.     "initialize": "",
  200.     "finalize": "",
  201.     "x": 560,
  202.     "y": 400,
  203.     "wires": [
  204.       [
  205.         "4cd18af0.653dc4"
  206.       ]
  207.     ]
  208.   },
  209.   {
  210.     "id": "f2b2c0db.24e48",
  211.     "type": "mqtt out",
  212.     "z": "6af9e1fe.dad98",
  213.     "name": "Publish Image",
  214.     "topic": "radio/image",
  215.     "qos": "",
  216.     "retain": "true",
  217.     "broker": "501d6e11.e1d5e",
  218.     "x": 1700,
  219.     "y": 280,
  220.     "wires": []
  221.   },
  222.   {
  223.     "id": "4cd18af0.653dc4",
  224.     "type": "mqtt out",
  225.     "z": "6af9e1fe.dad98",
  226.     "name": "Publish Radio",
  227.     "topic": "",
  228.     "qos": "",
  229.     "retain": "",
  230.     "broker": "501d6e11.e1d5e",
  231.     "x": 1540,
  232.     "y": 400,
  233.     "wires": []
  234.   },
  235.   {
  236.     "id": "5ec1edc1.e72fb4",
  237.     "type": "www-request",
  238.     "z": "6af9e1fe.dad98",
  239.     "name": "Get Image",
  240.     "method": "GET",
  241.     "ret": "bin",
  242.     "url": "",
  243.     "follow-redirects": true,
  244.     "persistent-http": true,
  245.     "tls": "",
  246.     "x": 1490,
  247.     "y": 280,
  248.     "wires": [
  249.       [
  250.         "f2b2c0db.24e48"
  251.       ]
  252.     ]
  253.   },
  254.   {
  255.     "id": "55430927.517ce8",
  256.     "type": "server",
  257.     "name": "Home Assistant",
  258.     "legacy": false,
  259.     "addon": true,
  260.     "rejectUnauthorizedCerts": true,
  261.     "ha_boolean": "y|yes|true|on|home|open",
  262.     "connectionDelay": true,
  263.     "cacheJson": true
  264.   },
  265.   {
  266.     "id": "501d6e11.e1d5e",
  267.     "type": "mqtt-broker",
  268.     "name": "HomeAssistant",
  269.     "broker": "localhost",
  270.     "port": "1883",
  271.     "clientid": "",
  272.     "usetls": false,
  273.     "compatmode": false,
  274.     "keepalive": "60",
  275.     "cleansession": true,
  276.     "birthTopic": "",
  277.     "birthQos": "0",
  278.     "birthPayload": "",
  279.     "closeTopic": "",
  280.     "closeQos": "0",
  281.     "closePayload": "",
  282.     "willTopic": "",
  283.     "willQos": "0",
  284.     "willPayload": ""
  285.   }
  286. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement