Skip to content

Commit

Permalink
Remove water level lookup tables
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbungle64 committed Mar 5, 2020
1 parent 5d2466c commit 40f3cb1
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 38 deletions.
14 changes: 0 additions & 14 deletions library/ecovacsConstants_950type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 0 additions & 14 deletions library/ecovacsConstants_non950type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion library/ecovacsXMPP.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
Expand Down
5 changes: 2 additions & 3 deletions library/vacBotCommand_950type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand All @@ -182,6 +180,7 @@ class GetWaterInfo extends VacBotCommand_950type {
super('getWaterInfo');
}
}

class GetPosition extends VacBotCommand_950type {
constructor() {
super('getPos', ["chargePos", "deebotPos"]);
Expand Down
3 changes: 0 additions & 3 deletions library/vacBotCommand_non950type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down
4 changes: 2 additions & 2 deletions library/vacBot_950type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion library/vacBot_non950type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 40f3cb1

Please sign in to comment.