Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [gelöst] Problem: Abruf von Strompreisen mit JS und Axios

    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

    [gelöst] Problem: Abruf von Strompreisen mit JS und Axios

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

      Instanz ist angelegt?
      URL: https://api.awattar.at/v1/marketdata eingetragen. Sonst kann man eh nicht viel konfigurieren

      fuzzy1955 1 Reply Last reply Reply Quote 0
      • arteck
        arteck Developer Most Active last edited by

        @fuzzy1955 schau doch mal was du im response bekommst

        console.warn(JSON.stringify(response));
        

        in die zeile 12

        fuzzy1955 1 Reply Last reply Reply Quote 0
        • fuzzy1955
          fuzzy1955 @JohGre last edited by

          @johgre sagte in Problem: Abruf von Strompreisen mit JS und Axios:

          URL: https://api.awattar.at/v1/marketdata eingetragen

          Ja, habe ich gemacht.
          Clipboard02.jpg

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

            aa2b0d7d-d6b6-41c1-980d-aa841bf55e49-image.png
            Der aWattar Adapter holt nur einmal am Tag die Daten, bei mir um 14:55 Uhr. Was hast du da konfiguriert

            fuzzy1955 1 Reply Last reply Reply Quote 0
            • fuzzy1955
              fuzzy1955 @arteck last edited by

              @arteck sagte in Problem: Abruf von Strompreisen mit JS und Axios:

              in die zeile 12

              Fehler beim Abrufen des Strompreises: Converting circular structure to JSON
                  --> starting at object with constructor 'ClientRequest'
                  |     property 'res' -> object with constructor 'IncomingMessage'
                  --- property 'req' closes the circle
              
              arteck 1 Reply Last reply Reply Quote 0
              • arteck
                arteck Developer Most Active @fuzzy1955 last edited by

                @fuzzy1955 sagte in Problem: Abruf von Strompreisen mit JS und Axios:

                Converting circular structure to JSON

                da hst du es ja..

                fuzzy1955 1 Reply Last reply Reply Quote 0
                • fuzzy1955
                  fuzzy1955 @arteck last edited by

                  @arteck sagte in Problem: Abruf von Strompreisen mit JS und Axios:

                  da hst du es ja..

                  Ja, aber ich weiß dazu keine Lösung. Kannst du mir weiterhelfen?

                  1 Reply Last reply Reply Quote 0
                  • fuzzy1955
                    fuzzy1955 @JohGre last edited by

                    @johgre sagte in Problem: Abruf von Strompreisen mit JS und Axios:

                    Der aWattar Adapter holt nur einmal am Tag die Daten, bei mir um 14:55 Uhr.

                    Aah... jetzt fällt es mir wieder ein. Ich fand es zu mühsam, die Daten aus 24 Stundenverzeichnissen rauszuklauben. Darum bin ich auf die Version mit JS gekommen.

                    1 Reply Last reply Reply Quote 0
                    • arteck
                      arteck Developer Most Active last edited by

                      @fuzzy1955 sagte in Problem: Abruf von Strompreisen mit JS und Axios:

                      @arteck sagte in Problem: Abruf von Strompreisen mit JS und Axios:

                      da hst du es ja..

                      Ja, aber ich weiß dazu keine Lösung. Kannst du mir weiterhelfen?

                      ja wird aber nach 12 uhr

                      fuzzy1955 1 Reply Last reply Reply Quote 0
                      • JohGre
                        JohGre last edited by

                        Habe mal ChatGPT bemüht.

                        async function fetchPowerData() {
                            try {
                                const response = await axios.get(apiUrl);
                                const powerData = response.data;
                                
                                console.log("Strompreisdaten: " + JSON.stringify(powerData.data));
                                const dataArray = powerData.data;
                                    dataArray.forEach(entry => {
                                        const isoDate = entry.date;
                                        const value = entry.value;
                                        const date = new Date(isoDate);
                                        const localTime = date.toLocaleString();
                        
                                        console.log(`Original: ${isoDate} => Lokal: ${localTime} | Wert: ${value}`);
                        
                                    });
                         
                            } catch (e) {
                                console.error("Fehler beim Abrufen des Strompreises: " + e.message);
                            }
                        }
                        

                        Das iteriert jetzt durch das ResponseArray und schreibt alle Werte mal raus.

                        fuzzy1955 1 Reply Last reply Reply Quote 2
                        • fuzzy1955
                          fuzzy1955 @arteck last edited by

                          @arteck sagte in Problem: Abruf von Strompreisen mit JS und Axios:

                          ja wird aber nach 12 uhr

                          Danke, bei mir wird es eher 20 Uhr.

                          1 Reply Last reply Reply Quote 0
                          • fuzzy1955
                            fuzzy1955 @JohGre last edited by

                            @johgre sagte in Problem: Abruf von Strompreisen mit JS und Axios:

                            Das iteriert jetzt durch das ResponseArray und schreibt alle Werte mal raus

                            Aaah .... danke! Das hilft mir sehr weiter!

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

                            Support us

                            ioBroker
                            Community Adapters
                            Donate

                            879
                            Online

                            31.9k
                            Users

                            80.1k
                            Topics

                            1.3m
                            Posts

                            3
                            15
                            43
                            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