Skip to content

Commit

Permalink
add serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Nov 11, 2023
1 parent 2df9c45 commit 90add37
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ class Hoover extends utils.Adapter {
})
.then(async (res) => {
this.log.debug(JSON.stringify(res.data));

let appliances;
if (this.config.type === "wizard") {
appliances = res.data;
Expand All @@ -451,7 +452,7 @@ class Hoover extends utils.Adapter {
if (device.appliance) {
device = device.appliance;
}
let id = device.macAddress;
let id = device.macAddress || device.serialNumber;
if (this.config.type === "wizard") {
id = device.id;
}
Expand All @@ -460,6 +461,9 @@ class Hoover extends utils.Adapter {
if (device.modelName) {
name += " " + device.modelName;
}
if (device.nickName) {
name += " " + device.nickName;
}
await this.setObjectNotExistsAsync(id, {
type: "device",
common: {
Expand Down Expand Up @@ -701,18 +705,20 @@ class Hoover extends utils.Adapter {
this.device.on("connect", () => {
this.log.info("mqtt connected");
for (const device of this.deviceArray) {
this.log.info(`subscribe to ${device.macAddress}`);
this.device.subscribe("haier/things/" + device.macAddress + "/event/appliancestatus/update");
this.device.subscribe("haier/things/" + device.macAddress + "/event/discovery/update");
this.device.subscribe("$aws/events/presence/connected/" + device.macAddress);
const id = device.macAddress || device.serialNumber;
this.log.info(`subscribe to ${id}`);
this.device.subscribe("haier/things/" + id + "/event/appliancestatus/update");
this.device.subscribe("haier/things/" + id + "/event/discovery/update");
this.device.subscribe("$aws/events/presence/connected/" + id);
}
});

this.device.on("message", (topic, payload) => {
this.log.debug(`message ${topic} ${payload.toString()}`);
try {
const message = JSON.parse(payload.toString());
this.json2iob.parse(message.macAddress + ".stream", message, {
const id = message.macAddress || message.serialNumber;
this.json2iob.parse(id + ".stream", message, {
preferedArrayName: "parName",
channelName: "data from mqtt stream",
});
Expand Down Expand Up @@ -748,7 +754,7 @@ class Hoover extends utils.Adapter {
"accept-language": "de-de",
};
for (const device of this.deviceArray) {
const id = device.macAddress;
const id = device.macAddress || device.serialNumber;
for (const element of statusArray) {
let url = element.url.replace("$mac", id);
url = url.replace("$type", device.applianceTypeName);
Expand Down

0 comments on commit 90add37

Please sign in to comment.