[
{
"id": "021363853122b3fd",
"type": "tab",
"label": "小爱播放本地Webdav歌曲",
"disabled": false,
"info": "",
"env": []
},
{
"id": "cca1137c2f77a5b2",
"type": "function",
"z": "021363853122b3fd",
"name": "POST数据整理",
"func": "msg.payload = {\n "parent": "",\n "keywords": msg.keyword,\n "scope": 1,\n "page": 1,\n "per_page": 20\n}\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1280,
"y": 780,
"wires": [
[
"974c7e37c951d79c"
]
]
},
{
"id": "f51c3e053a4293a9",
"type": "inject",
"z": "021363853122b3fd",
"name": "歌曲名称",
"props": [
{
"p": "keyword",
"v": "小宇",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 580,
"y": 780,
"wires": [
[
"cca1137c2f77a5b2"
]
]
},
{
"id": "974c7e37c951d79c",
"type": "http request",
"z": "021363853122b3fd",
"name": "查找要播放的内容",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "http://192.168.0.115:5244/api/fs/search",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1470,
"y": 780,
"wires": [
[
"8c0a374ecdc22e93"
]
]
},
{
"id": "8c0a374ecdc22e93",
"type": "function",
"z": "021363853122b3fd",
"name": "POST数据整理",
"func": "\nif (msg.payload.data.total >0 ){\n //有歌手文件夹\n // msg.url = "http://192.168.0.115:5244/api/fs/list"\n // msg.payload = {\n // "path": msg.payload.data.content[0].parent + "/" + msg.payload.data.content[0].name,\n // "password": "",\n // "page": 1,\n // "per_page": 0,\n // "refresh": false\n\n//改成到文件夹里搜.,后续调用方式可以一致\n msg.url = "http://192.168.0.115:5244/api/fs/search"\n msg.payload = {\n "parent": msg.payload.data.content[0].parent + "/" + msg.payload.data.content[0].name,\n "keywords": ".",\n "scope": 2,\n "page": 1,\n "per_page": 20\n }\n}\nelse{\n //无歌手文件夹,认为是传入的是歌曲\n msg.url = "http://192.168.0.115:5244/api/fs/search"\n msg.payload = {\n "parent": "",\n "keywords": msg.keyword,\n "scope": 2,\n "page": 1,\n "per_page": 20\n }\n}\n\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1660,
"y": 780,
"wires": [
[
"cd7619d0b428860b"
]
]
},
{
"id": "cd7619d0b428860b",
"type": "http request",
"z": "021363853122b3fd",
"name": "查找要播放的内容",
"method": "POST",
"ret": "obj",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 1870,
"y": 780,
"wires": [
[
"8d3972ded92c571b"
]
]
},
{
"id": "5c41ebe526e08fa4",
"type": "function",
"z": "021363853122b3fd",
"name": "整理url",
"func": "var playMusiccommand = global.get("playMusiccommand")\nvar playMusicIndex = global.get("playMusicIndex")\n\nif (playMusiccommand == "play"){\n if (playMusicIndex >= msg.payload.data.total){\n //播放完了复位Index\n global.set("playMusicIndex", 0)\n playMusicIndex = 0\n }\n if (msg.payload.data.content[playMusicIndex].parent.split("WebDav/").length >= 2) {\n msg.parentpath = msg.payload.data.content[playMusicIndex].parent.split("WebDav/")[1] + "/"\n }\n else {\n msg.parentpath = ""\n }\n msg.payload = "http://192.168.0.115:5007/Music/" + msg.parentpath + msg.payload.data.content[playMusicIndex].name\n}\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2920,
"y": 780,
"wires": [
[
"c29fcc59c251a44e",
"e41c82303c5a303f"
]
]
},
{
"id": "012d3bd954d0d22a",
"type": "api-call-service",
"z": "021363853122b3fd",
"name": "小爱播放url歌曲",
"server": "466483fcf144a9ea",
"version": 5,
"debugenabled": false,
"domain": "media_player",
"service": "play_media",
"areaId": [
"chu_zu_wu"
],
"deviceId": [
"0499e2257416be9071ada18d53d0a3df"
],
"entityId": [
"media_player.xiaomi_lx06_0f65_play_control"
],
"data": "{\t "media_content_id":msg.payload,\t "media_content_type":"music"\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 3300,
"y": 780,
"wires": [
[]
]
},
{
"id": "ff8a8a5fe9659635",
"type": "switch",
"z": "021363853122b3fd",
"name": "判断是否为绿钻歌曲",
"property": "data.new_state.attributes.answers[0].tts.text",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "试听版",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 520,
"y": 640,
"wires": [
[
"183b8cf750e1bb12"
],
[]
]
},
{
"id": "183b8cf750e1bb12",
"type": "split",
"z": "021363853122b3fd",
"name": "",
"splt": "播放",
"spltType": "str",
"arraySplt": "1",
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 710,
"y": 640,
"wires": [
[
"61386bc310c047be"
]
]
},
{
"id": "61386bc310c047be",
"type": "join",
"z": "021363853122b3fd",
"name": "",
"mode": "custom",
"build": "array",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 830,
"y": 640,
"wires": [
[
"ea256afd87a09164"
]
]
},
{
"id": "ea256afd87a09164",
"type": "function",
"z": "021363853122b3fd",
"name": "",
"func": "msg.payload = msg.payload[1]\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 640,
"wires": [
[
"5de7e22b30a5b296"
]
]
},
{
"id": "0c2838967b10ea06",
"type": "server-state-changed",
"z": "021363853122b3fd",
"name": "小爱对话",
"server": "466483fcf144a9ea",
"version": 5,
"outputs": 1,
"exposeAsEntityConfig": "",
"entityId": "sensor.xiaomi_lx06_0f65_conversation",
"entityIdType": "exact",
"outputInitially": false,
"stateType": "str",
"ifState": "",
"ifStateType": "str",
"ifStateOperator": "is",
"outputOnlyOnStateChange": true,
"for": "0",
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": false,
"ignoreCurrentStateUnavailable": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
}
],
"x": 80,
"y": 420,
"wires": [
[
"c4d745d3481ec44e"
]
]
},
{
"id": "5de7e22b30a5b296",
"type": "change",
"z": "021363853122b3fd",
"name": "",
"rules": [
{
"t": "set",
"p": "keyword",
"pt": "msg",
"to": "payload",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1030,
"y": 740,
"wires": [
[
"cca1137c2f77a5b2"
]
]
},
{
"id": "3da9cf1da9eca9cf",
"type": "comment",
"z": "021363853122b3fd",
"name": "小爱播放本地音乐",
"info": "",
"x": 250,
"y": 100,
"wires": []
},
{
"id": "14d73a336525acbe",
"type": "comment",
"z": "021363853122b3fd",
"name": "先查询文件夹,如果是的话认为是歌手,播放整个文件夹下所有歌曲文件",
"info": "",
"x": 1510,
"y": 680,
"wires": []
},
{
"id": "9839a184e7f8048d",
"type": "comment",
"z": "021363853122b3fd",
"name": "绿钻歌曲自动放本地的",
"info": "",
"x": 800,
"y": 580,
"wires": []
},
{
"id": "b2384213013da667",
"type": "xiaoai-tts",
"z": "021363853122b3fd",
"name": "",
"xiaoai": "f36c15f97a0bea15",
"tts": "",
"device": "",
"x": 2530,
"y": 860,
"wires": [
[],
[]
]
},
{
"id": "8d3972ded92c571b",
"type": "switch",
"z": "021363853122b3fd",
"name": "判断最后是否找到",
"property": "payload.data.total",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "0",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 2090,
"y": 780,
"wires": [
[
"21db4fbe060fa13d"
],
[
"c966ddc1c36aa24f"
]
]
},
{
"id": "c966ddc1c36aa24f",
"type": "change",
"z": "021363853122b3fd",
"name": "播放本地未找到歌曲",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "本地没有找到你想要播放的歌曲",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2340,
"y": 860,
"wires": [
[
"b2384213013da667"
]
]
},
{
"id": "c4d745d3481ec44e",
"type": "switch",
"z": "021363853122b3fd",
"name": "判断是否含本地播放",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "本地播放",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 300,
"y": 420,
"wires": [
[
"44c272c5b0302e50"
],
[
"ff8a8a5fe9659635"
]
]
},
{
"id": "44c272c5b0302e50",
"type": "split",
"z": "021363853122b3fd",
"name": "",
"splt": "本地播放",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 510,
"y": 400,
"wires": [
[
"57bdc1fbc0e32799"
]
]
},
{
"id": "63a3bb8c415dd4d4",
"type": "inject",
"z": "021363853122b3fd",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "本地播放赵雷",
"payloadType": "str",
"x": 290,
"y": 340,
"wires": [
[
"44c272c5b0302e50"
]
]
},
{
"id": "cfd9892bf243c73e",
"type": "change",
"z": "021363853122b3fd",
"name": "",
"rules": [
{
"t": "set",
"p": "keyword",
"pt": "msg",
"to": "payload",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 950,
"y": 400,
"wires": [
[
"cca1137c2f77a5b2",
"34d52cfd2323e888"
]
]
},
{
"id": "9a8317d64d45a148",
"type": "debug",
"z": "021363853122b3fd",
"name": "play status",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 2470,
"y": 660,
"wires": []
},
{
"id": "a6cdab81aa9b2323",
"type": "switch",
"z": "021363853122b3fd",
"name": "判断是否变为空闲",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "idle",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 2490,
"y": 720,
"wires": [
[
"91d2fda4f9157393"
]
]
},
{
"id": "645d85504ac5e9b3",
"type": "comment",
"z": "021363853122b3fd",
"name": "空闲认为播放完毕,播放下一曲",
"info": "",
"x": 2530,
"y": 460,
"wires": []
},
{
"id": "78ac9bbb442ae8af",
"type": "server-state-changed",
"z": "021363853122b3fd",
"name": "小爱对话",
"server": "466483fcf144a9ea",
"version": 5,
"outputs": 1,
"exposeAsEntityConfig": "",
"entityId": "sensor.xiaomi_lx06_0f65_conversation",
"entityIdType": "exact",
"outputInitially": false,
"stateType": "str",
"ifState": "",
"ifStateType": "str",
"ifStateOperator": "is",
"outputOnlyOnStateChange": false,
"for": "0",
"forType": "num",
"forUnits": "minutes",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": true,
"ignoreCurrentStateUnavailable": true,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
}
],
"x": 2280,
"y": 600,
"wires": [
[
"532cdc2b77c65a99"
]
]
},
{
"id": "532cdc2b77c65a99",
"type": "switch",
"z": "021363853122b3fd",
"name": "判断是否含退出停止",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "退出本地播放",
"vt": "str"
},
{
"t": "cont",
"v": "停止本地播放",
"vt": "str"
},
{
"t": "cont",
"v": "取消本地播放",
"vt": "str"
},
{
"t": "eq",
"v": "上一首",
"vt": "str"
},
{
"t": "eq",
"v": "上一曲",
"vt": "str"
},
{
"t": "eq",
"v": "下一曲",
"vt": "str"
},
{
"t": "eq",
"v": "下一首",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 7,
"x": 2480,
"y": 560,
"wires": [
[
"2f241251fa501c4f"
],
[
"2f241251fa501c4f"
],
[
"2f241251fa501c4f"
],
[
"7c956359a5f2fb1d"
],
[
"7c956359a5f2fb1d"
],
[
"91d2fda4f9157393"
],
[
"91d2fda4f9157393"
]
]
},
{
"id": "2f241251fa501c4f",
"type": "function",
"z": "021363853122b3fd",
"name": "循环参数break",
"func": "global.set("playMusiccommand", "break")\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2720,
"y": 520,
"wires": [
[]
]
},
{
"id": "21db4fbe060fa13d",
"type": "change",
"z": "021363853122b3fd",
"name": "设定播放序列",
"rules": [
{
"t": "set",
"p": "playMusicIndex",
"pt": "global",
"to": "0",
"tot": "num"
},
{
"t": "set",
"p": "playMusiccommand",
"pt": "global",
"to": "play",
"tot": "str"
},
{
"t": "set",
"p": "PlayMusicpayload",
"pt": "global",
"to": "payload",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2380,
"y": 780,
"wires": [
[
"5c41ebe526e08fa4"
]
]
},
{
"id": "91d2fda4f9157393",
"type": "function",
"z": "021363853122b3fd",
"name": "播放序列+1",
"func": "var playMusicIndex = global.get("playMusicIndex")\nglobal.set("playMusicIndex", playMusicIndex+1)\nmsg.payload = global.get("PlayMusicpayload")\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2710,
"y": 720,
"wires": [
[
"5c41ebe526e08fa4"
]
]
},
{
"id": "57bdc1fbc0e32799",
"type": "join",
"z": "021363853122b3fd",
"name": "",
"mode": "custom",
"build": "array",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 670,
"y": 400,
"wires": [
[
"6aa4da5dba8a97ba"
]
]
},
{
"id": "6aa4da5dba8a97ba",
"type": "function",
"z": "021363853122b3fd",
"name": "",
"func": "msg.payload = msg.payload[1]\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 790,
"y": 400,
"wires": [
[
"cfd9892bf243c73e"
]
]
},
{
"id": "7c956359a5f2fb1d",
"type": "function",
"z": "021363853122b3fd",
"name": "播放序列-1",
"func": "var playMusicIndex = global.get("playMusicIndex")\nglobal.set("playMusicIndex", playMusicIndex-1)\nmsg.payload = global.get("PlayMusicpayload")\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2710,
"y": 680,
"wires": [
[
"5c41ebe526e08fa4"
]
]
},
{
"id": "ba8b79e5d9da1a41",
"type": "server-state-changed",
"z": "021363853122b3fd",
"name": "小爱状态",
"server": "466483fcf144a9ea",
"version": 5,
"outputs": 1,
"exposeAsEntityConfig": "",
"entityId": "media_player.xiaomi_lx06_0f65_play_control",
"entityIdType": "exact",
"outputInitially": false,
"stateType": "str",
"ifState": "",
"ifStateType": "str",
"ifStateOperator": "is",
"outputOnlyOnStateChange": true,
"for": "5",
"forType": "num",
"forUnits": "seconds",
"ignorePrevStateNull": false,
"ignorePrevStateUnknown": false,
"ignorePrevStateUnavailable": false,
"ignoreCurrentStateUnknown": false,
"ignoreCurrentStateUnavailable": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
},
{
"property": "topic",
"propertyType": "msg",
"value": "",
"valueType": "triggerId"
}
],
"x": 2280,
"y": 720,
"wires": [
[
"9a8317d64d45a148",
"a6cdab81aa9b2323"
]
]
},
{
"id": "34d52cfd2323e888",
"type": "debug",
"z": "021363853122b3fd",
"name": "debug 13",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1190,
"y": 380,
"wires": []
},
{
"id": "c29fcc59c251a44e",
"type": "delay",
"z": "021363853122b3fd",
"name": "",
"pauseType": "delay",
"timeout": "4",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 3120,
"y": 780,
"wires": [
[
"012d3bd954d0d22a"
]
]
},
{
"id": "e41c82303c5a303f",
"type": "debug",
"z": "021363853122b3fd",
"name": "debug 14",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 3100,
"y": 700,
"wires": []
},
{
"id": "466483fcf144a9ea",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": true,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
},
{
"id": "f36c15f97a0bea15",
"type": "xiaoai-tts-configurator",
"name": ""
}
]