From 89e819b6efc007878ac91cdc0bcf17883cf7ce7b Mon Sep 17 00:00:00 2001 From: mrbungle64 Date: Fri, 2 Feb 2024 10:52:33 +0100 Subject: [PATCH] Handle the different variants for Wash Interval function --- lib/adapterObjects.js | 29 ++++++++++++++++++++++++++++- main.js | 21 +-------------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/lib/adapterObjects.js b/lib/adapterObjects.js index f4f7511b..b4bd981d 100644 --- a/lib/adapterObjects.js +++ b/lib/adapterObjects.js @@ -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()) { @@ -850,5 +876,6 @@ module.exports = { createAdditionalObjects, createControlCleanSpeedIfNotExists, createControlScrubbingPatternIfNotExists, - createControlWaterLevelIfNotExists + createControlWaterLevelIfNotExists, + createControlWashIntervalIfNotExists }; diff --git a/main.js b/main.js index 0e5dfb6b..de7db741 100644 --- a/main.js +++ b/main.js @@ -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); })(); });