Skip to content

Commit

Permalink
Optimization and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattreim committed Nov 21, 2024
1 parent 1428d0b commit f440e0e
Showing 1 changed file with 8 additions and 39 deletions.
47 changes: 8 additions & 39 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,6 @@ class deconz extends utils.Adapter {
parameters = '{"bri": ' + Math.round((255 / 100) * state.val) + ', "on": false}';
}
break;
case "on":
if (transitionTime === "none" || transitionTime === 0) {
parameters = '{"on": ' + JSON.stringify(state.val) + "}";
} else {
parameters = '{"transitiontime": ' + JSON.stringify(transitionTime) + ', "on": ' + JSON.stringify(state.val) + "}";
}
break;
case "stop":
if (transitionTime === "none" || transitionTime === 0) {
parameters = '{"stop": ' + JSON.stringify(state.val) + "}";
} else {
parameters = '{"transitiontime": ' + JSON.stringify(transitionTime) + ', "on": ' + JSON.stringify(state.val) + "}";
}
break;
case "hue":
if (transitionTime === "none" || transitionTime === 0) {
parameters = '{"hue": ' + Math.round(parseInt(JSON.stringify(state.val)) * hue_factor) + "}";
Expand Down Expand Up @@ -228,16 +214,11 @@ class deconz extends utils.Adapter {
let dimspeed = await this.getStateAsync(
this.name + "." + this.instance + "." + id + ".dimspeed"
);

if (dimspeed === null || dimspeed === undefined || dimspeed.val === 0) {
dimspeed = 10;
this.setState(this.name + "." + this.instance + "." + id + ".dimspeed", 10, true);
}
let speed = dp === "dimup" ? dimspeed.val : dimspeed.val * -1;
if (transitionTime !== "none") {
parameters = `{ "transitiontime": ${JSON.stringify(transitionTime)} , "bri_inc": ${speed} }`;
parameters = `{ "transitiontime": ${JSON.stringify(transitionTime)} , "bri_inc": ${speed} , "on": true}`;
} else {
parameters = `{ "bri_inc": ${speed} }`;
parameters = `{ "bri_inc": ${speed} , "on": true}`;
}
break;
case "action":
Expand Down Expand Up @@ -292,6 +273,7 @@ class deconz extends utils.Adapter {
case "lift":
case "melody":
case "mountingmode":
case "on":
case "off":
case "offset":
case "pulseconfiguration":
Expand All @@ -300,6 +282,7 @@ class deconz extends utils.Adapter {
case "setvalve":
case "sensitivity":
case "speed":
case "stop":
case "tholddark":
case "tholdoffset":
case "toggle":
Expand Down Expand Up @@ -1128,15 +1111,6 @@ async function getGroupAttributes(groupId) {
stateName,
list["state"][stateName]
);
if (!list["uniqueid"]) {
await SetObjectAndState(
groupId,
list["name"],
"Groups",
"transitiontime",
null
);
}
}
if (!list["uniqueid"]) {
await SetObjectAndState(
Expand All @@ -1152,8 +1126,9 @@ async function getGroupAttributes(groupId) {
name: list["name"] + " " + "dimspeed",
type: "number",
role: "level.dimspeed",
min: 0,
min: 1,
max: 255,
def: 10,
read: false,
write: true,
},
Expand Down Expand Up @@ -1930,8 +1905,9 @@ async function createLightDevice(list, keyName, lightID) {
name: list[keyName]["name"] + " " + "dimspeed",
type: "number",
role: "level.dimspeed",
min: 0,
min: 1,
max: 255,
def: 10,
read: false,
write: true,
},
Expand Down Expand Up @@ -1985,13 +1961,6 @@ async function createBlindsDevice(list, keyName, lightID) {
stateName,
list[keyName]["state"][stateName]
);
await SetObjectAndState(
lightID,
list[keyName]["name"],
"Lights",
"transitiontime",
null
);
adapter.setObjectNotExists(`Lights.${lightID}.stop`, {
type: "state",
common: {
Expand Down

0 comments on commit f440e0e

Please sign in to comment.