Skip to content

Commit

Permalink
Handle the different variants for Wash Interval function
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbungle64 committed Feb 2, 2024
1 parent abeee66 commit 89e819b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
29 changes: 28 additions & 1 deletion lib/adapterObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,32 @@ async function createControlCleanSpeedIfNotExists(adapter, def = 2, id = 'contro
}
}

async function createControlWashIntervalIfNotExists(adapter) {
const isT20Type = adapter.isModelTypeT20() || adapter.isModelTypeX2();
const deep = isT20Type ? 6 : 10;
const daily = isT20Type ? 10 : 15;
const efficient = isT20Type ? 15 : 25;
const states = {};
states[deep] = 'Deep';
states[daily] = 'Daily';
states[efficient] = 'Efficent';
await adapter.setObjectNotExists('control.extended.washInterval', {
'type': 'state',
'common': {
'name': 'Wash interval',
'type': 'number',
'role': 'level',
'read': true,
'write': true,
'min': deep,
'max': efficient,
'def': daily,
'states': states
},
native: {}
});
}

async function createAdditionalObjects(adapter) {

if (adapter.vacbot.hasMoppingSystem()) {
Expand Down Expand Up @@ -850,5 +876,6 @@ module.exports = {
createAdditionalObjects,
createControlCleanSpeedIfNotExists,
createControlScrubbingPatternIfNotExists,
createControlWaterLevelIfNotExists
createControlWaterLevelIfNotExists,
createControlWashIntervalIfNotExists
};
21 changes: 1 addition & 20 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,26 +388,7 @@ class EcovacsDeebot extends utils.Adapter {
'info.extended.washInterval', 'Wash interval',
'number', 'value', false, 0, 'min');
await this.setStateConditionalAsync('info.extended.washInterval', value, true);
await this.setObjectNotExistsAsync('control.extended.washInterval', {
'type': 'state',
'common': {
'name': 'Wash interval',
'type': 'number',
'role': 'value',
'read': true,
'write': true,
'min': 10,
'max': 25,
'def': 15,
'unit': 'min',
'states': {
10: '10',
15: '15',
25: '25'
}
},
'native': {}
});
await adapterObjects.createControlWashIntervalIfNotExists(this);
await this.setStateConditionalAsync('control.extended.washInterval', value, true);
})();
});
Expand Down

0 comments on commit 89e819b

Please sign in to comment.