From 67b8d1b2f8060ee8904ba69582aa6d080b164baa Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 6 Feb 2024 20:51:03 +0100 Subject: [PATCH] var --- admin/index_m.html | 14 +++++++++----- io-package.json | 45 ++++++++++++++++++++++++++++++++++++++++++++- main.js | 33 +++++++++------------------------ 3 files changed, 62 insertions(+), 30 deletions(-) diff --git a/admin/index_m.html b/admin/index_m.html index 0da6e91..a0aa56b 100755 --- a/admin/index_m.html +++ b/admin/index_m.html @@ -124,10 +124,6 @@ function findGeoCode(){ console.log('Start import geocode') document.getElementById("loader").style.display = "block"; - //$('#loader1').removeClass('seenot'); - - //const geoCodeJSON = require('./meteoalarm/geocodes.json') - //turf = require('@turf/turf') $.getJSON('geocodes.json', function(data) { @@ -137,13 +133,16 @@ locationArray = [] + var geocodeNameArray = [] for(let i = 0; i < crs.length; i++) { var loccode = crs[i].properties.code let polygon = JSON.stringify(crs[i].geometry.coordinates) let type = JSON.stringify(crs[i].properties.type) + let geocodeLocation = crs[i].properties.name if (checkIfInPoly(polygon)){ locationArray.push(loccode) + geocodeNameArray.push(geocodeLocation) } //console.log('Code: ' + loccode) @@ -156,6 +155,8 @@ // geocode gefunden $("#geocode").val(locationArray); + $("#geocodeLocation").val(geocodeNameArray); + } else{ console.log('Geocode not found') @@ -536,7 +537,7 @@
chooseAlarmLocation
-
+
@@ -567,6 +568,9 @@
chooseAlarmLocation
+ +
+ diff --git a/io-package.json b/io-package.json index 31dcbf9..144bbea 100755 --- a/io-package.json +++ b/io-package.json @@ -256,7 +256,50 @@ "sentry": { "dsn": "https://336269261940428d9f3093e61a6e06c6@sentry.iobroker.net/124" } - } + }, + "messages": [ + { + "condition": { + "operand": "and", + "rules": [ + "oldVersion<3.0.0", + "newVersion>=3.0.0" + ] + }, + "title": { + "en": "Important notice!", + "de": "Wichtiger Hinweis!", + "ru": "Важное замечание!", + "pt": "Notícia importante!", + "nl": "Belangrijke mededeling!", + "fr": "Avis important!", + "it": "Avviso IMPORTANTE!", + "es": "Noticia importante!", + "pl": "Ważna uwaga!", + "zh-cn": "重要通知!", + "uk": "Важливе повідомлення!" + }, + "text": { + "en": "This update contains a breaking change. Please go to the setup and maintain the location. Otherwise, the alarms will not work any more.", + "de": "Dieses Update enthält eine kritische Änderung. Bitte gehen Sie zum Setup und halten Sie den Standort. Sonst funktionieren die Alarme nicht mehr.", + "ru": "Это обновление содержит нарушающие изменения. Пожалуйста, отправляйтесь на установку и сохраняйте местоположение. В противном случае тревога больше не будет работать.", + "pt": "Esta atualização contém uma mudança de ruptura. Por favor, vá para a configuração e mantenha a localização. Caso contrário, os alarmes não funcionarão mais.", + "nl": "Deze update bevat een breuk verandering. Ga naar de setup en onderhoud de locatie. Anders werkt het alarm niet meer.", + "fr": "Cette mise à jour contient un changement de rupture. Veuillez aller à l'installation et maintenir l'emplacement. Sinon, les alarmes ne fonctionneront plus.", + "it": "Questo aggiornamento contiene un cambiamento di rottura. Si prega di andare alla configurazione e mantenere la posizione. Altrimenti, gli allarmi non funzioneranno più.", + "es": "Esta actualización contiene un cambio de ruptura. Por favor, vaya a la configuración y mantenga la ubicación. De lo contrario, las alarmas ya no funcionarán.", + "pl": "Ta aktualizacja zawiera przełomową zmianę. Proszę przejść do ustawienia i utrzymać lokalizację. Inaczej alarmy już nie będą działać.", + "uk": "Цей оновлення містить зміни розриву. Будь ласка, перейдемо на налаштування та підтримує розташування. В іншому випадку сигналізація не працює.", + "zh-cn": "此更新包含一个突破性的更改 。 请到设置处维持位置. 否则,警报就会失效." + }, + "level": "warn", + "buttons": [ + "agree", + "cancel" + ] + } + ] + }, "adminUI": { "config": "materialize" diff --git a/main.js b/main.js index 3e882ce..ed6a1cb 100755 --- a/main.js +++ b/main.js @@ -34,6 +34,7 @@ var DescFilter1 = ''; var DescFilter2 = ''; var country = ''; var countryConfig = ''; +var geocodeLocationConfig = [] //var regionConfig = ''; var latConfig = ''; var longConfig = ''; @@ -42,7 +43,7 @@ var typeArray = []; var urlArray = []; var regionCSV = "" -var regionName = "" +//var regionName = "" var xmlLanguage = "" const warnMessages = {}; @@ -238,6 +239,7 @@ function initialSetup(){ locationArray = adapter.config.geocode countryConfig = adapter.config.country + geocodeLocationConfig = adapter.config.geocodeLocation imageSizeSetup = Number(adapter.config.imageSize) adapter.log.debug('0.0 Initial setup loaded') @@ -267,7 +269,7 @@ async function getData(){ adapter.terminate ? adapter.terminate(0) : process.exit(0); } else{ - adapter.log.debug('0.1 Setup found: country ' + countryConfig + ' with geocode(s) ' + locationArray + ' and location Lat ' + latConfig + ' Long ' + longConfig ) + adapter.log.debug('0.1 Setup found: country ' + countryConfig + ' with geocode(s) ' + locationArray + ' for location ' + geocodeLocationConfig+ ' and Lat ' + latConfig + ' Long ' + longConfig ) if (Sentry){ adapter.log.debug('Sentry aktiv - Breadcrumb gesetzt') Sentry.addBreadcrumb({ @@ -636,7 +638,7 @@ async function getData(){ await Promise.all([ adapter.setStateAsync({device: '' , channel: '',state: 'level'}, {val: maxAlarmLevel, ack: true}), adapter.setStateAsync({device: '' , channel: '',state: 'htmlToday'}, {val: htmlCode, ack: true}), - adapter.setStateAsync({device: '' , channel: '',state: 'location'}, {val: regionName, ack: true}), + adapter.setStateAsync({device: '' , channel: '',state: 'location'}, {val: geocodeLocationConfig, ack: true}), adapter.setStateAsync({device: '' , channel: '',state: 'link'}, {val: urlAtom, ack: true}), adapter.setStateAsync({device: '' , channel: '',state: 'color'}, {val: getColor(maxAlarmLevel.toString()), ack: true}), adapter.setStateAsync({device: '' , channel: '',state: 'noOfAlarms'}, {val: warningCount, ack: true}), @@ -650,8 +652,8 @@ async function getData(){ adapter.log.debug('15: All Done') - if (regionName){ - adapter.log.info('15.1: Updated Weather Alarms for ' + regionName + ' -> ' + warningCount + ' alarm(s) found') + if (geocodeLocationConfig){ + adapter.log.info('15.1: Updated Weather Alarms for ' + geocodeLocationConfig + ' -> ' + warningCount + ' alarm(s) found') } adapter.terminate ? adapter.terminate('All data processed. Adapter stopped until next scheduled process.') : process.exit(0); @@ -1074,7 +1076,7 @@ async function processNotifications(alarms){ } var region = "" if (adapter.config.showLocation){ - region = ' - ' + regionName + region = ' - ' + geocodeLocationConfig } var notificationLevel = getNotificationLevel(alarms.Level) @@ -1094,7 +1096,7 @@ async function processNotifications(alarms){ adapter.log.debug('14.1.1: Warning for "All warnings ended" sent') var region = "" if (adapter.config.showLocation){ - region = ' - ' + regionName + region = ' - ' + geocodeLocationConfig } var notificationLevel = getNotificationLevel(1) var notificationText = notificationLevel + region + ': ' + i18nHelper.warningsLifted[lang] @@ -1397,23 +1399,6 @@ async function processDetails(content, countInt,detailsType,detailsIdentifier,de } //adapter.log.debug('geocodes.array length ' + geoCodesArray.length) - for(let h = 0; h < geoCodesArray.length; h++) { - //adapter.log.debug('EMMA ID: ' + geoCodesArray[h].valueName + ' - ' + geoCodesArray[h].value) - //adapter.log.debug('Location Array: ' + locationArray) - //adapter.log.debug('Incouded: ' + locationArray.includes(geoCodesArray[h].value)) - if (geoCodesArray[h].valueName == "EMMA_ID" && (locationArray.includes(geoCodesArray[h].value))){ - adapter.log.debug(' Region found - ' + areaData[i].areaDesc) - if (regionName ==""){ - regionName = areaData[i].areaDesc - } - else{ - if (!regionName.includes(areaData[i].areaDesc)){ - regionName += ', ' + areaData[i].areaDesc - } - } - } - } - //adapter.log.debug('Location : ' + areaData[i].areaDesc) }