Skip to content

Commit

Permalink
Add dust bag reminder flag and option to set the hours until the flag…
Browse files Browse the repository at this point in the history
… is set
  • Loading branch information
mrbungle64 committed Feb 17, 2024
1 parent 4f530b0 commit cb734cb
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
13 changes: 13 additions & 0 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,19 @@
</select>
</div>
</div>
<div class="row">
<div class="col s6 input-field">
<span class="translate label">feature.info.extended.hoursUntilDustBagEmptyReminderFlagIsSet</span>
<select id="feature.info.extended.hoursUntilDustBagEmptyReminderFlagIsSet" class="value">
<option value="0" class="translate" selected>Disabled</option>
<option value="1" class="translate">1</option>
<option value="2" class="translate">2</option>
<option value="3" class="translate">3</option>
<option value="4" class="translate">4</option>
<option value="5" class="translate">5</option>
</select>
</div>
</div>
</div>
<div id="tab-experimental" class="col s12 page">
<div class="row">
Expand Down
5 changes: 5 additions & 0 deletions admin/words.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ systemDictionary = {
"de": "Automatisches Herunterladen vom Image der letzten Reinigung",
"ru": "Автоматическая загрузка последнего образа очистки"
},
"feature.info.extended.hoursUntilDustBagEmptyReminderFlagIsSet": {
"en": "Hours of cleaning time until dust bag reminder flag is set",
"de": "Reinigungszeit in Stunden, bis das Flag für die Staubbeutel-Erinnerung gesetzt wird",
"ru": "Время уборки в часах до установки флажка напоминания о пылесборнике"
},
"enableKeepLatest": {
"en": "enable download and keep the latest map image",
"de": "aktivieren und die aktuellste Karte als Datei behalten",
Expand Down
3 changes: 2 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
"feature.pauseBeforeDockingChargingStation.areasize": 500,
"feature.pauseBeforeDockingChargingStation.pauseOrStop": "pause",
"pollingInterval": 120000,
"languageForSpotAreaNames": "en"
"languageForSpotAreaNames": "en",
"hoursUntilDustBagEmptyReminderFlagIsSet": ""
},
"objects": [],
"instanceObjects": [
Expand Down
9 changes: 9 additions & 0 deletions lib/adapterObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,15 @@ async function createInitialObjects(adapter) {
'history.dateOfLastMessageReceived', 'Human readable timestamp of last message received from Ecovacs API',
'string', 'value.datetime', false, '', '');

if (adapter.getModel().isSupportedFeature('info.dustbox') &&
adapter.getHoursUntilDustBagEmptyReminderFlagIsSet() > 0) {
await adapter.createObjectNotExists(
'info.extended.dustBagEmptyReminder', 'Dust bag empty reminder',
'boolean', 'value', true, false, '');
} else {
await adapter.deleteObjectIfExists('info.extended.dustBagEmptyReminder');
}

if (adapter.getModel().isSupportedFeature('info.dustbox')) {
await adapter.createObjectNotExists(
'history.timestampOfLastTimeDustboxRemoved', 'Timestamp of last time dustbox was removed',
Expand Down
19 changes: 16 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,12 @@ class EcovacsDeebot extends utils.Adapter {
const cleaningTime = Number(cleaningTimeSinceLastDustboxRemoved.val) + diff;
await this.setStateConditionalAsync('history.cleaningTimeSinceLastDustboxRemoved', cleaningTime, true);
await this.setStateConditionalAsync('history.cleaningTimeSinceLastDustboxRemovedString', helper.getTimeStringFormatted(cleaningTime), true);
const hoursUntilDustBagEmptyReminder = this.getHoursUntilDustBagEmptyReminderFlagIsSet();
if (hoursUntilDustBagEmptyReminder > 0) {
const hoursSinceLastDustboxRemoved = Math.floor(cleaningTimeSinceLastDustboxRemoved / 3600);
const reminderValue = (hoursSinceLastDustboxRemoved >= hoursUntilDustBagEmptyReminder);
this.setStateConditional('info.extended.dustBagEmptyReminder', reminderValue, true);
}
}
}
}
Expand Down Expand Up @@ -1695,11 +1701,10 @@ class EcovacsDeebot extends utils.Adapter {
}

getPauseBeforeDockingChargingStationAreaSize() {
let areaSize = 500;
if (this.getConfigValue('feature.pauseBeforeDockingChargingStation.areasize')) {
areaSize = Number(this.getConfigValue('feature.pauseBeforeDockingChargingStation.areasize'));
return Number(this.getConfigValue('feature.pauseBeforeDockingChargingStation.areasize'));
}
return areaSize;
return 500;
}

getPauseBeforeDockingSendPauseOrStop() {
Expand All @@ -1710,6 +1715,13 @@ class EcovacsDeebot extends utils.Adapter {
return sendPauseOrStop;
}

getHoursUntilDustBagEmptyReminderFlagIsSet() {
if (this.getConfigValue('feature.info.extended.hoursUntilDustBagEmptyReminderFlagIsSet')) {
return Number(this.getConfigValue('feature.info.extended.hoursUntilDustBagEmptyReminderFlagIsSet'));
}
return 0;
}

getCurrentDateAndTimeFormatted() {
return helper.getCurrentDateAndTimeFormatted(this);
}
Expand All @@ -1720,6 +1732,7 @@ class EcovacsDeebot extends utils.Adapter {
this.setStateConditional('history.cleaningTimeSinceLastDustboxRemoved', 0, true);
this.setStateConditional('history.cleaningTimeSinceLastDustboxRemovedString', helper.getTimeStringFormatted(0), true);
this.setStateConditional('history.squareMetersSinceLastDustboxRemoved', 0, true);
this.setStateConditional('info.extended.dustBagEmptyReminder', false, true);
}

downloadLastCleaningMapImage(imageUrl, configValue) {
Expand Down

0 comments on commit cb734cb

Please sign in to comment.