首頁 收藏 QQ群
 網(wǎng)站導(dǎo)航

ZNDS智能電視網(wǎng) 推薦當(dāng)貝市場

TV應(yīng)用下載 / 資源分享區(qū)

軟件下載 | 游戲 | 討論 | 電視計(jì)算器

綜合交流 / 評測 / 活動(dòng)區(qū)

交流區(qū) | 測硬件 | 網(wǎng)站活動(dòng) | Z幣中心

新手入門 / 進(jìn)階 / 社區(qū)互助

新手 | 你問我答 | 免費(fèi)刷機(jī)救磚 | ROM固件

查看: 190603|回復(fù): 32
上一主題 下一主題
[分享]

怎樣用小愛音箱控制電視 用小愛音箱控制電視播放任意影視

  [復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
發(fā)表于 2024-1-10 11:06 | 只看該作者 |只看大圖 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式 | 來自江西
除了播放音樂和控制智能家居設(shè)備外,小愛音箱還可以與電視進(jìn)行聯(lián)動(dòng),實(shí)現(xiàn)語音控制電視的功能。那么,如何利用小愛音箱來控制電視,并播放任意影視內(nèi)容呢?

首先說明,我實(shí)在群暉docker安裝的homeassistant和nodered,部署在其他服務(wù)器上的可參考修改。

1.本地部署小雅,具體怎么部署的自己搜嗶站,教程一大堆就不在重復(fù)。假設(shè)我部署的地址是:http://192.168.1.222:6789/
后邊代碼中這個(gè)地址改為你自己的

怎樣用小愛音箱控制電視 用小愛音箱控制電視播放任意影視

2.在homeassistant中將你家的電視通過dlna接入。

怎樣用小愛音箱控制電視 用小愛音箱控制電視播放任意影視

3.在群暉創(chuàng)建一個(gè)文件夾掛載 nodered的root目錄。

怎樣用小愛音箱控制電視 用小愛音箱控制電視播放任意影視

4.群暉開啟ssh,并進(jìn)入nodered容器內(nèi)部:

  1. docker exec -it nodered /bin/bash
復(fù)制代碼

怎樣用小愛音箱控制電視 用小愛音箱控制電視播放任意影視


我這里以新docker部署的nr為例

安裝http請求及解析需要的庫:

  1. python3 -m ensurepip --upgrade
  2. python3 -m pip install requests
  3. python3 -m pip install bs4
復(fù)制代碼

怎樣用小愛音箱控制電視 用小愛音箱控制電視播放任意影視


安裝完就可以到nr里邊操作了。

5.在nodered中,將我的流導(dǎo)入:并將第一步說的小雅的網(wǎng)址改為自己的

  1. [
  2.     {
  3.         "id": "ce7ae6436c0af95a",
  4.         "type": "file",
  5.         "z": "5641ce060432f122",
  6.         "name": "存儲(chǔ)在root目錄下",
  7.         "filename": "/root/查詢小雅電影url.py",
  8.         "filenameType": "str",
  9.         "appendNewline": true,
  10.         "createDir": true,
  11.         "overwriteFile": "true",
  12.         "encoding": "none",
  13.         "x": 430,
  14.         "y": 1740,
  15.         "wires": [
  16.             [
  17.                 "6d47d72d49f59618"
  18.             ]
  19.         ]
  20.     },
  21.     {
  22.         "id": "6d47d72d49f59618",
  23.         "type": "exec",
  24.         "z": "5641ce060432f122",
  25.         "command": "python3 /root/查詢小雅電影url.py",
  26.         "addpay": "payload",
  27.         "append": "",
  28.         "useSpawn": "false",
  29.         "timer": "",
  30.         "winHide": false,
  31.         "oldrc": false,
  32.         "name": "",
  33.         "x": 740,
  34.         "y": 1740,
  35.         "wires": [
  36.             [
  37.                 "05f6b97e57de70a4",
  38.                 "931f4e09ee722274"
  39.             ],
  40.             [],
  41.             []
  42.         ]
  43.     },
  44.     {
  45.         "id": "1b5f9bfbd0bce847",
  46.         "type": "api-call-service",
  47.         "z": "5641ce060432f122",
  48.         "name": "主臥電視",
  49.         "server": "598f8fe7bc05621b",
  50.         "version": 5,
  51.         "debugenabled": false,
  52.         "domain": "media_player",
  53.         "service": "play_media",
  54.         "areaId": [
  55.             "wo_shi"
  56.         ],
  57.         "deviceId": [],
  58.         "entityId": [
  59.             "media_player.zhu_wo_dian_shi"
  60.         ],
  61.         "data": "{\t   "media_content_id": msg.payload[0],\t   "media_content_type":"video",\t   "announce":"true"\t}",
  62.         "dataType": "jsonata",
  63.         "mergeContext": "",
  64.         "mustacheAltTags": false,
  65.         "outputProperties": [],
  66.         "queue": "none",
  67.         "x": 1680,
  68.         "y": 1700,
  69.         "wires": [
  70.             [
  71.                 "6ffd3c1403904fc6"
  72.             ]
  73.         ]
  74.     },
  75.     {
  76.         "id": "6ffd3c1403904fc6",
  77.         "type": "debug",
  78.         "z": "5641ce060432f122",
  79.         "name": "debug 18",
  80.         "active": true,
  81.         "tosidebar": true,
  82.         "console": false,
  83.         "tostatus": false,
  84.         "complete": "true",
  85.         "targetType": "full",
  86.         "statusVal": "",
  87.         "statusType": "auto",
  88.         "x": 1960,
  89.         "y": 1800,
  90.         "wires": []
  91.     },
  92.     {
  93.         "id": "2e0618eb53503ab3",
  94.         "type": "debug",
  95.         "z": "5641ce060432f122",
  96.         "name": "debug 20",
  97.         "active": true,
  98.         "tosidebar": true,
  99.         "console": false,
  100.         "tostatus": false,
  101.         "complete": "true",
  102.         "targetType": "full",
  103.         "statusVal": "",
  104.         "statusType": "auto",
  105.         "x": 1460,
  106.         "y": 1600,
  107.         "wires": []
  108.     },
  109.     {
  110.         "id": "030138d8effd759f",
  111.         "type": "template",
  112.         "z": "5641ce060432f122",
  113.         "name": "python 腳本",
  114.         "field": "payload",
  115.         "fieldType": "msg",
  116.         "format": "python",
  117.         "syntax": "mustache",
  118.         "template": "import requests\nfrom bs4 import BeautifulSoup\n\n# 定義URL\nurl = "http://192.168.1.222:6789/search?box={{payload}}&type=video&url="\n\n# 發(fā)送GET請求獲取頁面內(nèi)容\nresponse = requests.get(url)\n\n# 檢查響應(yīng)狀態(tài)碼\nif response.status_code == 200:\n    html = response.text\n\n    # 使用Beautiful Soup解析HTML\n    soup = BeautifulSoup(html, 'html.parser')\n\n    # 找到所有的<a>標(biāo)簽\n    a_tags = soup.find_all('a')\n\n    # 初始化路徑列表,用于存儲(chǔ)嘗試的路徑\n    paths_to_try = [a['href'] for a in a_tags[2:]]\n\n    # 用于記錄是否找到匹配的文件名\n    found = False\n\n    # 檢查列表中是否包含".mkv"或".mp4"的結(jié)果\n    for path in paths_to_try:\n        if ".mkv" in path or ".mp4" in path:\n            # 拼接新的URL\n            new_url = f"http://192.168.1.222:6789/d/{path}"\n            print(new_url)\n            found = True\n            break\n\n    if not found:\n        while paths_to_try and not found:\n            path = paths_to_try.pop(0)  # 彈出列表中的第一個(gè)路徑\n\n            # 定義URL\n            api_url = "http://192.168.1.222:6789/api/fs/list"\n\n            # 定義請求參數(shù)\n            params = {\n                "path": path,\n                "password": "",\n                "page": 1,\n                "per_page": 30,\n                "refresh": False\n            }\n\n            # 發(fā)送POST請求獲取JSON響應(yīng)\n            response = requests.post(api_url, json=params)\n\n            # 檢查響應(yīng)狀態(tài)碼\n            if response.status_code == 200:\n                data = response.json()\n\n                # 嘗試獲取content中的項(xiàng)目,如果出現(xiàn)異常則跳出當(dāng)前循環(huán)\n                try:\n                    content = data.get("data", {}).get("content")\n                except AttributeError:\n                   # print(f"在路徑 {path} 下發(fā)生異常,跳過該路徑")\n                    continue\n\n                if content is not None:\n                    # 查找第一個(gè)包含“.mp4”或“.mkv”的name\n                    found_name = None\n                    for item in content:\n                        name = item.get("name", "")\n                        if ".mp4" in name or ".mkv" in name:\n                            found_name = name\n                            break\n\n                    # 如果找到了匹配的name\n                    if found_name:\n                        # 拼接完整的網(wǎng)址\n                        full_url = f"http://192.168.1.222:6789/d/{path}/{found_name}"\n                        print(full_url)\n                        found = True\n                    else:\n                        print(f"在路徑 {path} 下未找到匹配的文件名")\n                else:\n                    print(f"JSON響應(yīng)中沒有'content'字段")\n            else:\n                print(f"無法訪問指定URL: {api_url}")\n\n        if not found:\n            print("沒有找到包含'.mp4'或'.mkv'的文件名")\nelse:\n    print("無法訪問指定URL")\n",
  119.         "output": "str",
  120.         "x": 210,
  121.         "y": 1760,
  122.         "wires": [
  123.             [
  124.                 "ce7ae6436c0af95a"
  125.             ]
  126.         ]
  127.     },
  128.     {
  129.         "id": "0e62fca7ed5d9b7b",
  130.         "type": "inject",
  131.         "z": "5641ce060432f122",
  132.         "name": "",
  133.         "props": [
  134.             {
  135.                 "p": "payload"
  136.             },
  137.             {
  138.                 "p": "topic",
  139.                 "vt": "str"
  140.             }
  141.         ],
  142.         "repeat": "",
  143.         "crontab": "",
  144.         "once": false,
  145.         "onceDelay": 0.1,
  146.         "topic": "",
  147.         "payload": "速度與激情10",
  148.         "payloadType": "str",
  149.         "x": 130,
  150.         "y": 1680,
  151.         "wires": [
  152.             [
  153.                 "030138d8effd759f"
  154.             ]
  155.         ]
  156.     },
  157.     {
  158.         "id": "05f6b97e57de70a4",
  159.         "type": "debug",
  160.         "z": "5641ce060432f122",
  161.         "name": "debug 21",
  162.         "active": true,
  163.         "tosidebar": true,
  164.         "console": false,
  165.         "tostatus": false,
  166.         "complete": "true",
  167.         "targetType": "full",
  168.         "statusVal": "",
  169.         "statusType": "auto",
  170.         "x": 940,
  171.         "y": 1840,
  172.         "wires": []
  173.     },
  174.     {
  175.         "id": "561da383e0140cab",
  176.         "type": "join",
  177.         "z": "5641ce060432f122",
  178.         "name": "",
  179.         "mode": "custom",
  180.         "build": "array",
  181.         "property": "payload",
  182.         "propertyType": "msg",
  183.         "key": "topic",
  184.         "joiner": "\\n",
  185.         "joinerType": "str",
  186.         "accumulate": false,
  187.         "timeout": "",
  188.         "count": "",
  189.         "reduceRight": false,
  190.         "reduceExp": "",
  191.         "reduceInit": "",
  192.         "reduceInitType": "",
  193.         "reduceFixup": "",
  194.         "x": 1230,
  195.         "y": 1720,
  196.         "wires": [
  197.             [
  198.                 "2e0618eb53503ab3",
  199.                 "081e66e145ad4ade",
  200.                 "65545ddaebf3e8a4"
  201.             ]
  202.         ]
  203.     },
  204.     {
  205.         "id": "c3e5a779dfee461f",
  206.         "type": "split",
  207.         "z": "5641ce060432f122",
  208.         "name": "",
  209.         "splt": "\\n",
  210.         "spltType": "str",
  211.         "arraySplt": 1,
  212.         "arraySpltType": "len",
  213.         "stream": false,
  214.         "addname": "",
  215.         "x": 1130,
  216.         "y": 1780,
  217.         "wires": [
  218.             [
  219.                 "561da383e0140cab"
  220.             ]
  221.         ]
  222.     },
  223.     {
  224.         "id": "4d24b8ce856620bf",
  225.         "type": "function",
  226.         "z": "5641ce060432f122",
  227.         "name": "function 10",
  228.         "func": "\nmsg.payload=encodeURI(msg.payload).slice(0, -3);\n\n\nreturn msg;",
  229.         "outputs": 1,
  230.         "timeout": 0,
  231.         "noerr": 0,
  232.         "initialize": "",
  233.         "finalize": "",
  234.         "libs": [],
  235.         "x": 1630,
  236.         "y": 1600,
  237.         "wires": [
  238.             [
  239.                 "1b5f9bfbd0bce847"
  240.             ]
  241.         ]
  242.     },
  243.     {
  244.         "id": "ef5d923092afd21d",
  245.         "type": "comment",
  246.         "z": "5641ce060432f122",
  247.         "name": "電影url",
  248.         "info": "",
  249.         "x": 110,
  250.         "y": 1600,
  251.         "wires": []
  252.     },
  253.     {
  254.         "id": "ebde0123b4902e43",
  255.         "type": "server-state-changed",
  256.         "z": "5641ce060432f122",
  257.         "name": "小愛對話",
  258.         "server": "598f8fe7bc05621b",
  259.         "version": 4,
  260.         "exposeToHomeAssistant": false,
  261.         "haConfig": [
  262.             {
  263.                 "property": "name",
  264.                 "value": ""
  265.             },
  266.             {
  267.                 "property": "icon",
  268.                 "value": ""
  269.             }
  270.         ],
  271.         "entityidfilter": "sensor.xiaomi_lx5a_7d9b_conversation",
  272.         "entityidfiltertype": "exact",
  273.         "outputinitially": false,
  274.         "state_type": "str",
  275.         "haltifstate": "",
  276.         "halt_if_type": "str",
  277.         "halt_if_compare": "is",
  278.         "outputs": 1,
  279.         "output_only_on_state_change": true,
  280.         "for": "0",
  281.         "forType": "num",
  282.         "forUnits": "minutes",
  283.         "ignorePreVSTateNull": false,
  284.         "ignorePrevStateUnknown": false,
  285.         "ignorePrevStateUnavailable": false,
  286.         "ignoreCurrentStateUnknown": false,
  287.         "ignoreCurrentStateUnavailable": false,
  288.         "outputProperties": [
  289.             {
  290.                 "property": "payload",
  291.                 "propertyType": "msg",
  292.                 "value": "",
  293.                 "valueType": "entityState"
  294.             },
  295.             {
  296.                 "property": "data",
  297.                 "propertyType": "msg",
  298.                 "value": "",
  299.                 "valueType": "eventData"
  300.             },
  301.             {
  302.                 "property": "topic",
  303.                 "propertyType": "msg",
  304.                 "value": "",
  305.                 "valueType": "triggerId"
  306.             }
  307.         ],
  308.         "x": 120,
  309.         "y": 2000,
  310.         "wires": [
  311.             [
  312.                 "2f2c89887be9e04e"
  313.             ]
  314.         ]
  315.     },
  316.     {
  317.         "id": "2f2c89887be9e04e",
  318.         "type": "switch",
  319.         "z": "5641ce060432f122",
  320.         "name": "我想看",
  321.         "property": "payload",
  322.         "propertyType": "msg",
  323.         "rules": [
  324.             {
  325.                 "t": "cont",
  326.                 "v": "我想看",
  327.                 "vt": "str"
  328.             },
  329.             {
  330.                 "t": "else"
  331.             }
  332.         ],
  333.         "checkall": "true",
  334.         "repair": false,
  335.         "outputs": 2,
  336.         "x": 310,
  337.         "y": 1980,
  338.         "wires": [
  339.             [
  340.                 "b028350e4a8ff48d",
  341.                 "2dc0658ed70d52dd"
  342.             ],
  343.             []
  344.         ]
  345.     },
  346.     {
  347.         "id": "b028350e4a8ff48d",
  348.         "type": "split",
  349.         "z": "5641ce060432f122",
  350.         "name": "",
  351.         "splt": "想看",
  352.         "spltType": "str",
  353.         "arraySplt": "1",
  354.         "arraySpltType": "len",
  355.         "stream": false,
  356.         "addname": "",
  357.         "x": 510,
  358.         "y": 1980,
  359.         "wires": [
  360.             [
  361.                 "2c27c3910bb47959"
  362.             ]
  363.         ]
  364.     },
  365.     {
  366.         "id": "2c27c3910bb47959",
  367.         "type": "join",
  368.         "z": "5641ce060432f122",
  369.         "name": "",
  370.         "mode": "custom",
  371.         "build": "array",
  372.         "property": "payload",
  373.         "propertyType": "msg",
  374.         "key": "topic",
  375.         "joiner": "\\n",
  376.         "joinerType": "str",
  377.         "accumulate": false,
  378.         "timeout": "",
  379.         "count": "",
  380.         "reduceRight": false,
  381.         "reduceExp": "",
  382.         "reduceInit": "",
  383.         "reduceInitType": "",
  384.         "reduceFixup": "",
  385.         "x": 670,
  386.         "y": 1980,
  387.         "wires": [
  388.             [
  389.                 "cfb73ae3d376c74a"
  390.             ]
  391.         ]
  392.     },
  393.     {
  394.         "id": "cfb73ae3d376c74a",
  395.         "type": "function",
  396.         "z": "5641ce060432f122",
  397.         "name": "",
  398.         "func": "msg.payload = msg.payload[1]\n\nreturn msg;",
  399.         "outputs": 1,
  400.         "timeout": "",
  401.         "noerr": 0,
  402.         "initialize": "",
  403.         "finalize": "",
  404.         "libs": [],
  405.         "x": 790,
  406.         "y": 1980,
  407.         "wires": [
  408.             [
  409.                 "030138d8effd759f",
  410.                 "f4f391a64858ac59"
  411.             ]
  412.         ]
  413.     },
  414.     {
  415.         "id": "df9356cc80c6bfb0",
  416.         "type": "inject",
  417.         "z": "5641ce060432f122",
  418.         "name": "",
  419.         "props": [
  420.             {
  421.                 "p": "payload"
  422.             },
  423.             {
  424.                 "p": "topic",
  425.                 "vt": "str"
  426.             }
  427.         ],
  428.         "repeat": "",
  429.         "crontab": "",
  430.         "once": false,
  431.         "onceDelay": 0.1,
  432.         "topic": "",
  433.         "payload": "我想看我和我的祖國",
  434.         "payloadType": "str",
  435.         "x": 210,
  436.         "y": 2100,
  437.         "wires": [
  438.             [
  439.                 "2f2c89887be9e04e"
  440.             ]
  441.         ]
  442.     },
  443.     {
  444.         "id": "2dc0658ed70d52dd",
  445.         "type": "xiaoai-mediaplayer",
  446.         "z": "5641ce060432f122",
  447.         "name": "",
  448.         "xiaoai": "09b787bdbe3ed75d",
  449.         "action": "pause",
  450.         "device": "",
  451.         "x": 550,
  452.         "y": 2100,
  453.         "wires": [
  454.             [],
  455.             []
  456.         ]
  457.     },
  458.     {
  459.         "id": "f23f85e17f7d3a33",
  460.         "type": "api-call-service",
  461.         "z": "5641ce060432f122",
  462.         "name": "",
  463.         "server": "598f8fe7bc05621b",
  464.         "version": 5,
  465.         "debugenabled": false,
  466.         "domain": "media_player",
  467.         "service": "play_media",
  468.         "areaId": [],
  469.         "deviceId": [],
  470.         "entityId": [
  471.             "media_player.chuang_wei_ke_ting_dian_shi_g6_7f6_dlna"
  472.         ],
  473.         "data": "{\t   "media_content_id": msg.payload[0],\t   "media_content_type":"video",\t   "announce":"true"\t}",
  474.         "dataType": "jsonata",
  475.         "mergeContext": "",
  476.         "mustacheAltTags": false,
  477.         "outputProperties": [],
  478.         "queue": "none",
  479.         "x": 1790,
  480.         "y": 1860,
  481.         "wires": [
  482.             [
  483.                 "6ffd3c1403904fc6"
  484.             ]
  485.         ]
  486.     },
  487.     {
  488.         "id": "3798846de5c7f949",
  489.         "type": "server-state-changed",
  490.         "z": "5641ce060432f122",
  491.         "name": "電影名稱",
  492.         "server": "598f8fe7bc05621b",
  493.         "version": 4,
  494.         "exposeToHomeAssistant": false,
  495.         "haConfig": [
  496.             {
  497.                 "property": "name",
  498.                 "value": ""
  499.             },
  500.             {
  501.                 "property": "icon",
  502.                 "value": ""
  503.             }
  504.         ],
  505.         "entityidfilter": "input_text.dian_ying_ming_cheng",
  506.         "entityidfiltertype": "exact",
  507.         "outputinitially": false,
  508.         "state_type": "str",
  509.         "haltifstate": "",
  510.         "halt_if_type": "str",
  511.         "halt_if_compare": "is",
  512.         "outputs": 1,
  513.         "output_only_on_state_change": true,
  514.         "for": "0",
  515.         "forType": "num",
  516.         "forUnits": "minutes",
  517.         "ignorePrevStateNull": false,
  518.         "ignorePrevStateUnknown": false,
  519.         "ignorePrevStateUnavailable": false,
  520.         "ignoreCurrentStateUnknown": false,
  521.         "ignoreCurrentStateUnavailable": false,
  522.         "outputProperties": [
  523.             {
  524.                 "property": "payload",
  525.                 "propertyType": "msg",
  526.                 "value": "",
  527.                 "valueType": "entityState"
  528.             },
  529.             {
  530.                 "property": "data",
  531.                 "propertyType": "msg",
  532.                 "value": "",
  533.                 "valueType": "eventData"
  534.             },
  535.             {
  536.                 "property": "topic",
  537.                 "propertyType": "msg",
  538.                 "value": "",
  539.                 "valueType": "triggerId"
  540.             }
  541.         ],
  542.         "x": 100,
  543.         "y": 1880,
  544.         "wires": [
  545.             [
  546.                 "030138d8effd759f"
  547.             ]
  548.         ]
  549.     },
  550.     {
  551.         "id": "081e66e145ad4ade",
  552.         "type": "api-call-service",
  553.         "z": "5641ce060432f122",
  554.         "name": "",
  555.         "server": "598f8fe7bc05621b",
  556.         "version": 5,
  557.         "debugenabled": false,
  558.         "domain": "media_player",
  559.         "service": "media_stop",
  560.         "areaId": [],
  561.         "deviceId": [],
  562.         "entityId": [
  563.             "media_player.chuang_wei_ke_ting_dian_shi_g6_7f6_dlna"
  564.         ],
  565.         "data": "",
  566.         "dataType": "jsonata",
  567.         "mergeContext": "",
  568.         "mustacheAltTags": false,
  569.         "outputProperties": [],
  570.         "queue": "none",
  571.         "x": 1250,
  572.         "y": 1860,
  573.         "wires": [
  574.             []
  575.         ]
  576.     },
  577.     {
  578.         "id": "e6304a814503d679",
  579.         "type": "debug",
  580.         "z": "5641ce060432f122",
  581.         "name": "debug 301",
  582.         "active": true,
  583.         "tosidebar": true,
  584.         "console": false,
  585.         "tostatus": false,
  586.         "complete": "payload",
  587.         "targetType": "msg",
  588.         "statusVal": "",
  589.         "statusType": "auto",
  590.         "x": 1550,
  591.         "y": 1960,
  592.         "wires": []
  593.     },
  594.     {
  595.         "id": "2162eb85046df316",
  596.         "type": "delay",
  597.         "z": "5641ce060432f122",
  598.         "name": "",
  599.         "pauseType": "delay",
  600.         "timeout": "2",
  601.         "timeoutUnits": "seconds",
  602.         "rate": "1",
  603.         "nbRateUnits": "1",
  604.         "rateUnits": "second",
  605.         "randomFirst": "1",
  606.         "randomLast": "5",
  607.         "randomUnits": "seconds",
  608.         "drop": false,
  609.         "allowrate": false,
  610.         "outputs": 1,
  611.         "x": 1640,
  612.         "y": 1780,
  613.         "wires": [
  614.             [
  615.                 "f23f85e17f7d3a33"
  616.             ]
  617.         ]
  618.     },
  619.     {
  620.         "id": "3e5669590088e34d",
  621.         "type": "function",
  622.         "z": "5641ce060432f122",
  623.         "name": "function 17",
  624.         "func": "// 獲取輸入的URL\nvar originalURL = msg.payload;\n\n// 使用encodeURI函數(shù)轉(zhuǎn)換URL\nvar encodedURL = encodeURI(originalURL);\n\n// 刪除末尾的逗號(hào)\nvar cleanedURL = encodedURL.replace(/,+$/, '');\n\n// 將清理后的URL存儲(chǔ)在msg.payload中\(zhòng)nmsg.payload = cleanedURL;\n\n// 返回msg對象以傳遞到下一個(gè)節(jié)點(diǎn)\nreturn msg;",
  625.         "outputs": 1,
  626.         "timeout": 0,
  627.         "noerr": 0,
  628.         "initialize": "",
  629.         "finalize": "",
  630.         "libs": [],
  631.         "x": 1470,
  632.         "y": 1840,
  633.         "wires": [
  634.             [
  635.                 "2162eb85046df316",
  636.                 "e6304a814503d679"
  637.             ]
  638.         ]
  639.     },
  640.     {
  641.         "id": "65545ddaebf3e8a4",
  642.         "type": "switch",
  643.         "z": "5641ce060432f122",
  644.         "name": "",
  645.         "property": "payload",
  646.         "propertyType": "msg",
  647.         "rules": [
  648.             {
  649.                 "t": "cont",
  650.                 "v": "%20",
  651.                 "vt": "str"
  652.             },
  653.             {
  654.                 "t": "else"
  655.             }
  656.         ],
  657.         "checkall": "true",
  658.         "repair": false,
  659.         "outputs": 2,
  660.         "x": 1410,
  661.         "y": 1680,
  662.         "wires": [
  663.             [
  664.                 "2162eb85046df316"
  665.             ],
  666.             [
  667.                 "3e5669590088e34d"
  668.             ]
  669.         ]
  670.     },
  671.     {
  672.         "id": "3a5605c9317eb24f",
  673.         "type": "api-call-service",
  674.         "z": "5641ce060432f122",
  675.         "name": "",
  676.         "server": "598f8fe7bc05621b",
  677.         "version": 5,
  678.         "debugenabled": false,
  679.         "domain": "xiaomi_miot",
  680.         "service": "intelligent_speaker",
  681.         "areaId": [],
  682.         "deviceId": [],
  683.         "entityId": [
  684.             "media_player.xiaomi_lx5a_7d9b_play_control"
  685.         ],
  686.         "data": "{"text":"沒有找到您所說的電影,可以去tv,box找找"}",
  687.         "dataType": "jsonata",
  688.         "mergeContext": "",
  689.         "mustacheAltTags": false,
  690.         "outputProperties": [],
  691.         "queue": "none",
  692.         "x": 1030,
  693.         "y": 1520,
  694.         "wires": [
  695.             []
  696.         ]
  697.     },
  698.     {
  699.         "id": "931f4e09ee722274",
  700.         "type": "switch",
  701.         "z": "5641ce060432f122",
  702.         "name": "",
  703.         "property": "payload",
  704.         "propertyType": "msg",
  705.         "rules": [
  706.             {
  707.                 "t": "cont",
  708.                 "v": "沒有找到包含",
  709.                 "vt": "str"
  710.             },
  711.             {
  712.                 "t": "else"
  713.             }
  714.         ],
  715.         "checkall": "true",
  716.         "repair": false,
  717.         "outputs": 2,
  718.         "x": 850,
  719.         "y": 1620,
  720.         "wires": [
  721.             [
  722.                 "3a5605c9317eb24f"
  723.             ],
  724.             [
  725.                 "c3e5a779dfee461f",
  726.                 "38da2c94e298a6f6",
  727.                 "8b39e6f4e4fa8774"
  728.             ]
  729.         ]
  730.     },
  731.     {
  732.         "id": "1ee4cc39ad69ee40",
  733.         "type": "inject",
  734.         "z": "5641ce060432f122",
  735.         "name": "",
  736.         "props": [
  737.             {
  738.                 "p": "payload"
  739.             },
  740.             {
  741.                 "p": "topic",
  742.                 "vt": "str"
  743.             }
  744.         ],
  745.         "repeat": "",
  746.         "crontab": "",
  747.         "once": false,
  748.         "onceDelay": 0.1,
  749.         "topic": "",
  750.         "payload": "",
  751.         "payloadType": "date",
  752.         "x": 990,
  753.         "y": 1920,
  754.         "wires": [
  755.             [
  756.                 "081e66e145ad4ade"
  757.             ]
  758.         ]
  759.     },
  760.     {
  761.         "id": "dac6af55d7290b5e",
  762.         "type": "api-call-service",
  763.         "z": "5641ce060432f122",
  764.         "name": "",
  765.         "server": "598f8fe7bc05621b",
  766.         "version": 5,
  767.         "debugenabled": false,
  768.         "domain": "xiaomi_miot",
  769.         "service": "intelligent_speaker",
  770.         "areaId": [],
  771.         "deviceId": [],
  772.         "entityId": [
  773.             "media_player.xiaomi_lx5a_7d9b_play_control"
  774.         ],
  775.         "data": "{"text":msg.name}",
  776.         "dataType": "jsonata",
  777.         "mergeContext": "",
  778.         "mustacheAltTags": false,
  779.         "outputProperties": [],
  780.         "queue": "none",
  781.         "x": 1410,
  782.         "y": 1520,
  783.         "wires": [
  784.             []
  785.         ]
  786.     },
  787.     {
  788.         "id": "38da2c94e298a6f6",
  789.         "type": "function",
  790.         "z": "5641ce060432f122",
  791.         "name": "function 18",
  792.         "func": "\n\n\nmsg.name = "正在為您播放 " + global.get("moviename")+"請稍后";\nreturn msg;",
  793.         "outputs": 1,
  794.         "timeout": 0,
  795.         "noerr": 0,
  796.         "initialize": "",
  797.         "finalize": "",
  798.         "libs": [],
  799.         "x": 1030,
  800.         "y": 1580,
  801.         "wires": [
  802.             [
  803.                 "dac6af55d7290b5e"
  804.             ]
  805.         ]
  806.     },
  807.     {
  808.         "id": "f4f391a64858ac59",
  809.         "type": "function",
  810.         "z": "5641ce060432f122",
  811.         "name": "function 19",
  812.         "func": "\n\nglobal.set("moviename", msg.payload);\nreturn msg;",
  813.         "outputs": 1,
  814.         "timeout": 0,
  815.         "noerr": 0,
  816.         "initialize": "",
  817.         "finalize": "",
  818.         "libs": [],
  819.         "x": 930,
  820.         "y": 2020,
  821.         "wires": [
  822.             []
  823.         ]
  824.     },
  825.     {
  826.         "id": "8b39e6f4e4fa8774",
  827.         "type": "debug",
  828.         "z": "5641ce060432f122",
  829.         "name": "debug 302",
  830.         "active": true,
  831.         "tosidebar": true,
  832.         "console": false,
  833.         "tostatus": false,
  834.         "complete": "true",
  835.         "targetType": "full",
  836.         "statusVal": "",
  837.         "statusType": "auto",
  838.         "x": 1130,
  839.         "y": 1660,
  840.         "wires": []
  841.     },
  842.     {
  843.         "id": "598f8fe7bc05621b",
  844.         "type": "server",
  845.         "name": "Home Assistant",
  846.         "version": 5,
  847.         "addon": false,
  848.         "rejectUnauthorizedCerts": false,
  849.         "ha_boolean": "y|yes|true|on|home|open",
  850.         "connectionDelay": true,
  851.         "cacheJson": true,
  852.         "heartbeat": false,
  853.         "heartbeatInterval": "30",
  854.         "areaSelector": "friendlyName",
  855.         "deviceSelector": "friendlyName",
  856.         "entitySelector": "friendlyName",
  857.         "statusSeparator": ": ",
  858.         "statusYear": "hidden",
  859.         "statusMonth": "short",
  860.         "statusDay": "numeric",
  861.         "statusHourCycle": "default",
  862.         "statusTimeFormat": "h:m",
  863.         "enableGlobalContextStore": false
  864.     },
  865.     {
  866.         "id": "09b787bdbe3ed75d",
  867.         "type": "xiaoai-tts-configurator",
  868.         "name": ""
  869.     }
  870. ]
復(fù)制代碼

在nr輸入一個(gè)你想看的電影,如果出現(xiàn)下邊的url就說明成功了。恭喜你,可以隨心看電影了。

怎樣用小愛音箱控制電視 用小愛音箱控制電視播放任意影視

如果上邊的流導(dǎo)入有問題就直接下載附件

游客,如果您要查看本帖隱藏內(nèi)容請回復(fù)



相關(guān)閱讀:



上一篇:Alist Helper(電腦傻瓜式設(shè)置alist) v0.1.4.8使用教程
下一篇:山西移動(dòng)九聯(lián)UNT413A,芯片S905L3急需求助?。?!
沙發(fā)
發(fā)表于 2024-1-10 11:10 | 只看該作者 | 來自江西
大神666.
板凳
發(fā)表于 2024-1-10 11:10 | 只看該作者 | 來自陜西
厲害了,膜拜一下
地板
發(fā)表于 2024-1-10 11:11 | 只看該作者 | 來自重慶

有些人可能是在homeassistant里面安裝的nodered,并不是獨(dú)立的docker,這種情況怎么安裝http請求及解析需要的庫
5#
發(fā)表于 2024-1-10 11:11 | 只看該作者 | 來自重慶
天天貓媽 發(fā)表于 2024-1-10 11:11
有些人可能是在homeassistant里面安裝的nodered,并不是獨(dú)立的docker,這種情況怎么安裝http請求及解析需 ...

如果HA supervised的,直接SSH進(jìn)宿主機(jī),用同樣的命令。
如果HAOS的,需要超級權(quán)限,進(jìn)SSH,然后,命令一樣。
6#
發(fā)表于 2024-1-10 11:11 | 只看該作者 | 來自上海
果然還是玩不轉(zhuǎn),要好好學(xué)習(xí)了
7#
發(fā)表于 2024-1-10 11:11 | 只看該作者 | 來自江西
厲害了我的哥
8#
發(fā)表于 2024-1-10 21:27 來自ZNDS手機(jī)版 | 只看該作者 | 來自湖南
我連標(biāo)點(diǎn)符號(hào)都不懂
9#
發(fā)表于 2024-1-10 21:53 | 只看該作者 | 來自遼寧

謝謝樓主分享
10#
發(fā)表于 2024-1-11 16:24 | 只看該作者 | 來自山東
連標(biāo)點(diǎn)符號(hào)都不懂
您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

Archiver|新帖|標(biāo)簽|軟件|Sitemap|ZNDS智能電視網(wǎng) ( 蘇ICP備2023012627號(hào) )

網(wǎng)絡(luò)信息服務(wù)信用承諾書 | 增值電信業(yè)務(wù)經(jīng)營許可證:蘇B2-20221768 丨 蘇公網(wǎng)安備 32011402011373號(hào)

GMT+8, 2024-10-23 07:34 , Processed in 0.104091 second(s), 14 queries , Redis On.

Powered by Discuz!

監(jiān)督舉報(bào):report#znds.com (請將#替換為@)

© 2007-2024 ZNDS.Com

快速回復(fù) 返回頂部 返回列表