Skip to content

Commit

Permalink
(simatec) Fix eslint error
Browse files Browse the repository at this point in the history
  • Loading branch information
simatec committed Dec 9, 2024
1 parent cb080c8 commit 236ecf1
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 460 deletions.
21 changes: 20 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default [
'test/**/*.js',
'*.config.mjs',
'build',
'admin/**/*.js',
'admin/build',
'admin/words.js',
'admin/admin.d.ts',
Expand All @@ -25,7 +26,25 @@ export default [
// you may disable some 'jsdoc' warnings - but using jsdoc is highly recommended
// as this improves maintainability. jsdoc warnings will not block buiuld process.
rules: {
// 'jsdoc/require-jsdoc': 'off',
'jsdoc/require-jsdoc': 'off',
'no-async-promise-executor': 'off',
'prettier/prettier': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'curly': 'off',
'jsdoc/require-returns-description': 'off',
'no-else-return': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'jsdoc/require-param-description': 'off',
'no-constant-binary-expression': 'off',
'valid-typeof': 'off',
'no-irregular-whitespace': 'off',
//'no-prototype-builtins': 'off',
//'no-case-declarations': 'off',
//'no-useless-escape': 'off',
//'jsdoc/require-param': 'off',
//'@typescript-eslint/no-require-imports': 'off',
'jsdoc/no-types': 'off',
//'jsdoc/tag-lines': 'off',
},
},

Expand Down
37 changes: 17 additions & 20 deletions lib/buttonAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,47 @@ async function buttonAction(adapter, buttonState, shutterSettings) {
if (shutterSettings) {
switch (buttonState) {
case 'openLiving':
resLiving = shutterSettings.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp == 'living' || d.typeUp == 'living-auto');
resLiving = shutterSettings.filter((d) => d.typeUp == 'living' || d.typeUp == 'living-auto');
break;
case 'closeLiving':
resLiving = shutterSettings.filter((/** @type {{ typeDown: string; typeUp: string; }} */ d) => d.typeDown == 'living' || d.typeUp == 'living-auto');
resLiving = shutterSettings.filter((d) => d.typeDown == 'living' || d.typeUp == 'living-auto');
break;
case 'openSleep':
resLiving = shutterSettings.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp == 'sleep' || d.typeUp == 'sleep-auto');
resLiving = shutterSettings.filter((d) => d.typeUp == 'sleep' || d.typeUp == 'sleep-auto');
break;
case 'closeSleep':
resLiving = shutterSettings.filter((/** @type {{ typeDown: string; typeUp: string; }} */ d) => d.typeDown == 'sleep' || d.typeUp == 'sleep-auto');
resLiving = shutterSettings.filter((d) => d.typeDown == 'sleep' || d.typeUp == 'sleep-auto');
break;
case 'openChildren':
resLiving = shutterSettings.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp == 'children' || d.typeUp == 'children-auto');
resLiving = shutterSettings.filter((d) => d.typeUp == 'children' || d.typeUp == 'children-auto');
break;
case 'closeChildren':
resLiving = shutterSettings.filter((/** @type {{ typeDown: string; typeUp: string; }} */ d) => d.typeDown == 'children' || d.typeUp == 'children-auto');
resLiving = shutterSettings.filter((d) => d.typeDown == 'children' || d.typeUp == 'children-auto');
break;
case 'openAll':
resLiving = shutterSettings.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp != 'manual-only');
resLiving = shutterSettings.filter((d) => d.typeUp != 'manual-only');
break;
case 'closeAll':
resLiving = shutterSettings.filter((/** @type {{ typeDown: string; }} */ d) => d.typeDown != 'manual-only');
resLiving = shutterSettings.filter((d) => d.typeDown != 'manual-only');
break;
case 'sunProtect':
resLiving = shutterSettings.filter((/** @type {{ typeDown: string; }} */ d) => d.typeDown != 'manual-only');
resLiving = shutterSettings.filter((d) => d.typeDown != 'manual-only');
break;
case 'sunProtectSleep':
resLiving = shutterSettings.filter((/** @type {{ typeDown: string; typeUp: string; }} */ d) => d.typeDown == 'sleep' || d.typeUp == 'sleep-auto');
resLiving = shutterSettings.filter((d) => d.typeDown == 'sleep' || d.typeUp == 'sleep-auto');
break;
case 'sunProtectChildren':
resLiving = shutterSettings.filter((/** @type {{ typeDown: string; typeUp: string; }} */ d) => d.typeDown == 'children' || d.typeUp == 'children-auto');
resLiving = shutterSettings.filter((d) => d.typeDown == 'children' || d.typeUp == 'children-auto');
break;
case 'sunProtectLiving':
resLiving = shutterSettings.filter((/** @type {{ typeDown: string; typeUp: string; }} */ d) => d.typeDown == 'living' || d.typeUp == 'living-auto');
resLiving = shutterSettings.filter((d) => d.typeDown == 'living' || d.typeUp == 'living-auto');
break;
case 'autoAll':
resLiving = shutterSettings.filter((/** @type {{ typeUp: string; }} */ d) => d.typeUp != 'manual-only');
resLiving = shutterSettings.filter((d) => d.typeUp != 'manual-only');
break;
}

