|
@@ -839,26 +839,27 @@ const aiService = {
|
|
|
controlCurtain: withErrorHandling('控制窗帘状态', async function(isOn) {
|
|
controlCurtain: withErrorHandling('控制窗帘状态', async function(isOn) {
|
|
|
// 根据传入的布尔值决定是打开还是关闭窗帘
|
|
// 根据传入的布尔值决定是打开还是关闭窗帘
|
|
|
if (isOn) {
|
|
if (isOn) {
|
|
|
- await this.openCurtain();
|
|
|
|
|
|
|
+ this.openCurtain();
|
|
|
} else {
|
|
} else {
|
|
|
- await this.closeCurtain();
|
|
|
|
|
|
|
+ this.closeCurtain();
|
|
|
}
|
|
}
|
|
|
return isOn;
|
|
return isOn;
|
|
|
}, '控制窗帘状态失败'),
|
|
}, '控制窗帘状态失败'),
|
|
|
|
|
|
|
|
// 打开窗帘
|
|
// 打开窗帘
|
|
|
openCurtain: withErrorHandling('打开窗帘', async function() {
|
|
openCurtain: withErrorHandling('打开窗帘', async function() {
|
|
|
|
|
+
|
|
|
console.log("打开窗帘");
|
|
console.log("打开窗帘");
|
|
|
|
|
|
|
|
- if (!state.showCurtainLeft && !state.showCurtainRight) {
|
|
|
|
|
|
|
+ if (state.showCurtainLeft && state.showCurtainRight) {
|
|
|
console.log("窗帘已经是打开的状态");
|
|
console.log("窗帘已经是打开的状态");
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
// 重置窗帘状态
|
|
// 重置窗帘状态
|
|
|
- state.showCurtainLeft = true;
|
|
|
|
|
- state.showCurtainRight = true;
|
|
|
|
|
|
|
+ // state.showCurtainLeft = true;
|
|
|
|
|
+ // state.showCurtainRight = true;
|
|
|
state.animateCurtainLeft = false;
|
|
state.animateCurtainLeft = false;
|
|
|
state.animateCurtainRight = false;
|
|
state.animateCurtainRight = false;
|
|
|
|
|
|
|
@@ -897,15 +898,15 @@ const aiService = {
|
|
|
// 关闭窗帘
|
|
// 关闭窗帘
|
|
|
closeCurtain: withErrorHandling('关闭窗帘', async function() {
|
|
closeCurtain: withErrorHandling('关闭窗帘', async function() {
|
|
|
console.log("关闭窗帘");
|
|
console.log("关闭窗帘");
|
|
|
- if (state.showCurtainLeft && state.showCurtainRight) {
|
|
|
|
|
|
|
+ if (!state.showCurtainLeft && !state.showCurtainRight) {
|
|
|
console.log("窗帘已经是关闭的状态");
|
|
console.log("窗帘已经是关闭的状态");
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
// 重置窗帘状态
|
|
// 重置窗帘状态
|
|
|
- state.showCurtainLeft = false;
|
|
|
|
|
- state.showCurtainRight = false;
|
|
|
|
|
|
|
+ // state.showCurtainLeft = false;
|
|
|
|
|
+ // state.showCurtainRight = false;
|
|
|
state.animateCurtainLeft = false;
|
|
state.animateCurtainLeft = false;
|
|
|
state.animateCurtainRight = false;
|
|
state.animateCurtainRight = false;
|
|
|
|
|
|
|
@@ -944,12 +945,17 @@ const aiService = {
|
|
|
for (const pair of commandPairs) {
|
|
for (const pair of commandPairs) {
|
|
|
const [device, action] = pair.split('=');
|
|
const [device, action] = pair.split('=');
|
|
|
if (!device || !action) continue;
|
|
if (!device || !action) continue;
|
|
|
|
|
+
|
|
|
|
|
+ const actionBool = action === 'true' || action === '1' || action === 'on' ? true :
|
|
|
|
|
+ action === 'false' || action === '0' || action === 'off' ? false :
|
|
|
|
|
+ Boolean(action);
|
|
|
|
|
+
|
|
|
if (device === 'light') {
|
|
if (device === 'light') {
|
|
|
- await this.controlTopLamp(action)
|
|
|
|
|
|
|
+ await this.controlTopLamp(actionBool)
|
|
|
} else if (device === 'curtain') {
|
|
} else if (device === 'curtain') {
|
|
|
- await this.controlCurtain(action)
|
|
|
|
|
|
|
+ await this.controlCurtain(actionBool)
|
|
|
} else if (device === 'tv') {
|
|
} else if (device === 'tv') {
|
|
|
- await this.controlTv(action)
|
|
|
|
|
|
|
+ await this.controlTv(actionBool)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -959,9 +965,9 @@ const aiService = {
|
|
|
// 智能音箱命令处理 - 多参数版本
|
|
// 智能音箱命令处理 - 多参数版本
|
|
|
controlSmartSpeakers: withErrorHandling('智能音箱命令处理(多参数)', async function(lightStatus, curtainStatus, tvStatus) {
|
|
controlSmartSpeakers: withErrorHandling('智能音箱命令处理(多参数)', async function(lightStatus, curtainStatus, tvStatus) {
|
|
|
console.log(`智能音箱执行命令: light=${lightStatus}, curtain=${curtainStatus}, tv=${tvStatus}`);
|
|
console.log(`智能音箱执行命令: light=${lightStatus}, curtain=${curtainStatus}, tv=${tvStatus}`);
|
|
|
- await this.controlTopLamp(lightStatus)
|
|
|
|
|
- await this.controlCurtain(curtainStatus)
|
|
|
|
|
- await this.controlTv(tvStatus)
|
|
|
|
|
|
|
+ this.controlTopLamp(lightStatus)
|
|
|
|
|
+ this.controlCurtain(curtainStatus)
|
|
|
|
|
+ this.controlTv(tvStatus)
|
|
|
|
|
|
|
|
return "命令执行完成";
|
|
return "命令执行完成";
|
|
|
}, '智能音箱命令执行失败'),
|
|
}, '智能音箱命令执行失败'),
|