Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Pegelwerte Fritzbox 6490 Cable auslesen?

    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

    Pegelwerte Fritzbox 6490 Cable auslesen?

    This topic has been deleted. Only users with topic management privileges can see it.
    • MartinP
      MartinP @fastfoot last edited by MartinP

      @fastfoot Was mich als gelernter C++ Programmierer irritiert, ist der Unterschied im jetzt funktionierenden httpPost und dem Beispiel aus der Github-Dokumentation

      httpPost(docsisURL,
              'xhr=1&sid=' + sid + '&lang=de&page=docInfo&xhrId=all&no_sidrenew=', {
              headers: {
                  'Content-Type': 'application/x-www-form-urlencoded'
              },
          },
              (error, response) => {
      
      

      In den beiden Beispielen aus der Doku ist der zweite Parameter komischerweise JSON...

      https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#httppost

      httpPost('http://jsonplaceholder.typicode.com/posts',
            { title: 'foo', body: 'bar', userId: 1 }, 
           (error, response) => {
          if (!error) {
              console.log(response.statusCode);
              console.log(response.data);
              console.log(response.headers);
          } else {
              console.error(error);
          }
      });
      

      und...

      httpPost(
          'http://jsonplaceholder.typicode.com/posts',
          {
              title: 'foo',
              body: 'bar',
              userId: 1
          },
          {
              timeout: 2000,
              basicAuth: {
                  user: 'admin',
                  password: 'dg2LdALNznHFNo'
              },
              headers: {
                  'Cookie': 'PHPSESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1'
              }
          },
          (error, response) => {
              if (!error) {
                  console.log(response.statusCode);
                  console.log(response.data);
                  console.log(response.headers);
              } else {
                  console.error(error);
              }
          }
      );
      
      F 1 Reply Last reply Reply Quote 0
      • MartinP
        MartinP last edited by

        Ich habe noch eine interessante Feststellung gemacht: Der Schedule im Code des Scriptes scheint manchmal nicht deregistriert zu werden, wenn man nach Code-Änderungen das Script wieder starten will - Geisterhaftes Logging, was nicht mehr im Quellcode des Scriptes vorhanden ist ... Da läuft dann wohl die Precompiled Version der vorigen Script-Version weiter ...

        Einmal den Javascript - Adapter durchstarten bereinigt das aber ...

        F 1 Reply Last reply Reply Quote 0
        • F
          fastfoot @MartinP last edited by

          @martinp mir scheint die Doku falsch, siehe hier im Source.

          1 Reply Last reply Reply Quote 0
          • F
            fastfoot @MartinP last edited by

            @martinp ist mir auch aufgefallen, als Workaround:

            //const intervalID = setInterval(() => getCableModemChannelInfosV2(), refreshRate);
            const scheduleID = schedule('* * * * *', () => getCableModemChannelInfosV2())
            
            // Bei Stop Interval löschen, Bug im Adapter???
            onStop(() => {
                //clearInterval(intervalID)
                clearSchedule(scheduleID);
            })
            
            
            1 Reply Last reply Reply Quote 0
            • D
              DasKind91 @MartinP last edited by

              @MartinP
              Danke! Läuft auf Anhieb

              S 1 Reply Last reply Reply Quote 0
              • MartinP
                MartinP last edited by MartinP

                @fastfoot said in Pegelwerte Fritzbox 6490 Cable auslesen?:

                @martinp mir scheint die Doku falsch, siehe hier im Source.

                Sollte man da ggfs einen separaten Issue aufmachen?

                habe eine bessere Test-Seite gefunden - die "echoed" das, was sie empfangen hat im Response Body

                httpPost('https://httpbin.org/post', "[{ title: 'foo', body: 'bar', userId: 1 }]", (error, response) => {
                // httpPost('https://httpbin.org/post', { title: 'foo', body: 'bar', userId: 1 }, (error, response) => {
                    if (!error) {
                        console.log('statusCode: ' + response.statusCode);
                        console.log('data: ' + response.data);
                        console.log('headers: ' + response.headers);
                    } else {
                        console.error(error);
                    }
                });
                
                
                

                Hier das Logging der oberen Variante

                javascript.0	10:14:40.626	info	script.js.Spielwiese.Ressourcentest: statusCode: 200
                javascript.0	10:14:40.626	info	script.js.Spielwiese.Ressourcentest: data: { "args": {}, "data": "", "files": {}, "form": { "[{ title: 'foo', body: 'bar', userId: 1 }]": "" }, "headers": { "Accept": "application/json, text/plain, */*", "Accept-Encoding": "gzip, compress, deflate, br", "Baggage": "sentry-environment=production,sentry-release=iobroker.javascript%408.3.1,sentry-public_key=f3b9740caaee4ee69eb68019d71526ff,sentry-trace_id=4e9d2599655c4da3ba2864550274d0a8", "Content-Length": "42", "Content-Type": "application/x-www-form-urlencoded", "Host": "httpbin.org", "Sentry-Trace": "4e9d2599655c4da3ba2864550274d0a8-bb42ffe38676a38a", "User-Agent": "Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/121.0", "X-Amzn-Trace-Id": "Root=1-6688fcf0-44abb5ee167177b203eaf2e3" }, "json": null, "origin": "178.200.220.43", "url": "https://httpbin.org/post" }
                javascript.0	10:14:40.627	info	script.js.Spielwiese.Ressourcentest: headers: date: Sat, 06 Jul 2024 08:14:40 GMT content-type: application/json content-length: 871 connection: keep-alive server: gunicorn/19.9.0 access-control-allow-origin: * access-control-allow-credentials: true
                

                Und das die im Listing auskommentierte Version:

                javascript.0	10:13:50.731	info	script.js.Spielwiese.Ressourcentest: statusCode: 200
                javascript.0	10:13:50.732	info	script.js.Spielwiese.Ressourcentest: data: { "args": {}, "data": "{\"title\":\"foo\",\"body\":\"bar\",\"userId\":1}", "files": {}, "form": {}, "headers": { "Accept": "application/json, text/plain, */*", "Accept-Encoding": "gzip, compress, deflate, br", "Baggage": "sentry-environment=production,sentry-release=iobroker.javascript%408.3.1,sentry-public_key=f3b9740caaee4ee69eb68019d71526ff,sentry-trace_id=4e9d2599655c4da3ba2864550274d0a8", "Content-Length": "39", "Content-Type": "application/json", "Host": "httpbin.org", "Sentry-Trace": "4e9d2599655c4da3ba2864550274d0a8-ab0960d5e4e3bc86", "User-Agent": "Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/121.0", "X-Amzn-Trace-Id": "Root=1-6688fcbe-236bdbd352d2980c328604d5" }, "json": { "body": "bar", "title": "foo", "userId": 1 }, "origin": "178.200.220.43", "url": "https://httpbin.org/post" }
                javascript.0	10:13:50.733	info	script.js.Spielwiese.Ressourcentest: headers: date: Sat, 06 Jul 2024 08:13:50 GMT content-type: application/json content-length: 905 connection: keep-alive server: gunicorn/19.9.0 access-control-allow-origin: * access-control-allow-credentials: true
                

                EDIT:
                https://github.com/ioBroker/ioBroker.javascript/issues/1633

                MartinP1 created this issue in ioBroker/ioBroker.javascript

                closed [Bug]: second parameter of httpPost() - Usage of JSON (conforming to documentation) leads to strange behaviour #1633

                1 Reply Last reply Reply Quote 0
                • S
                  sugram @DasKind91 last edited by sugram

                  Hmm, aktuell habe ich mit dem "alten" script keine Probleme.
                  Zumindest zeigt es im log keine an.
                  Ich habe nur bemerkt, daß die Werte die in der FB angezeigt werden, nicht mehr mit den aufgezeigten stimmen.
                  Nutze eine 6690 v 7.57

                  Wenn es ein überarbeitetes Script gibt, bin ich absolut interessiert, da ich die Werte nach wie vor logge.

                  Ah, jetzt.
                  aber nur wenn ich in dem JS Script direkt auf das Request gehe

                  Bild_2024-07-13_220614327.png

                  Also das gleiche Problem.
                  Ich offe das ihr das gelöst bekommt, daß wäre wirklich klasse.

                  S 1 Reply Last reply Reply Quote 0
                  • S
                    sugram @sugram last edited by

                    Nur mal eine Nachfrage.

                    Gibt es nun ein Script bei dem wieder alles funktioniert?

                    1 Reply Last reply Reply Quote 0
                    • S
                      sugram @MartinP last edited by

                      @martinp Vielen Dank für deine Antwort.
                      Dein Script funktioniert hier bei mir nun auch wieder

                      MartinP 1 Reply Last reply Reply Quote 0
                      • MartinP
                        MartinP @sugram last edited by MartinP

                        Ich habe noch eine Nickeligkeit in Javascript Adapter 6.3.1 gefunden (in der Version 6.7.1 aus dem Latest - Repo tritt das Problem nicht auf):

                        zum httpPost wird im Editor gesagt, response enthielte kein Element "statusCode"

                        Lässt man sich beim Korrigieren vom Tooltip leiten, korrigiert man von "response.statusCode" auf "response.responseCode"...

                        Dann funktioniert aber das Script nicht mehr. Um die roten Schlängel unter statusCode zu sehen, musste ich einen Screenshot machen.

                        899abd4a-ee58-4b74-9cbf-0dc57431a271-grafik.png

                        diese beiden im Screenshot auskommentierten Log-Meldungen ...

                                         log ('response.statusCode' + response.statusCode.toString());
                                         log ('response.responseCode' + response.responseCode.toString());
                        
                        

                        Lösten folgendes Logging aus:

                        javascript.0
                        	2024-07-23 10:09:00.139	info	script.js.Fritzbox.DOCSISV01: response.statusCode200
                        javascript.0
                        	2024-07-23 10:09:00.143	error	Error in callback: TypeError: Cannot read properties of undefined (reading 'toString')
                        javascript.0
                        	2024-07-23 10:09:00.144	error	at Object.<anonymous> (script.js.Fritzbox.DOCSISV01:442:70)
                        javascript.0
                        	2024-07-23 10:09:00.144	error	at /opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1242:38
                        javascript.0
                        	2024-07-23 10:09:00.144	error	at processTicksAndRejections (node:internal/process/task_queues:95:5)
                        j
                        

                        @haus-automatisierung habe extra jetzt Javascript 6.7.1 installiert, und da tritt der obige Fehler nicht auf. da wird responseCode mit einer roten Schlangenlinie unterlegt.... schreibe keinen Issue 😉

                        haus-automatisierung 1 Reply Last reply Reply Quote 0
                        • haus-automatisierung
                          haus-automatisierung Developer Most Active @MartinP last edited by haus-automatisierung

                          @martinp sagte in Pegelwerte Fritzbox 6490 Cable auslesen?:

                          Ich habe noch eine Nickeligkeit in Javascript Adapter 6.3.1 gefunden (in der Version 6.7.1 aus dem Latest - Repo tritt das Problem nicht auf):

                          Du meinst sicher 8.3.1 und 8.7.1?

                          Dann hast du ja schon gemerkt, dass das bereits gefixt wurde 🙂

                          MartinP 1 Reply Last reply Reply Quote 0
                          • MartinP
                            MartinP @haus-automatisierung last edited by

                            @haus-automatisierung Ja, Tippfehler

                            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

                            947
                            Online

                            31.9k
                            Users

                            80.2k
                            Topics

                            1.3m
                            Posts

                            20
                            199
                            29033
                            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