Skip to content

Commit

Permalink
Translated all objects
Browse files Browse the repository at this point in the history
  • Loading branch information
klein0r committed Nov 14, 2021
1 parent 2017918 commit 98d572b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 34 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ iobroker add trashschedule
### **WORK IN PROGRESS**
-->

### 1.3.4

* (klein0r) Translated all objects

### 1.3.3

* (klein0r) Translated admin table headers
Expand Down
14 changes: 13 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"common": {
"name": "trashschedule",
"version": "1.3.3",
"version": "1.3.4",
"news": {
"1.3.4": {
"en": "Translated all objects",
"de": "Alle Objekte übersetzt",
"ru": "Переведены все объекты",
"pt": "Todos os objetos traduzidos",
"nl": "Alle objecten vertaald",
"fr": "Traduit tous les objets",
"it": "Tradotto tutti gli oggetti",
"es": "Traducido todos los objetos",
"pl": "Przetłumaczono wszystkie obiekty",
"zh-cn": "翻译所有对象"
},
"1.3.3": {
"en": "Translated admin table headers",
"de": "Übersetzte Kopfzeilen der Admin-Tabelle",
Expand Down
64 changes: 32 additions & 32 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class Trashschedule extends utils.Adapter {
return id.replace(re, '');
}

updateByCalendarTable(data) {
async updateByCalendarTable(data) {
this.log.debug('(0) updating data');

// Added compatibility with iCal 1.10.0
Expand All @@ -358,7 +358,7 @@ class Trashschedule extends utils.Adapter {

// Array should be sorted by date (done by ical)
if (data && Array.isArray(data) && data.length > 0) {
this.setStateAsync('info.connection', true, true);
await this.setStateAsync('info.connection', true, true);

this.log.debug('(0) start processing ' + data.length + ' iCal events');

Expand Down Expand Up @@ -414,13 +414,13 @@ class Trashschedule extends utils.Adapter {
if (!filledTypes.includes(trashName)) {
filledTypes.push(trashName);

this.setStateAsync('type.' + trashNameClean + '.nextDate', date.getTime(), true);
this.setStateAsync('type.' + trashNameClean + '.nextDateFormat', this.formatDate(date), true);
this.setStateAsync('type.' + trashNameClean + '.nextDescription', entry._section, true);
this.setStateAsync('type.' + trashNameClean + '.nextWeekday', date.getDay(), true);
this.setStateAsync('type.' + trashNameClean + '.daysLeft', dayDiff, true);
this.setStateAsync('type.' + trashNameClean + '.nextDateFound', true, true);
this.setStateAsync('type.' + trashNameClean + '.color', trashType.color, true);
await this.setStateAsync('type.' + trashNameClean + '.nextDate', date.getTime(), true);
await this.setStateAsync('type.' + trashNameClean + '.nextDateFormat', this.formatDate(date), true);
await this.setStateAsync('type.' + trashNameClean + '.nextDescription', entry._section, true);
await this.setStateAsync('type.' + trashNameClean + '.nextWeekday', date.getDay(), true);
await this.setStateAsync('type.' + trashNameClean + '.daysLeft', dayDiff, true);
await this.setStateAsync('type.' + trashNameClean + '.nextDateFound', true, true);
await this.setStateAsync('type.' + trashNameClean + '.color', trashType.color, true);

jsonSummary.push(
{
Expand Down Expand Up @@ -468,11 +468,11 @@ class Trashschedule extends utils.Adapter {
this.log.warn('no events matches type "' + trashName + '" with match "' + trashType.match + '". Check configuration of iCal (increase preview) and trashschedule!');

// reset values
this.setStateAsync('type.' + trashNameClean + '.nextDate', 0, true);
this.setStateAsync('type.' + trashNameClean + '.nextDateFormat', '', true);
this.setStateAsync('type.' + trashNameClean + '.nextWeekday', null, true);
this.setStateAsync('type.' + trashNameClean + '.daysLeft', null, true);
this.setStateAsync('type.' + trashNameClean + '.nextDateFound', false, true);
await this.setStateAsync('type.' + trashNameClean + '.nextDate', 0, true);
await this.setStateAsync('type.' + trashNameClean + '.nextDateFormat', '', true);
await this.setStateAsync('type.' + trashNameClean + '.nextWeekday', null, true);
await this.setStateAsync('type.' + trashNameClean + '.daysLeft', null, true);
await this.setStateAsync('type.' + trashNameClean + '.nextDateFound', false, true);
}
}

Expand All @@ -483,38 +483,38 @@ class Trashschedule extends utils.Adapter {

this.setStateAsync('type.json', JSON.stringify(jsonSummary), true);

this.fillNext(next, 'next');
this.fillNext(nextAfter, 'nextAfter');
await this.fillNext(next, 'next');
await this.fillNext(nextAfter, 'nextAfter');

} else {
this.log.error('no events found in iCal instance - check configuration and restart adapter');

this.setStateAsync('info.connection', false, true);
await this.setStateAsync('info.connection', false, true);
}
}

fillNext(obj, statePrefix) {
async fillNext(obj, statePrefix) {

this.log.debug('(5) filling "' + statePrefix + '" event with data: ' + JSON.stringify(obj));

if (obj.minDays < 999 && obj.minTypes.length > 0) {
this.setStateAsync(statePrefix + '.date', obj.minDate.getTime(), true);
this.setStateAsync(statePrefix + '.dateFormat', this.formatDate(obj.minDate), true);
this.setStateAsync(statePrefix + '.weekday', obj.minDate.getDay(), true);
this.setStateAsync(statePrefix + '.daysLeft', obj.minDays, true);
this.setStateAsync(statePrefix + '.types', obj.minTypes.join(','), true);
this.setStateAsync(statePrefix + '.typesText', obj.minTypes.join(this.config.nextseparator), true);
this.setStateAsync(statePrefix + '.dateFound', true, true);
await this.setStateAsync(statePrefix + '.date', obj.minDate.getTime(), true);
await this.setStateAsync(statePrefix + '.dateFormat', this.formatDate(obj.minDate), true);
await this.setStateAsync(statePrefix + '.weekday', obj.minDate.getDay(), true);
await this.setStateAsync(statePrefix + '.daysLeft', obj.minDays, true);
await this.setStateAsync(statePrefix + '.types', obj.minTypes.join(','), true);
await this.setStateAsync(statePrefix + '.typesText', obj.minTypes.join(this.config.nextseparator), true);
await this.setStateAsync(statePrefix + '.dateFound', true, true);
} else {
this.log.warn(statePrefix + ' has no entries. Check configuration of iCal and trashschedule!');

this.setStateAsync(statePrefix + '.date', 0, true);
this.setStateAsync(statePrefix + '.dateFormat', '', true);
this.setStateAsync(statePrefix + '.weekday', null, true);
this.setStateAsync(statePrefix + '.daysLeft', null, true);
this.setStateAsync(statePrefix + '.types', 'n/a', true);
this.setStateAsync(statePrefix + '.typesText', 'n/a', true);
this.setStateAsync(statePrefix + '.dateFound', false, true);
await this.setStateAsync(statePrefix + '.date', 0, true);
await this.setStateAsync(statePrefix + '.dateFormat', '', true);
await this.setStateAsync(statePrefix + '.weekday', null, true);
await this.setStateAsync(statePrefix + '.daysLeft', null, true);
await this.setStateAsync(statePrefix + '.types', 'n/a', true);
await this.setStateAsync(statePrefix + '.typesText', 'n/a', true);
await this.setStateAsync(statePrefix + '.dateFound', false, true);
}

}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.trashschedule",
"version": "1.3.3",
"version": "1.3.4",
"description": "Calculates the days until next trash pickup",
"author": {
"name": "Matthias Kleine",
Expand Down

0 comments on commit 98d572b

Please sign in to comment.