From 40f3cb174b1d1e63522055d7d77e1605ce883086 Mon Sep 17 00:00:00 2001 From: mrbungle64 Date: Thu, 5 Mar 2020 22:24:05 +0100 Subject: [PATCH] Remove water level lookup tables --- library/ecovacsConstants_950type.js | 14 -------------- library/ecovacsConstants_non950type.js | 14 -------------- library/ecovacsXMPP.js | 3 ++- library/vacBotCommand_950type.js | 5 ++--- library/vacBotCommand_non950type.js | 3 --- library/vacBot_950type.js | 4 ++-- library/vacBot_non950type.js | 2 +- 7 files changed, 7 insertions(+), 38 deletions(-) diff --git a/library/ecovacsConstants_950type.js b/library/ecovacsConstants_950type.js index f37cd710..9c7b0f11 100644 --- a/library/ecovacsConstants_950type.js +++ b/library/ecovacsConstants_950type.js @@ -49,20 +49,6 @@ exports.FAN_SPEED_FROM_ECOVACS = { 2: 4 //veryhigh }; -exports.WATER_LEVEL_TO_ECOVACS = { - 'low': 1, - 'medium': 2, - 'high': 3, - 'max': 4 -}; - -exports.WATER_LEVEL_FROM_ECOVACS = { - '1': 'low', - '2': 'medium', - '3': 'high', - '4': 'max' -}; - exports.CHARGE_MODE_TO_ECOVACS = { 'return': 'go', 'returning': 'returning', diff --git a/library/ecovacsConstants_non950type.js b/library/ecovacsConstants_non950type.js index b143d9d0..82b3a1da 100644 --- a/library/ecovacsConstants_non950type.js +++ b/library/ecovacsConstants_non950type.js @@ -38,20 +38,6 @@ exports.FAN_SPEED_TO_ECOVACS = { 'high': 'strong' }; -exports.WATER_LEVEL_TO_ECOVACS = { - 'low': '1', - 'medium': '2', - 'high': '3', - 'max': '4' -}; - -exports.WATER_LEVEL_FROM_ECOVACS = { - '1': 'low', - '2': 'medium', - '3': 'high', - '4': 'max' -}; - exports.FAN_SPEED_FROM_ECOVACS = { 'standard': 'normal', 'strong': 'high' diff --git a/library/ecovacsXMPP.js b/library/ecovacsXMPP.js index f1781ab3..2a8f3e9f 100644 --- a/library/ecovacsXMPP.js +++ b/library/ecovacsXMPP.js @@ -72,7 +72,8 @@ class EcovacsXMPP extends EventEmitter { } } if (secondChild.attrs.hasOwnProperty('v')) { - if (dictionary.WATER_LEVEL_FROM_ECOVACS[secondChild.attrs.v]) { + let waterLevel = parseInt(secondChild.attrs.v); + if ((waterLevel >= 1) && (waterLevel <= 4)) { command = 'WaterLevel'; } } diff --git a/library/vacBotCommand_950type.js b/library/vacBotCommand_950type.js index a0c646c3..3948707d 100644 --- a/library/vacBotCommand_950type.js +++ b/library/vacBotCommand_950type.js @@ -166,11 +166,9 @@ class SetCleanSpeed extends VacBotCommand_950type { }); } } + class SetWaterLevel extends VacBotCommand_950type { constructor(level) { - if (constants_type.WATER_LEVEL_TO_ECOVACS.hasOwnProperty(level)) { - level = constants_type.WATER_LEVEL_TO_ECOVACS[level]; - } super('setWaterInfo', { 'amount': level }); @@ -182,6 +180,7 @@ class GetWaterInfo extends VacBotCommand_950type { super('getWaterInfo'); } } + class GetPosition extends VacBotCommand_950type { constructor() { super('getPos', ["chargePos", "deebotPos"]); diff --git a/library/vacBotCommand_non950type.js b/library/vacBotCommand_non950type.js index e2ed587d..b85496bf 100644 --- a/library/vacBotCommand_non950type.js +++ b/library/vacBotCommand_non950type.js @@ -169,9 +169,6 @@ class GetCleanSpeed extends VacBotCommand_non950type { class SetWaterLevel extends VacBotCommand_non950type { constructor(level) { - if (constants_type.WATER_LEVEL_TO_ECOVACS.hasOwnProperty(level)) { - level = constants_type.WATER_LEVEL_TO_ECOVACS[level]; - } super('SetWaterPermeability', { 'v': level }); diff --git a/library/vacBot_950type.js b/library/vacBot_950type.js index c4424db0..fa1fc5d8 100644 --- a/library/vacBot_950type.js +++ b/library/vacBot_950type.js @@ -240,7 +240,7 @@ class VacBot_950type { _handle_water_level(event) { this.water_level = event['resultData']['amount']; - tools.envLog("[VacBot] *** water_level = " + constants_type.WATER_LEVEL_FROM_ECOVACS[this.water_level] + " (" + this.water_level + ")"); + tools.envLog("[VacBot] *** water_level = %s", this.water_level); } _handle_relocation_state(event) { @@ -269,7 +269,7 @@ class VacBot_950type { this.water_level = event['resultData']['amount']; this.waterbox_info = event['resultData']['enable']; tools.envLog("[VacBot] *** waterbox_info = " + this.waterbox_info); - tools.envLog("[VacBot] *** water_level = " + constants_type.WATER_LEVEL_FROM_ECOVACS[this.water_level] + " (" + this.water_level + ")"); + tools.envLog("[VacBot] *** water_level = " + this.water_level); } _handle_charge_state(event) { //has to be checked diff --git a/library/vacBot_non950type.js b/library/vacBot_non950type.js index 82c8eae0..be256dba 100644 --- a/library/vacBot_non950type.js +++ b/library/vacBot_non950type.js @@ -197,7 +197,7 @@ class VacBot_non950type { _handle_water_level(event) { if ((event.attrs) && (event.attrs['v'])) { this.water_level = event.attrs['v']; - tools.envLog("[VacBot] *** water_level = " + dictionary.WATER_LEVEL_FROM_ECOVACS[this.water_level] + " (" + this.water_level + ")"); + tools.envLog("[VacBot] *** water_level = %s", this.water_level); } }