Skip to content

Commit

Permalink
add hotwater for device 406 & 401
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucky-ESA committed Oct 23, 2024
1 parent 817e625 commit c16a86c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ Adapter for LG ThinQ
-->

## Changelog
### **WORK IN PROGRESS**

- (Lucky-ESA) Added hotwater for device 406 & 401

### 1.0.2 (2024-09-10)

- (Lucky-ESA) Dependencies updated
Expand Down
26 changes: 18 additions & 8 deletions lib/air_conditioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const new_silentMode = {
endMin: 17,
silentMode: 1,
};
const addRemote = ["airState.tempState.hotWaterTarget"];
module.exports = {
async createAirRemoteStates(device, deviceModel) {
if (!deviceModel || !deviceModel.ControlDevice) {
Expand All @@ -57,23 +58,32 @@ module.exports = {
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) => {
if (control.includes(remote)) {
isAdd = false;
if (control.includes(remote) || addRemote.includes(remote)) {
if (!control.includes(remote)) isAdd = true;
for (const dataRemote of deviceModel.ControlDevice) {
if (JSON.stringify(dataRemote).includes(remote)) {
if (JSON.stringify(dataRemote).includes(remote) || isAdd) {
const laststate = remote.split(".").pop();
if (dataRemote.dataKey || (dataRemote.dataSetList && (laststate == "jet" || laststate == "airClean"))) {
await this.setObjectNotExistsAsync(device.deviceId + ".remote." + dataRemote.ctrlKey, {
if (isAdd) {
foldername = "basicCtrl";
} else {
foldername = dataRemote.ctrlKey;
}
if (dataRemote.dataKey || (dataRemote.dataSetList && (laststate == "jet" || laststate == "airClean")) || isAdd) {
await this.setObjectNotExistsAsync(device.deviceId + ".remote." + foldername, {
type: "channel",
common: {
name: dataRemote.ctrlKey,
name: foldername,
desc: "Create by LG-Thinq Adapter",
},
native: {},
});
const obj = await this.getObjectAsync(
device.deviceId + ".remote." + dataRemote.ctrlKey + "." + laststate,
device.deviceId + ".remote." + foldername + "." + laststate,
);
common = {
name: remote,
Expand Down Expand Up @@ -124,13 +134,13 @@ module.exports = {
common.states = commons;
}
if (!obj) {
await this.createDataPoint(device.deviceId + ".remote." + dataRemote.ctrlKey + "." + laststate, common, "state", {"dataKey": remote});
await this.createDataPoint(device.deviceId + ".remote." + foldername + "." + laststate, common, "state", {"dataKey": remote});
} else {
obj.common = common;
obj.native = { dataKey: remote };
await this.setObjectAsync(
device.deviceId + ".remote." +
dataRemote.ctrlKey + "." +
foldername + "." +
laststate, obj
);
}
Expand Down

0 comments on commit c16a86c

Please sign in to comment.