const result = resLiving.filter((/** @type {{ enabled: boolean | string; }} */ d) => d.enabled === true || d.enabled === 'true'); // Filter enabled
const result = resLiving.filter((d) => d.enabled === true || d.enabled === 'true'); // Filter enabled

for (const i in result) {
for (const s in shutterSettings) {
Expand Down Expand Up @@ -105,8 +105,7 @@ async function buttonAction(adapter, buttonState, shutterSettings) {
await setShutterState(adapter, shutterSettings, shutterSettings[s], targetLevel2Set, nameDevice, `Button ${buttonState}`);

adapter.log.debug(`shutterDownButton ${shutterSettings[s].shutterName} old height: ${shutterSettings[s].oldHeight}% new height: ${targetLevel2Set}%`);
}
else if (_shutterState?.val !== null && _shutterState?.val !== undefined &&
} else if (_shutterState?.val !== null && _shutterState?.val !== undefined &&
Math.round(_shutterState.val / adapter.config.shutterStateRound) * adapter.config.shutterStateRound == targetLevel2Set) {

shutterSettings[s].currentHeight = targetLevel2Set;
Expand Down Expand Up @@ -138,8 +137,7 @@ async function buttonAction(adapter, buttonState, shutterSettings) {
await setShutterState(adapter, shutterSettings, shutterSettings[s], parseFloat(shutterSettings[s].heightUp), nameDevice, `Button ${buttonState}`);

adapter.log.debug(`shutterUpButton ${shutterSettings[s].shutterName} old height: ${shutterSettings[s].oldHeight}% new height: ${shutterSettings[s].heightUp}%`);
}
else if (_shutterState?.val !== null && _shutterState?.val !== undefined &&
} else if (_shutterState?.val !== null && _shutterState?.val !== undefined &&
Math.round(_shutterState.val / adapter.config.shutterStateRound) * adapter.config.shutterStateRound == shutterSettings[s].heightUp) {

shutterSettings[s].currentHeight = shutterSettings[s].heightUp;
Expand Down Expand Up @@ -173,8 +171,7 @@ async function buttonAction(adapter, buttonState, shutterSettings) {
await setShutterState(adapter, shutterSettings, shutterSettings[s], parseFloat(shutterSettings[s].heightDownSun), nameDevice, `Button ${buttonState}`);

adapter.log.debug(`shutterUpButton ${shutterSettings[s].shutterName} old height: ${shutterSettings[s].oldHeight}% new height: ${shutterSettings[s].heightUp}%`);
}
else if (_shutterState?.val !== null && _shutterState?.val !== undefined &&
} else if (_shutterState?.val !== null && _shutterState?.val !== undefined &&
Math.round(_shutterState.val / adapter.config.shutterStateRound) * adapter.config.shutterStateRound == shutterSettings[s].heightDownSun) {

shutterSettings[s].currentHeight = shutterSettings[s].heightDownSun;
Expand Down
Loading

0 comments on commit 236ecf1

Please sign in to comment.