Skip to content

Commit

Permalink
fix silent mode for 401 thinq2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucky-ESA committed Nov 2, 2024
1 parent d775be7 commit e6e35a5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
23 changes: 14 additions & 9 deletions lib/air_conditioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const new_silentMode = {
endMin: 17,
silentMode: 1,
};
const addRemote = ["airState.tempState.hotWaterTarget", "airState.2nd.operation", "airState.miscFuncState.hotWater", "airState.miscFuncState.powerHotWater"];
const addRemote = ["airState.tempState.hotWaterTarget", "airState.2nd.tempState.target", "airState.2nd.operation", "airState.miscFuncState.hotWater", "airState.miscFuncState.powerHotWater"];
module.exports = {
async createAirRemoteStates(device, deviceModel) {
if (!deviceModel || !deviceModel.ControlDevice) {
Expand All @@ -56,20 +56,24 @@ module.exports = {
}
this.log.debug(JSON.stringify(langPack));
const control = JSON.stringify(deviceModel.ControlDevice);
let common = {};
let valueDefault = null;
let isAdd = false;
let foldername = "";
if (device.snapshot) {
Object.keys(device.snapshot).forEach(async (remote) => {
for (const remote in device.snapshot) {
isAdd = false;
if (control.includes(remote) || addRemote.includes(remote)) {
if (!control.includes(remote)) isAdd = true;
for (const dataRemote of deviceModel.ControlDevice) {
let common = {};
if (JSON.stringify(dataRemote).includes(remote) || isAdd) {
const laststate = remote.split(".").pop();
if (isAdd) {
foldername = "basicCtrl";
if (remote === "airState.2nd.operation" || remote === "airState.2nd.tempState.target") {
foldername = "2nd";
} else {
foldername = "basicCtrl";
}
} else {
foldername = dataRemote.ctrlKey;
}
Expand Down Expand Up @@ -153,9 +157,10 @@ module.exports = {
//energyDesiredCtrl
}
}
if (isAdd) break;
}
}
});
}
}

await this.setObjectNotExistsAsync(device.deviceId + ".remote.sendJSON", {
Expand Down Expand Up @@ -552,10 +557,10 @@ module.exports = {
if (editJSON) {
const allValue = Object.keys(editJSON["airState.reservation.advancedSchedule"]).length;
if (allValue > 0) {
const index = editJSON.findIndex((index) => index.type === 3);
editJSON[index].onOffFlag = state.val ? 1: 0;
if (editJSON[index].startHour === 255) editJSON[index].onOffFlag = 18;
if (editJSON[index].endHour === 255) editJSON[index].onOffFlag = 6;
const index = editJSON["airState.reservation.advancedSchedule"].findIndex((index) => index.type === 3);
editJSON["airState.reservation.advancedSchedule"][index].onOffFlag = state.val ? 1 : 0;
if (editJSON["airState.reservation.advancedSchedule"][index].startHour === 255) editJSON["airState.reservation.advancedSchedule"][index].onOffFlag = 18;
if (editJSON["airState.reservation.advancedSchedule"][index].endHour === 255) editJSON["airState.reservation.advancedSchedule"][index].onOffFlag = 6;
this.log.debug("editJSON: " + JSON.stringify(editJSON));
data.command = "Set";
data.dataSetList = editJSON;
Expand Down
4 changes: 3 additions & 1 deletion lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,9 @@ module.exports = {
if (this.remoteValue[`${element.deviceId}.${key}`] != element.data.state.reported[key]) {
this.remoteValue[`${element.deviceId}.${key}`] = element.data.state.reported[key];
const laststate = key.split(".").pop();
await this.setStateAsync(`${element.deviceId}.remote.basicCtrl.${laststate}`, {
let folder = "basicCtrl";
if (key === "airState.2nd.operation" || key === "airState.2nd.tempState.target") folder = "2nd";
await this.setStateAsync(`${element.deviceId}.remote.${folder}.${laststate}`, {
val: element.data.state.reported[key],
ack: true,
});
Expand Down
7 changes: 7 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2531,6 +2531,13 @@ class LgThinq extends utils.Adapter {
this.log.info("The command is not implemented: " + secsplit);
return;
}
} else if (secsplit === "2nd") {
action = "basicCtrl";
rawData["command"] = lastsplit === "operation" ? "Operation" : "Set";
rawData["dataKey"] = obj.native.dataKey;
rawData["dataValue"] = state.val;
rawData["dataSetList"] = null;
rawData["dataGetList"] = null;
} else {
this.log.info("The command is not implemented");
return;
Expand Down

0 comments on commit e6e35a5

Please sign in to comment.