Skip to content

Commit

Permalink
Merge pull request #418 from mattreim/extended
Browse files Browse the repository at this point in the history
Objects for plug and configuration tool reduced
  • Loading branch information
Jey-Cee authored Nov 14, 2024
2 parents a67da17 + aa923c9 commit 2a66a69
Showing 1 changed file with 61 additions and 66 deletions.
127 changes: 61 additions & 66 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,14 +1322,7 @@ async function setGroupState(parameters, groupId, stateId) {
}
} //END setGroupState -------------------------------------------------------------------------------------------------

async function setGroupScene(
parameters,
groupId,
sceneId,
action,
stateId,
method
) {
async function setGroupScene(parameters, groupId, sceneId, action, stateId, method) {
let sceneString = "";
if (sceneId > 0) {
sceneString = "/" + sceneId;
Expand Down Expand Up @@ -1561,7 +1554,7 @@ async function getSensor(sensorId) {
for (let z = 0; z <= count2; z++) {
let stateName = Object.keys(list["state"])[z];

if (stateName === "buttonevent" && list["modelid"] === "lumi.Sensors.switch.aq2") {
if (stateName === "buttonevent" && (list["modelid"] === "lumi.sensor_switch" || list["modelid"] === "lumi.sensor_switch.aq2")) {
let LastUpdate = Number(new Date(list["state"]["lastupdated"]));
let Now = Number(new Date().getTime());
let dateOff = new Date();
Expand Down Expand Up @@ -1775,63 +1768,65 @@ async function createLightDevice(list, keyName, lightID) {
stateName,
list[keyName]["state"][stateName]
);
await SetObjectAndState(
lightID,
list[keyName]["name"],
"Lights",
"transitiontime",
null
);
await SetObjectAndState(
lightID,
list[keyName]["name"],
"Lights",
"level",
null
);
adapter.setObjectNotExists(`Lights.${lightID}.dimspeed`, {
type: "state",
common: {
name: list[keyName]["name"] + " " + "dimspeed",
type: "number",
role: "level.dimspeed",
min: 0,
max: 255,
read: false,
write: true,
},
native: {},
});
adapter.setObjectNotExists(`Lights.${lightID}.dimup`, {
type: "state",
common: {
name: list[keyName]["name"] + " " + "dimup",
role: "button",
type: "boolean",
read: false,
write: true,
},
});
adapter.setObjectNotExists(`Lights.${lightID}.dimdown`, {
type: "state",
common: {
name: list[keyName]["name"] + " " + "dimdown",
role: "button",
type: "boolean",
read: false,
write: true,
},
});
adapter.setObjectNotExists(`Lights.${lightID}.action`, {
type: "state",
common: {
name: list[keyName]["name"] + " " + "action",
role: "argument",
type: "string",
read: false,
write: true,
},
});
if (list[keyName]['type'] !== "On/Off plug-in unit" && list[keyName]['type'] !== "On/Off light" && list[keyName]['type'] !== "Configuration tool") {
await SetObjectAndState(
lightID,
list[keyName]["name"],
"Lights",
"transitiontime",
null
);
await SetObjectAndState(
lightID,
list[keyName]["name"],
"Lights",
"level",
null
);
adapter.setObjectNotExists(`Lights.${lightID}.dimspeed`, {
type: "state",
common: {
name: list[keyName]["name"] + " " + "dimspeed",
type: "number",
role: "level.dimspeed",
min: 0,
max: 255,
read: false,
write: true,
},
native: {},
});
adapter.setObjectNotExists(`Lights.${lightID}.dimup`, {
type: "state",
common: {
name: list[keyName]["name"] + " " + "dimup",
role: "button",
type: "boolean",
read: false,
write: true,
},
});
adapter.setObjectNotExists(`Lights.${lightID}.dimdown`, {
type: "state",
common: {
name: list[keyName]["name"] + " " + "dimdown",
role: "button",
type: "boolean",
read: false,
write: true,
},
});
adapter.setObjectNotExists(`Lights.${lightID}.action`, {
type: "state",
common: {
name: list[keyName]["name"] + " " + "action",
role: "argument",
type: "string",
read: false,
write: true,
},
});
}
}
}
}
Expand Down

0 comments on commit 2a66a69

Please sign in to comment.