[
{
"id": "73f4cb07bcf61615",
"type": "server-state-changed",
"z": "8c8242e7b6ea02a8",
"name": "小爱音箱",
"server": "459a05598e74e156",
"version": 4,
"exposeToHomeAssistant": false,
"haConfig": [
{
"property": "name",
"value": ""
},
{
"property": "icon",
"value": ""
}
],
"entityidfilter": "sensor.xiaomi_lx5a_7d9b_conversation",
"entityidfiltertype": "exact",
"outputinitially": false,
"state_type": "str",
"haltifstate": "",
"halt_if_type": "str",
"halt_if_compare": "is",
"outputs": 1,
"output_only_on_state_change": 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": 160,
"y": 1400,
"wires": [
[
"50ef668ebea29429",
"3f3dabf2834007ca"
]
]
},
{
"id": "3f3dabf2834007ca",
"type": "switch",
"z": "8c8242e7b6ea02a8",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "开启贾维斯",
"vt": "str"
},
{
"t": "cont",
"v": "召唤贾维斯",
"vt": "str"
},
{
"t": "cont",
"v": "打开贾维斯",
"vt": "str"
},
{
"t": "cont",
"v": "退出贾维斯",
"vt": "str"
},
{
"t": "cont",
"v": "关闭贾维斯",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 5,
"x": 350,
"y": 1320,
"wires": [
[
"039fbd671807fa3f"
],
[
"039fbd671807fa3f"
],
[
"039fbd671807fa3f"
],
[
"5121643a1fa5d572"
],
[
"5121643a1fa5d572"
]
]
},
{
"id": "4b01a0e4fc04ec84",
"type": "debug",
"z": "8c8242e7b6ea02a8",
"name": "debug 334",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 810,
"y": 1360,
"wires": []
},
{
"id": "d5960fdc46d6972a",
"type": "inject",
"z": "8c8242e7b6ea02a8",
"name": "",
"props": [
{
"p": "wt",
"v": "帮我策划一个十岁小孩的生日",
"vt": "str"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 190,
"y": 1580,
"wires": [
[
"8773f238830b2caa"
]
]
},
{
"id": "8773f238830b2caa",
"type": "function",
"z": "8c8242e7b6ea02a8",
"name": "function 32",
"func": "msg.headers = {\n 'Content-Type': 'application/json',\n 'Authorization': 'Bearer your key'\n }\n\n\nmsg.payload = {\n "model": "gpt-3.5-turbo",\n "messages": [\n {\n "role": "system",\n "content": "You are a helpful assistant."\n },\n {\n "role": "user",\n "content": msg.wt\n }\n ]\n}\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 370,
"y": 1580,
"wires": [
[
"efabfcb91ec074c3"
]
]
},
{
"id": "efabfcb91ec074c3",
"type": "http request",
"z": "8c8242e7b6ea02a8",
"name": "",
"method": "POST",
"ret": "txt",
"paytoqs": "ignore",
"url": "https://api.chatanywhere.tech/v1/chat/completions",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 520,
"y": 1580,
"wires": [
[
"0977d103cb1ba3f9"
]
]
},
{
"id": "0977d103cb1ba3f9",
"type": "json",
"z": "8c8242e7b6ea02a8",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 650,
"y": 1580,
"wires": [
[
"f02c68977360528a"
]
]
},
{
"id": "82e28a5544ebc505",
"type": "debug",
"z": "8c8242e7b6ea02a8",
"name": "debug 335",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1030,
"y": 1580,
"wires": []
},
{
"id": "f02c68977360528a",
"type": "change",
"z": "8c8242e7b6ea02a8",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.choices[0].message.content",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 830,
"y": 1580,
"wires": [
[
"82e28a5544ebc505",
"db79d520a7ee4b61"
]
]
},
{
"id": "db79d520a7ee4b61",
"type": "api-call-service",
"z": "8c8242e7b6ea02a8",
"name": "小爱播放结果",
"server": "459a05598e74e156",
"version": 5,
"debugenabled": false,
"domain": "xiaomi_miot",
"service": "intelligent_speaker",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.xiaomi_lx5a_7d9b_play_control"
],
"data": "{"text":msg.payload}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 940,
"y": 1680,
"wires": [
[]
]
},
{
"id": "039fbd671807fa3f",
"type": "api-call-service",
"z": "8c8242e7b6ea02a8",
"name": "",
"server": "459a05598e74e156",
"version": 5,
"debugenabled": false,
"domain": "input_boolean",
"service": "turn_on",
"areaId": [],
"deviceId": [],
"entityId": [
"input_boolean.xiao_ai_yin_xiang_chatgptkai_guan"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 540,
"y": 1300,
"wires": [
[]
]
},
{
"id": "a14c57cda204418c",
"type": "api-current-state",
"z": "8c8242e7b6ea02a8",
"name": "贾维斯开关",
"server": "459a05598e74e156",
"version": 3,
"outputs": 2,
"halt_if": "on",
"halt_if_type": "str",
"halt_if_compare": "is",
"entity_id": "input_boolean.xiao_ai_yin_xiang_chatgptkai_guan",
"state_type": "str",
"blockInputOverrides": false,
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "entityState"
},
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "entity"
}
],
"for": "0",
"forType": "num",
"forUnits": "minutes",
"override_topic": false,
"state_location": "payload",
"override_payload": "msg",
"entity_location": "data",
"override_data": "msg",
"x": 630,
"y": 1480,
"wires": [
[
"4b01a0e4fc04ec84",
"2dfa531005c8b19c"
],
[]
]
},
{
"id": "499eac86a8f557c6",
"type": "api-call-service",
"z": "8c8242e7b6ea02a8",
"name": "小爱播放结果",
"server": "459a05598e74e156",
"version": 5,
"debugenabled": false,
"domain": "xiaomi_miot",
"service": "intelligent_speaker",
"areaId": [],
"deviceId": [],
"entityId": [
"media_player.xiaomi_lx5a_7d9b_play_control"
],
"data": "{"text":"贾维斯正在查询,请稍后"}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 1000,
"y": 1440,
"wires": [
[]
]
},
{
"id": "50ef668ebea29429",
"type": "change",
"z": "8c8242e7b6ea02a8",
"name": "",
"rules": [
{
"t": "set",
"p": "wt",
"pt": "msg",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 310,
"y": 1480,
"wires": [
[
"b825827679c20f63"
]
]
},
{
"id": "5121643a1fa5d572",
"type": "api-call-service",
"z": "8c8242e7b6ea02a8",
"name": "",
"server": "459a05598e74e156",
"version": 5,
"debugenabled": false,
"domain": "input_boolean",
"service": "turn_off",
"areaId": [],
"deviceId": [],
"entityId": [
"input_boolean.xiao_ai_yin_xiang_chatgptkai_guan"
],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 540,
"y": 1360,
"wires": [
[]
]
},
{
"id": "b825827679c20f63",
"type": "delay",
"z": "8c8242e7b6ea02a8",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 480,
"y": 1480,
"wires": [
[
"a14c57cda204418c"
]
]
},
{
"id": "2dfa531005c8b19c",
"type": "switch",
"z": "8c8242e7b6ea02a8",
"name": "",
"property": "wt",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "打开贾维斯",
"vt": "str"
},
{
"t": "eq",
"v": "召唤贾维斯",
"vt": "str"
},
{
"t": "eq",
"v": "启动贾维斯",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 4,
"x": 810,
"y": 1480,
"wires": [
[],
[],
[],
[
"8773f238830b2caa",
"499eac86a8f557c6"
]
]
},
{
"id": "459a05598e74e156",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": false
}
]