Skip to content

Commit

Permalink
fixed AutoOnLux
Browse files Browse the repository at this point in the history
  • Loading branch information
Schmakus committed Sep 22, 2023
1 parent dda5a86 commit 139d40b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ iobroker add lightcontrol
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->

### **WORK IN PROGRESS**

- (Schmakus) update dependencies
- (Schmakus) fixed AutoOnLux (Cannot read properties of undefined (reading 'minLux'))

### 0.4.0 (2023-08-16)

- (Schmakus) Node >=16 and NPM >=7 necessary!
Expand Down
25 changes: 13 additions & 12 deletions lib/switchingOnOff.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,18 +498,25 @@ async function AutoOnLux(adapter, Group) {
const LightGroups = adapter.LightGroups;
try {
adapter.log.debug(
`Reaching AutoOnLux for Group="${Group} enabled="${LightGroups[Group].autoOnLux?.enabled}", actuallux="${LightGroups[Group].actualLux}", minLux="${LightGroups[Group].autoOnLux.minLux}" LightGroups[Group].autoOnLux.dailyLock="${LightGroups[Group].autoOnLux.dailyLock}"`,
`Reaching AutoOnLux for Group="${Group} enabled="${LightGroups[Group].autoOnLux?.enabled}", actuallux="${LightGroups[Group].actualLux}", minLux="${LightGroups[Group].autoOnLux?.minLux}" LightGroups[Group].autoOnLux.dailyLock="${LightGroups[Group].autoOnLux?.dailyLock}"`,
);

let tempBri = 0;
let tempColor = "";

if (LightGroups[Group].autoOnLux.operator == "<") {
let minLux = 500;

if (LightGroups[Group].autoOnLux?.minLux === undefined) {
minLux = 500;
adapter.writeLog(`[ AutoOnLux ] No minLux defined for Group="${Group}". Use default minLux of 500lux`);
}

if (LightGroups[Group].autoOnLux?.operator == "<") {
if (
LightGroups[Group].autoOnLux?.enabled &&
!LightGroups[Group].power &&
!LightGroups[Group].autoOnLux?.dailyLock &&
LightGroups[Group].actualLux <= LightGroups[Group].autoOnLux?.minLux
LightGroups[Group].actualLux <= minLux
) {
adapter.log.info(`AutoOn_Lux() activated Group="${Group}"`);

Expand All @@ -533,10 +540,7 @@ async function AutoOnLux(adapter, Group) {
LightGroups[Group].autoOnLux.dailyLock = true;

await adapter.setStateAsync(Group + ".autoOnLux.dailyLock", true, true);
} else if (
LightGroups[Group].autoOnLux.dailyLock &&
LightGroups[Group].actualLux > LightGroups[Group].autoOnLux.minLux
) {
} else if (LightGroups[Group].autoOnLux.dailyLock && LightGroups[Group].actualLux > minLux) {
//DailyLock zurücksetzen

LightGroups[Group].autoOnLux.dailyLockCounter++;
Expand All @@ -555,7 +559,7 @@ async function AutoOnLux(adapter, Group) {
LightGroups[Group].autoOnLux.enabled &&
!LightGroups[Group].power &&
!LightGroups[Group].autoOnLux.dailyLock &&
LightGroups[Group].actualLux >= LightGroups[Group].autoOnLux.minLux
LightGroups[Group].actualLux >= minLux
) {
adapter.log.info(`AutoOn_Lux() activated Group="${Group}"`);

Expand All @@ -578,10 +582,7 @@ async function AutoOnLux(adapter, Group) {

LightGroups[Group].autoOnLux.dailyLock = true;
await adapter.setStateAsync(Group + ".autoOnLux.dailyLock", true, true);
} else if (
LightGroups[Group].autoOnLux.dailyLock &&
LightGroups[Group].actualLux < LightGroups[Group].autoOnLux.minLux
) {
} else if (LightGroups[Group].autoOnLux.dailyLock && LightGroups[Group].actualLux < minLux) {
//DailyLock zurücksetzen

LightGroups[Group].autoOnLux.dailyLockCounter++;
Expand Down

0 comments on commit 139d40b

Please sign in to comment.