diff --git a/README.md b/README.md index 4df46809..3d6f0763 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ When the adapter crashes or an other Code error happens, this error message that ### __WORK IN PROGRESS__ * (simatec) Saturday added as work week * (simatec) Dependencies updated +* (simatec) Fix Auto-Living, Auto-Sleep & Auto-Children ### 1.6.2 (2023-08-28) * (simatec) Dependencies updated diff --git a/lib/shutterUpChildren.js b/lib/shutterUpChildren.js index fe96686a..b4f62627 100644 --- a/lib/shutterUpChildren.js +++ b/lib/shutterUpChildren.js @@ -18,16 +18,18 @@ async function sleep(ms) { // @ts-ignore async function driveshutterUpChildren(adapter, upTimeChildren, autoChildrenStr, shutterSettings, childrenType, driveDelayUpChildren, timeoutChildrenAuto, noGoDelay) { if (shutterSettings) { + adapter.log.debug(`Children-type: ${childrenType}`); + const resChildren = shutterSettings.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp == childrenType); // Filter Area Children const result = resChildren.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled let number = 0; - if (childrenType == 'children') { + if (childrenType === 'children') { for (const i in result) { number++; } - timeoutChildrenAuto = number * driveDelayUpChildren; + timeoutChildrenAuto = number !== 0 ? number * driveDelayUpChildren : driveDelayUpChildren; } for (const i in result) { @@ -127,7 +129,7 @@ async function driveshutterUpChildren(adapter, upTimeChildren, autoChildrenStr, } } // start children-auto after drive children shutter - if (autoChildrenStr == true && childrenType == 'children') { + if (autoChildrenStr === true && childrenType === 'children') { await sleep(timeoutChildrenAuto); childrenType = 'children-auto'; driveshutterUpChildren(adapter, upTimeChildren, autoChildrenStr, shutterSettings, childrenType, driveDelayUpChildren, timeoutChildrenAuto, noGoDelay); diff --git a/lib/shutterUpLiving.js b/lib/shutterUpLiving.js index 756e9a50..0fa7a431 100644 --- a/lib/shutterUpLiving.js +++ b/lib/shutterUpLiving.js @@ -18,16 +18,18 @@ async function sleep(ms) { // @ts-ignore async function driveshutterUpLiving(adapter, upTimeLiving, autoLivingStr, shutterSettings, livingType, driveDelayUpLiving, timeoutLivingAuto, noGoDelay) { if (shutterSettings) { + adapter.log.debug(`Living-type: ${livingType}`); + const resLiving = shutterSettings.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp == livingType); // Filter Area Living const result = resLiving.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled let number = 0; - if (livingType == 'living') { + if (livingType === 'living') { for (const i in result) { number++; } - timeoutLivingAuto = number * driveDelayUpLiving; + timeoutLivingAuto = number !== 0 ? number * driveDelayUpLiving: driveDelayUpLiving; } for (const i in result) { @@ -128,7 +130,7 @@ async function driveshutterUpLiving(adapter, upTimeLiving, autoLivingStr, shutte } } // start living-auto after drive living shutter - if (autoLivingStr == true && livingType == 'living') { + if (autoLivingStr === true && livingType === 'living') { await sleep(timeoutLivingAuto); livingType = 'living-auto'; driveshutterUpLiving(adapter, upTimeLiving, autoLivingStr, shutterSettings, livingType, driveDelayUpLiving, timeoutLivingAuto, noGoDelay); diff --git a/lib/shutterUpSleep.js b/lib/shutterUpSleep.js index aeb3cbb8..74b2d92f 100644 --- a/lib/shutterUpSleep.js +++ b/lib/shutterUpSleep.js @@ -18,9 +18,10 @@ async function sleep(ms) { // @ts-ignore async function driveshutterUpSleep(adapter, upTimeSleep, autoSleepStr, shutterSettings, sleepType, driveDelayUpSleep, timeoutSleepAuto, noGoDelay) { if (shutterSettings) { + adapter.log.debug(`Sleep-type: ${sleepType}`); const resSleep = shutterSettings.filter((/** @type {{ typeUp: any; }} */ d) => d.typeUp == sleepType); // Filter Area sleep - let result = resSleep.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled + const result = resSleep.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled ; let number = 0; @@ -28,7 +29,7 @@ async function driveshutterUpSleep(adapter, upTimeSleep, autoSleepStr, shutterSe for (const i in result) { number++; } - timeoutSleepAuto = number * driveDelayUpSleep; + timeoutSleepAuto = number !== 0 ? number * driveDelayUpSleep : driveDelayUpSleep; } for (const i in result) { @@ -128,7 +129,7 @@ async function driveshutterUpSleep(adapter, upTimeSleep, autoSleepStr, shutterSe } } // start sleep-auto after drive sleep shutter - if (autoSleepStr == true && sleepType == 'sleep') { + if (autoSleepStr === true && sleepType === 'sleep') { await sleep(timeoutSleepAuto); sleepType = 'sleep-auto'; driveshutterUpSleep(adapter, upTimeSleep, autoSleepStr, shutterSettings, sleepType, driveDelayUpSleep, timeoutSleepAuto, noGoDelay); diff --git a/main.js b/main.js index e4ee02f5..81439f93 100644 --- a/main.js +++ b/main.js @@ -1193,14 +1193,14 @@ function delayCalc() { const resultFull = shutterSettings; // Full Result if (resultFull) { - if ((upTimeLiving) === (upTimeSleep)) { + if (upTimeLiving === upTimeSleep) { const resLiving = resultFull.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp === 'living'); // Filter Area Living const result = resLiving.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled for (const i in result) { delayUp++; } - if ((autoLivingStr) === true) { + if (autoLivingStr === true) { const resLivingAuto = resultFull.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp === 'living-auto'); // Filter Area Living const result2 = resLivingAuto.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled @@ -1210,7 +1210,7 @@ function delayCalc() { } } - if ((upTimeSleep) === (upTimeChildren)) { + if (upTimeSleep === upTimeChildren) { delayUpChildren = delayUp; const resLiving = resultFull.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp === 'sleep'); // Filter Area Sleep @@ -1219,7 +1219,7 @@ function delayCalc() { for (const i in result) { delayUpChildren++; } - if ((autoSleepStr) === true) { + if (autoSleepStr === true) { const resLivingAuto = resultFull.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp === 'sleep-auto'); // Filter Area Sleep const result2 = resLivingAuto.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled @@ -1228,14 +1228,14 @@ function delayCalc() { } } } - if ((downTimeLiving) === (downTimeSleep)) { + if (downTimeLiving === downTimeSleep) { const resLiving2 = resultFull.filter((/** @type {{ typeDown: string; }} */ d) => d.typeDown === 'living'); // Filter Area Living const result3 = resLiving2.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled for (const i in result3) { delayDown++; } - if ((autoLivingStr) === true) { + if (autoLivingStr === true) { const resLivingAuto2 = resultFull.filter((/** @type {{ typeDown: string; }} */ d) => d.typeDown === 'living-auto'); // Filter Area Living const result4 = resLivingAuto2.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled @@ -1245,7 +1245,7 @@ function delayCalc() { } } - if ((downTimeSleep) === (downTimeChildren)) { + if (downTimeSleep === downTimeChildren) { delayDownChildren = delayDown; const resLiving2 = resultFull.filter((/** @type {{ typeDown: string; }} */ d) => d.typeDown === 'sleep'); // Filter Area Sleep @@ -1255,7 +1255,7 @@ function delayCalc() { delayDownChildren++; } - if ((autoSleepStr) === true) { + if (autoSleepStr === true) { const resLivingAuto2 = resultFull.filter((/** @type {{ typeDown: string; }} */ d) => d.typeDown === 'sleep-auto'); // Filter Area Sleep const result4 = resLivingAuto2.filter((/** @type {{ enabled: boolean; }} */ d) => d.enabled === true); // Filter enabled