iobroker.public-holidays
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"common": { | ||
"name": "public-holidays", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"news": { | ||
"0.0.2": { | ||
"en": "Fix on first select no data where loaded \nAdd new holidays for Austria \nLoad new holidays to configuration", | ||
"de": "Fix bei der ersten Auswahl wurden keine Daten geladen \nHinzufügen neuer Feiertage für Österreich \nLaden neuer Feiertage in die Konfiguration" | ||
}, | ||
"0.0.1": { | ||
@@ -7,0 +11,0 @@ "en": "initial release", |
@@ -13,3 +13,41 @@ [ | ||
"enabled": true | ||
}, | ||
{ | ||
"id": "nationalHoliday", | ||
"name": "Staatsfeiertag", | ||
"type": "political", | ||
"date": "05-01", | ||
"states": "Alle", | ||
"ruleType": "fixed", | ||
"offsetDay": null, | ||
"referenceHoliday": null, | ||
"weekdayInMonth": null, | ||
"enabled": true | ||
}, | ||
{ | ||
"id": "assumptionOfMary", | ||
"name": "Maria-Himmelfahrt", | ||
"type": "religion", | ||
"date": "08-15", | ||
"states": "Alle", | ||
"ruleType": "fixed", | ||
"offsetDay": null, | ||
"referenceHoliday": null, | ||
"weekdayInMonth": null, | ||
"enabled": true | ||
}, | ||
{ | ||
"id": "nationalHoliday", | ||
"name": "Nationalfeiertag", | ||
"type": "political", | ||
"date": "10-26", | ||
"states": "Alle", | ||
"ruleType": "fixed", | ||
"offsetDay": null, | ||
"referenceHoliday": null, | ||
"weekdayInMonth": null, | ||
"enabled": true | ||
} | ||
] |
35
main.js
@@ -42,5 +42,3 @@ 'use strict'; | ||
} | ||
if (JSON.stringify(lastSettings) === JSON.stringify(this.config)) { | ||
break updateSettings; | ||
} | ||
const adapterObject = await this.getForeignObjectAsync( | ||
@@ -50,2 +48,31 @@ 'system.adapter.public-holidays.' + this.instance | ||
// Check if new holidays exist in the country code holidays, add them if they do | ||
const currentHolidays = adapterObject.native['holidays'] || []; | ||
if (this.config.country === 'de') { | ||
const newHolidays = deHolidays.filter(holiday => !currentHolidays.find(current => current.name === holiday.name)); | ||
if (newHolidays.length > 0) { | ||
adapterObject.native['holidays'] = [...currentHolidays, ...newHolidays]; | ||
await this.setState(`info.lastSettings`, { val: adapterObject.native, ack: true }); | ||
await this.setForeignObjectAsync( | ||
'system.adapter.public-holidays.' + this.instance, | ||
adapterObject, | ||
); | ||
} | ||
} else if (this.config.country === 'at') { | ||
const newHolidays = atHolidays.filter(holiday => !currentHolidays.find(current => current.name === holiday.name)); | ||
if (newHolidays.length > 0) { | ||
adapterObject.native['holidays'] = [...currentHolidays, ...newHolidays]; | ||
await this.setState(`info.lastSettings`, { val: adapterObject.native, ack: true }); | ||
await this.setForeignObjectAsync( | ||
'system.adapter.public-holidays.' + this.instance, | ||
adapterObject, | ||
); | ||
} | ||
} | ||
if (JSON.stringify(lastSettings) === JSON.stringify(this.config)) { | ||
break updateSettings; | ||
} | ||
if (adapterObject === null || adapterObject === undefined) { | ||
@@ -55,3 +82,3 @@ break updateSettings; | ||
// Load original Settings after changing country | ||
if (adapterObject.native.country !== lastSettings.country) { | ||
if (lastSettings === '' || adapterObject.native.country !== lastSettings?.country) { | ||
@@ -58,0 +85,0 @@ delete adapterObject.native['holidays']; |
{ | ||
"name": "iobroker.public-holidays", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Calculates public holidays", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80076
868