Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Wunsch: Pollenflug-(Adapter/wasauchimmer)

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Wunsch: Pollenflug-(Adapter/wasauchimmer)

    This topic has been deleted. Only users with topic management privileges can see it.
    • Homoran
      Homoran Global Moderator Administrators @AlCalzone last edited by

      @AlCalzone

      läuft wunderbar:

      14:03:36.927	info	javascript.1 Stop script script.js.Wetter_und_Klima.request_test
      14:03:36.929	info	javascript.0 Stop script script.js.Wetter_und_Klima.request_test
      14:03:40.311	info	javascript.0 script.js.Wetter_und_Klima.request_test: compiling TypeScript source...
      14:03:40.311	info	javascript.0 script.js.Wetter_und_Klima.request_test: TypeScript compilation successful
      14:03:40.311	info	javascript.0 script.js.Wetter_und_Klima.request_test: registered 0 subscriptions and 0 schedules
      14:03:41.180	info	javascript.0 script.js.Wetter_und_Klima.request_test: https://apod.nasa.gov/apod/image/1903/M82Magnet_SOFIA_960.jpg
      14:03:41.180	info	javascript.0 script.js.Wetter_und_Klima.request_test: Are galaxies giant magnets? Yes, but the magnetic fields in galaxies are typically much weaker than on Earth's surface, as well as more complex and harder to measure. Recently, though, the HAWC+ instrument onboard the airborne (747) SOFIA observatory has been successful in detailing distant magnetic fields by observing infrared light polarized by reflection from dust grains. Featured here, HAWC+ observations of the M82, the Cigar galaxy, show that the central magnetic field is perpendicular to the disk and parallel to the strong supergalactic wind. This observation bolsters the hypothesis that M82's central magnetic field helps its wind transport the mass of millions of stars out from the central star-burst region. The featured image shows magnetic field lines superposed on top of an optical light (gray) and hydrogen gas (red) image from Kitt Peak National Observatory, further combined with infrared images (yellow) from SOFIA and the Spitzer Space Telescope. The Cigar Galaxy is about 12 million light years distant and visible with binoculars towards the constellation of the Great Bear.
      
      1 Reply Last reply Reply Quote 0
      • Nashra
        Nashra Most Active Forum Testing last edited by

        Habe gerade mal versucht im js Request einzutragen. Kleingeschrieben steht es schon drin
        aber ich dachte, nachdem was ich hier gelesen habe, versuch es mal mit Großschreibung
        also so: Request
        Ergebnis:

        javascript.0	2019-03-11 14:04:32.312	info	npm install Request --production --prefix "/opt/iobroker/node_modules/iobroker.javascript" (System call)
        javascript.0	2019-03-11 14:04:32.309	error	Cannot install Request: 1
        javascript.0	2019-03-11 14:04:32.251	error	npm ERR! A complete log of this run can be found in: npm ERR! /home/iobroker/.npm/_logs/2019-03-11T13_04_32_241Z-debug.log
        javascript.0	2019-03-11 14:04:32.249	error	
        javascript.0	2019-03-11 14:04:32.235	error	ERR! 404 Not Found: Request@latest
        javascript.0	2019-03-11 14:04:32.233	error	
        javascript.0	2019-03-11 14:04:32.230	error	npm
        javascript.0	2019-03-11 14:04:32.224	error	ERR! code E404
        javascript.0	2019-03-11 14:04:32.223	error	npm
        javascript.0	2019-03-11 14:04:27.455	info	npm install Request --production --prefix "/opt/iobroker/node_modules/iobroker.javascript" (System call)
        
        Homoran 1 Reply Last reply Reply Quote 0
        • Homoran
          Homoran Global Moderator Administrators @Nashra last edited by

          @Nashra
          ich habe jetzt beide wieder rausgenommen, da request ja schon im js-Adapter integriert sein soll.

          Hilft auch nicht

          1 Reply Last reply Reply Quote 0
          • SBorg
            SBorg Forum Testing Most Active last edited by

            Danke @AlCalzone
            Ich debuge es gerade, Daten kommen, aber nicht so wie sie wohl waren/sollen.
            ...und fragt nicht warum es mal ging, oder jetzt nicht geht, oder... 😉

            Homoran 1 Reply Last reply Reply Quote 0
            • Nashra
              Nashra Most Active Forum Testing last edited by

              Nachtrag noch von mir...
              Fehlermeldungen ohne Ende aber Datenpunkte sind angelegt und werden auch gefüllt.

              1 Reply Last reply Reply Quote 0
              • Homoran
                Homoran Global Moderator Administrators @SBorg last edited by Homoran

                @SBorg
                ich hatte mal den Quelltext heruntergelden und bei regex101 getestet.

                Das klappte ganz gut.
                Im Parser Adapter bekam ich dann live eine 503 forbidden
                Da kann ich ja keinen useragent eingeben

                1 Reply Last reply Reply Quote 0
                • Homoran
                  Homoran Global Moderator Administrators @SBorg last edited by

                  @SBorg sagte in Wunsch: Pollenflug-(Adapter/wasauchimmer):

                  Solange man es anscheinend kpl. in Ruhe lässt funktioniert es...

                  Mir fällt gerade die Meldung auf:

                  TypeScript compilation successful
                  

                  Das heisst doch:
                  sobald man das Skript anfasst wird es neu kompiliert!

                  ...und dann läuft es nicht mehr

                  AlCalzone 1 Reply Last reply Reply Quote 0
                  • SBorg
                    SBorg Forum Testing Most Active last edited by

                    Wie heißt es immer so schön: ich habe eine gute und eine schlechte Nachricht...
                    Die "gute": ich weiß woran es liegt...
                    die "schlechte": ich bin dann mal raus...

                    Eigentlich sollte es mit aktuellen Werten bei keinem mehr funktionieren, außer Wetteronline macht noch was anderes bei einigen URLs. Bei "meiner" ist es eindeutig so, dass der Webseiten-Parser nicht mehr zum Inhalt der Seite passt. Somit kann, wie schon @AlCalzone schrieb, er keine Daten mehr von der Seite verarbeiten. Er müsste also neu geschrieben werden. Ob ich das hin bekäme weiß ich nicht, aber ich habe für mich schon eine funktionsfähige andere Variante, so dass die Priorität hinter meinen eigenen derzeitigen Projekten läge. Sieht also von meiner Seite eher schlecht aus 😞

                    Nashra 1 Reply Last reply Reply Quote 1
                    • Nashra
                      Nashra Most Active Forum Testing @SBorg last edited by

                      @SBorg sagte in Wunsch: Pollenflug-(Adapter/wasauchimmer):

                      Wie heißt es immer so schön: ich habe eine gute und eine schlechte Nachricht...
                      Die "gute": ich weiß woran es liegt...
                      die "schlechte": ich bin dann mal raus...

                      Schade aber trotzdem vielen Dank für die Mühe die Du dir gemacht hast 👍

                      1 Reply Last reply Reply Quote 0
                      • AlCalzone
                        AlCalzone Developer @Homoran last edited by

                        @Homoran sagte in Wunsch: Pollenflug-(Adapter/wasauchimmer):

                        @SBorg sagte in Wunsch: Pollenflug-(Adapter/wasauchimmer):

                        Solange man es anscheinend kpl. in Ruhe lässt funktioniert es...

                        Mir fällt gerade die Meldung auf:

                        TypeScript compilation successful
                        

                        Das macht der Adapter bei jedem Start eines TypeScripts (also bei Änderung und bei Adapterstart).

                        1 Reply Last reply Reply Quote 0
                        • Segway
                          Segway @Homoran last edited by

                          @Homoran sagte in Wunsch: Pollenflug-(Adapter/wasauchimmer):

                          ob ich das mal machen sollte?

                          Hattest du das mal bei dir gemacht ? Habe das mal installiert allerdings zeigte das Debian nach einem Neustart wieder die alte 6.4.1 bei mir an ... weiss immer noch nicht wodran das liegt

                          Homoran 1 Reply Last reply Reply Quote 0
                          • Homoran
                            Homoran Global Moderator Administrators @Segway last edited by

                            @Segway sagte in Wunsch: Pollenflug-(Adapter/wasauchimmer):

                            Hattest du das mal bei dir gemacht ?

                            Ja!
                            und npm -v ergibt auch brav 6.9.0

                            Segway 1 Reply Last reply Reply Quote 0
                            • Segway
                              Segway @Homoran last edited by

                              @Homoran sagte in Wunsch: Pollenflug-(Adapter/wasauchimmer):

                              Ja!

                              mit --> npm install -g npm ?

                              Homoran 1 Reply Last reply Reply Quote 0
                              • Homoran
                                Homoran Global Moderator Administrators @Segway last edited by Homoran

                                @Segway nein als user pi mit

                                sudo -H npm install -g npm
                                
                                Segway 1 Reply Last reply Reply Quote 0
                                • Segway
                                  Segway @Homoran last edited by Segway

                                  @Homoran

                                  Update hm-rega from @2.3.1 to @2.3.2
                                  NPM version: 6.9.0
                                  

                                  👍 👍 👍☺ ☺ ☺

                                  1 Reply Last reply Reply Quote 0
                                  • SmarthomeMF
                                    SmarthomeMF last edited by

                                    Hallo
                                    Hatte das Skript das ganze letzte Jahr am laufen

                                    ```
                                    // ########################################################################################################
                                    // Polleninfo auswerten heute und die nächsten Tage
                                    // Version 1.4
                                    // ########################################################################################################

                                    /**************************************************************************************************

                                    • Initiale Optionen
                                      **************************************************************************************************/
                                      interface iRequestOptions {
                                      url: string;
                                      headers: any;
                                      }

                                    var baseUrl: string = "https://www.wetteronline.de/pollen/perg";
                                    var baseObjPath: string = 'wetter.pollenvorhersage';

                                    /**************************************************************************************************

                                    • Globale TypeScript Definitionen
                                      *************************************************************************************************/
                                      // -----------------------------------------------------------------------------
                                      /
                                      Die folgenden Funktionen sind bei mir in einem globalen script.
                                      Wenn man diese global definieren will, muss man das lokal referenzieren mit:
                                      declare function isPrimitive(obj:any):boolean
                                      declare function logDebug(...param: any[]):void;
                                      declare function logInfo(...param: any[]):void;
                                      declare function logWarning(...param: any[]):void;
                                      declare function logError(...param: any[]):void;
                                      */

                                    /**

                                    • Function for check if a object is a primitive object (string, number, etc)
                                    • @param obj any object to check if it is a primitive object
                                    • @returns boolean which is true if object in parameter is a primitive object
                                      */
                                      function isPrimitive(obj:any):boolean {
                                      return (obj !== Object(obj));
                                      }

                                    /**

                                    • write any objects given as parameter to log as debug

                                    • @param param a nist of different objects
                                      /
                                      function logDebug(...param: any[]):void {
                                      if (arguments.length > 0) {
                                      var text:string[] = [];
                                      for (var i = 0; i < arguments.length; i++) {
                                      if (typeof arguments[i] === 'string' || arguments[i] instanceof String) {
                                      text.push(arguments[i]);
                                      } else if(arguments[i] === null) {
                                      text.push('null');
                                      } else if(arguments[i] === undefined) {
                                      text.push('undefined');
                                      } else if (isPrimitive(arguments[i])) {
                                      text.push(arguments[i]);
                                      } else {
                                      text.push(JSON.stringify(arguments[i]));
                                      }
                                      //enum close bracket cannot be found in "channel[state.id=
                                      .TEMPERATURE](rooms=WZ|Wohnung|Wohnzimmer"

                                      }
                                      log(text.join(' '), 'debug');
                                      }
                                      }

                                    /**

                                    • write any objects given as parameter to log as Information

                                    • @param param a nist of different objects
                                      /
                                      function logInfo(...param: any[]):void {
                                      if (arguments.length > 0) {
                                      var text:string[] = [];
                                      for (var i = 0; i < arguments.length; i++) {
                                      if (typeof arguments[i] === 'string' || arguments[i] instanceof String) {
                                      text.push(arguments[i]);
                                      } else if(arguments[i] === null) {
                                      text.push('null');
                                      } else if(arguments[i] === undefined) {
                                      text.push('undefined');
                                      } else if (isPrimitive(arguments[i])) {
                                      text.push(arguments[i]);
                                      } else {
                                      text.push(JSON.stringify(arguments[i]));
                                      }
                                      //enum close bracket cannot be found in "channel[state.id=
                                      .TEMPERATURE](rooms=WZ|Wohnung|Wohnzimmer"

                                      }
                                      log(text.join(' '), 'info');
                                      setState("javascript.0.Ereignisliste.event",'INFO|'+text.join(' '));
                                      }
                                      //logEnhanced(logtext, 'info');
                                      //console.debug(p);
                                      //logs(logtext,loglevels.debug);
                                      }

                                    /**

                                    • write any objects given as parameter to log as warning

                                    • @param param a nist of different objects
                                      /
                                      function logWarning(...param: any[]):void {
                                      if (arguments.length > 0) {
                                      var text:string[] = [];
                                      for (var i = 0; i < arguments.length; i++) {
                                      if (typeof arguments[i] === 'string' || arguments[i] instanceof String) {
                                      text.push(arguments[i]);
                                      } else if(arguments[i] === null) {
                                      text.push('null');
                                      } else if(arguments[i] === undefined) {
                                      text.push('undefined');
                                      } else if (isPrimitive(arguments[i])) {
                                      text.push(arguments[i]);
                                      } else {
                                      text.push(JSON.stringify(arguments[i]));
                                      }
                                      //enum close bracket cannot be found in "channel[state.id=
                                      .TEMPERATURE](rooms=WZ|Wohnung|Wohnzimmer"

                                      }
                                      log(text.join(' '), 'warn');
                                      setState("javascript.0.Ereignisliste.event",'WARN|'+text.join(' '));
                                      }
                                      //logEnhanced(logtext, 'warn');
                                      //console.warn(p);
                                      //logs(logtext,loglevels.warn);
                                      }

                                    /**

                                    • write any objects given as parameter to log as error

                                    • @param param a nist of different objects
                                      /
                                      function logError(...param: any[]):void {
                                      if (arguments.length > 0) {
                                      var text:string[] = [];
                                      for (var i = 0; i < arguments.length; i++) {
                                      if (typeof arguments[i] === 'string' || arguments[i] instanceof String) {
                                      text.push(arguments[i]);
                                      } else if(arguments[i] === null) {
                                      text.push('null');
                                      } else if(arguments[i] === undefined) {
                                      text.push('undefined');
                                      } else if (isPrimitive(arguments[i])) {
                                      text.push(arguments[i]);
                                      } else {
                                      text.push(JSON.stringify(arguments[i]));
                                      }
                                      //enum close bracket cannot be found in "channel[state.id=
                                      .TEMPERATURE](rooms=WZ|Wohnung|Wohnzimmer"

                                      }
                                      log(text.join(' '), 'error');
                                      setState("javascript.0.Ereignisliste.event",'ERROR|'+text.join(' '));
                                      }
                                      }
                                      // ########################################################################################################
                                      // Lokale TypeScript Definitionen
                                      // ########################################################################################################
                                      import request = require("request");

                                    var Pollenarten:string[] = ['Erle','Hasel','Pappel','Weide','Ulme','Birke','Buche','Ampfer','Roggen','Gräser','Eiche','Wegerich','Beifuß','Ambrosia'];
                                    var tageVorhersage = ['d0','d1','d2','d3','d4','d5'];
                                    var tageVorhersageName = ['heute','morgen','übermorgen','heute + 3','heute + 4','heute + 5'];

                                    function stripTags(data:string):string {
                                    return data.replace(/( |<([^>]+)>)/ig, "");
                                    }

                                    function getDate(days: number): string { // Eingabe 0, 1, 2, ...
                                    var jetzt = new Date();
                                    jetzt.setHours(0);
                                    jetzt.setMinutes(0);
                                    jetzt.setSeconds(0);
                                    jetzt.setMilliseconds(0);
                                    var newdate = new Date();
                                    newdate.setTime(jetzt.getTime() + (24 * 60 * 60 * 1000 * days) ); // heute + anzahl tage ins Millisekunden
                                    var date :string = newdate.getDate().toString();
                                    var month: string = (newdate.getMonth()+1).toString();
                                    var year: string = newdate.getFullYear().toString();
                                    date = (date.length < 2) ? '0' + date : date;
                                    month = (month.length < 2) ? '0' + month : month;
                                    var result:string = year+month+date;
                                    logDebug('Datum in Link: ', result);
                                    return (result); // Ausgabe z.B. 20160506
                                    }

                                    function GetPollenIndex(pflanze:string, html:string):number {
                                    var code ={'kein':0, 'schwach':1, 'mäßig':2, 'stark':3};
                                    var result:string= "";
                                    var start:number =html.indexOf(pflanze)+pflanze.length;

                                    result=html.slice(start);
                                    result=result.trim();
                                    

                                    //logDebug('result for ',pflanze,html.slice(0,600));
                                    var stop:number =result.indexOf(' ');
                                    result=result.slice(0,stop);
                                    logDebug('pflanze=',pflanze,'code=',result);
                                    return code[result];
                                    }

                                    function initializePollenwetter(baseObj:string, name:string):void {
                                    createState(baseObj,0,false, {
                                    name: name,
                                    type: "string",
                                    role: 'json',
                                    read: true,
                                    write: false});

                                    for(var i=0;i<Pollenarten.length;i++) {
                                      createState(baseObj + '.' + Pollenarten[i].toLowerCase(),0,false, {
                                         name: 'Pollenart '+ Pollenarten[i],
                                         type: "number",
                                         role: 'value',
                                         read: true,
                                         write: false});
                                    }
                                    

                                    }

                                    function removeOldPollenwetter():void {
                                    for(var i=0;i<Pollenarten.length;i++) {
                                    deleteState(baseObjPath + '.' + Pollenarten[i].toLowerCase());
                                    }
                                    }

                                    function readPollenwetterForDay(day:number, baseObj:string):void {
                                    logDebug("Start");
                                    try {
                                    var options:iRequestOptions = {
                                    url: ((day>0) ? baseUrl + '?fcdatstr=' + getDate(day) : baseUrl), // korrekten Link erstellen ,
                                    headers: {
                                    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'
                                    }
                                    };
                                    request(options, function (error, response, body):void {
                                    if (!error && response.statusCode == 200) { // kein Fehler, Inhalt in body
                                    body=body.replace(/\t/g, ' ');
                                    body=body.replace(/(\n|\r)/g, '');
                                    var start:number =body.indexOf('<ul id="pollentable">');
                                    if (start>-1) { body=body.slice(start); }
                                    body=stripTags(body);
                                    //logDebug('body',body);
                                    let pobj:any = {};
                                    for(let i=0;i<Pollenarten.length;i++) {
                                    let pi:number = GetPollenIndex(Pollenarten[i],body);
                                    pobj[Pollenarten[i].toLowerCase()] = pi;
                                    setState(baseObj+'.'+Pollenarten[i].toLowerCase(),pi);
                                    }
                                    setState(baseObj,JSON.stringify(pobj));
                                    } else {
                                    logInfo("StatusCode="+response.statusCode);
                                    logError(error); // Error beim Einlesen
                                    }
                                    });
                                    } catch (e) {
                                    logError('Fehler (try) leseWebseite: ' + e);
                                    }
                                    }

                                    function readPollenwetter() {
                                    for (let d:number = 0; d < tageVorhersage.length; d++) {
                                    let path: string = baseObjPath + '.' + tageVorhersage[d];
                                    initializePollenwetter(path, tageVorhersageName[d]);
                                    readPollenwetterForDay(d, path);
                                    }
                                    }

                                    removeOldPollenwetter();
                                    readPollenwetter();
                                    schedule("5 0 * * *", readPollenwetter);

                                    nun nach dem Winter habe ich es wieder gestartet!
                                    nun gleich einen ERROR
                                    [s=]```
                                    20:20:23.749	error	javascript.0 script.js.common.Polleninfo compile failed:
                                     at script.js.common.Polleninfo:9
                                    ```[/s]
                                    Das ich gerade gesehen habe das es auch bereits einen Adapter gibt habe ich ihn probiert.
                                    Nur geht das nicht weil ich aus österreich bin und dafür keine Eonstellungen giebt.
                                    
                                    Was bedeutet der Error.
                                    Danke
                                    1 Reply Last reply Reply Quote 0
                                    • SmarthomeMF
                                      SmarthomeMF last edited by

                                      nun nach dem Winter habe ich es wieder gestartet!
                                      nun gleich einen ERROR

                                      20:20:23.749 error javascript.0 script.js.common.Polleninfo compile failed:
                                      at script.js.common.Polleninfo:9

                                      Das ich gerade gesehen habe das es auch bereits einen Adapter gibt habe ich ihn probiert.
                                      Nur geht das nicht weil ich aus österreich bin und dafür keine Eonstellungen giebt.

                                      Was bedeutet der Error.
                                      Danke

                                      1 Reply Last reply Reply Quote 0
                                      • SBorg
                                        SBorg Forum Testing Most Active last edited by

                                        Du kannst die letzten ~50 Posts bei Interesse dazu lesen, oder kurz und schmerzlos: der Aufbau der Seite hat sich geändert und der Parser funktioniert nicht mehr...

                                        Homoran 1 Reply Last reply Reply Quote 0
                                        • Homoran
                                          Homoran Global Moderator Administrators @SBorg last edited by Homoran

                                          @SBorg
                                          und wenn jemand Zeit, Lust und die Fähigkeit hat das Skript zu modifizieren (mir fehlt vor allem letzteres), habe ich schon mal etwas vorbereitet

                                          Mit dem Regex

                                          day0="(\w+)
                                          

                                          erhält man für die 14 Pollenarten die heutige Warnstufe
                                          Ändert man day0 auf day1 ist das die morgige Warnstufe, day2 übermorgen usw.

                                          Als Ergebnis kommen vier verschiedene Worte heraus: noburden, weakburden, moderateburden und strongborden, was den Intensitäten 0-3 entspricht, was dann noch umgerechnet werden muss.

                                          Mit dem Parser geht es leider nicht, da kommt 503-forbidden.
                                          (Oder kann man im Aufruf der Adresse einen Useragent mitgeben?)

                                          Die entsprechenden Pollenarten erhält man mit

                                          xt">(\w+)
                                          

                                          Wobei ich davon ausgehe, dass sich die Reihenfolge nicht ändert und man einfach 0=Erle, 1=Hasel usw. festlegen kännte

                                          SBorg AlCalzone 2 Replies Last reply Reply Quote 0
                                          • SBorg
                                            SBorg Forum Testing Most Active @Homoran last edited by

                                            @Homoran sagte in Wunsch: Pollenflug-(Adapter/wasauchimmer):

                                            (Oder kann man im Aufruf der Adresse einen Useragent mitgeben?)

                                            Nicht das ich wüsste. Ich gebe ihn bei meinem Shell-Script auch per wget mit.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate
                                            FAQ Cloud / IOT
                                            HowTo: Node.js-Update
                                            HowTo: Backup/Restore
                                            Downloads
                                            BLOG

                                            686
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

                                            43
                                            266
                                            44101
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo