Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. JSON Tabelle FuelPriceMonitor [Austria]

    NEWS

    • Amazon Alexa - ioBroker Skill läuft aus ?

    • Monatsrückblick – September 2025

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    JSON Tabelle FuelPriceMonitor [Austria]

    This topic has been deleted. Only users with topic management privileges can see it.
    • Negalein
      Negalein Global Moderator @liv-in-sky last edited by Negalein

      @liv-in-sky

      Servus

      Bin erst jetzt (komplett übersehn) auf dein Script gestossen.

      Du verwendest hier cheapest overall.

      Ist es möglich, stattdessen fuelpricemonitor.0.0_Home_Diesel zu verwenden?

      40fa0161-2154-4c9d-adbb-d57c4fd7315d-image.png

      liv-in-sky 2 Replies Last reply Reply Quote 0
      • liv-in-sky
        liv-in-sky @Negalein last edited by

        @negalein

        habe im moment wenig zeit - muss mir das nochmal ansehen - evtl am WE

        1 Reply Last reply Reply Quote 1
        • liv-in-sky
          liv-in-sky @Negalein last edited by liv-in-sky

          @negalein

          habe nochmal darüber geschaut - das umzustellen ist zu aufwendig - die frage ist aber ob das sinnvoll ist

          du bekommst die tankstellen deiner umgebung (abhängig von deinen koordinaten) zusätzlich kannst du weitere tankst. eingeben. in overall ist dann eine liste nach preis.

          wenn du in der instanz alle zusätzlichen tankstellen rausnimmst, sollte eigentlich in 0_home-diesel das selbe stehen, wie in cheapestall-diesel - das was du eigentlich möchtest

          musst du testen

          1 Reply Last reply Reply Quote 0
          • A
            australien last edited by australien

            @liv-in-sky
            kann man das für die VIS-2 auch verwenden?

            bei mir werden keine logos dargestellt, nur der Pfad, welcher richtig ist.
            44fe7273-92a6-42bd-a268-29acd86a59d0-grafik.png

            liv-in-sky 1 Reply Last reply Reply Quote 0
            • liv-in-sky
              liv-in-sky @australien last edited by

              @australien hi, schau mal im widget selbst, ob es für die spalte mit dem pfad eine einstellung gibt für "bild"

              A 1 Reply Last reply Reply Quote 0
              • A
                australien @liv-in-sky last edited by

                @liv-in-sky ich kann dazu leider im basic und inventwo nicht finden.
                welches verwendest du?

                liv-in-sky 1 Reply Last reply Reply Quote 0
                • liv-in-sky
                  liv-in-sky @australien last edited by

                  @australien

                  ich nutze das nicht - wohne nicht in AUT

                  du kannst dafür nur das json inventwo widget nutzen - ich habe kein vis 2, daher kenne ich das widget darin nicht - ich kann mich aber erinnbern, daß in vis 1 man die spalte als bild definieren muss, sonst wird halt nur der pfad angezeigt

                  A 1 Reply Last reply Reply Quote 0
                  • A
                    australien @liv-in-sky last edited by australien

                    @liv-in-sky ich habe mir nun in einen script eine html Ausgabe erstellen lassen, passt soweit.

                    // Dieses Skript liest zwei JSON-Datenpunkte (für Diesel & Super) aus
                    // und erstellt daraus zwei separate HTML-Tabellen für VIS-2.
                    //
                    // ✅ Quellen:
                    //   - 0_userdata.0.FUELPRICEMONITOR.DIEJsonAnzeige  → enthält Feld "DIE" für Logo
                    //   - 0_userdata.0.FUELPRICEMONITOR.SUPJsonAnzeige  → enthält Feld "SUP" für Logo
                    //
                    // ✅ Ziel-Datenpunkte (HTML für VIS-2):
                    //   - 0_userdata.0.FUELPRICEMONITOR.DIETankstellen_HTML
                    //   - 0_userdata.0.FUELPRICEMONITOR.SUPTankstellen_HTML
                    //
                    // Logos werden anhand des jeweiligen Feldes (SUP oder DIE) oder – falls leer – anhand des Firmennamens automatisch zugeordnet.
                    
                    // ------------------------- EINSTELLUNGEN -------------------------
                    const srcDIE = '0_userdata.0.FUELPRICEMONITOR.DIEJsonAnzeige';
                    const srcSUP = '0_userdata.0.FUELPRICEMONITOR.SUPJsonAnzeige';
                    const dpDIE  = '0_userdata.0.FUELPRICEMONITOR.DIETankstellen_HTML';
                    const dpSUP  = '0_userdata.0.FUELPRICEMONITOR.SUPTankstellen_HTML';
                    // -----------------------------------------------------------------
                    
                    // Liste aller Tankstellen-Logos
                    const logoList = [
                      { firma: "BP", pic: "/vis-2.0/doki/Tankstellen/bp.png" },
                      { firma: "Genol", pic: "/vis-2.0/doki/Tankstellen/genol.png" },
                      { firma: "eni", pic: "/vis-2.0/doki/Tankstellen/eni.png" },
                      { firma: "Turmöl", pic: "/vis-2.0/doki/Tankstellen/turmoel.png" },
                      { firma: "paradies", pic: "/vis-2.0/doki/Tankstellen/treibstoffparadies.png" },
                      { firma: "Lohberger", pic: "/vis-2.0/doki/Tankstellen/lohberger.png" },
                      { firma: "SB-Tankstelle", pic: "/vis-2.0/doki/Tankstellen/sb.jpg" },
                      { firma: "Diskont", pic: "/vis-2.0/doki/Tankstellen/hofer.png" },
                      { firma: "AVIA", pic: "/vis-2.0/doki/Tankstellen/avia.png" },
                      { firma: "AVANTI", pic: "/vis-2.0/doki/Tankstellen/avanti.png" },
                      { firma: "Shell", pic: "/vis-2.0/doki/Tankstellen/shell.png" },
                      { firma: "Aral", pic: "/vis-2.0/doki/Tankstellen/aral.png" },
                      { firma: "JET", pic: "/vis-2.0/doki/Tankstellen/jet.png" },
                      { firma: "Ultsch", pic: "/vis-2.0/doki/Tankstellen/ultsch.png" },
                      { firma: "IQ", pic: "/vis-2.0/doki/Tankstellen/iq.jpg" },
                      { firma: "SOCAR", pic: "/vis-2.0/doki/Tankstellen/socar.png" },
                      { firma: "OIL!", pic: "/vis-2.0/doki/Tankstellen/oil.png" },
                      { firma: "bft", pic: "/vis-2.0/doki/Tankstellen/bft.png" },
                      { firma: "default", pic: "/vis-2.0/doki/Tankstellen/default.png" }
                    ];
                    
                    // Funktion: passendes Logo anhand des Namens ermitteln
                    function getLogoByName(name) {
                      if (!name) return "/vis-2.0/doki/Tankstellen/default.png";
                      const lower = name.toLowerCase();
                      for (let entry of logoList) {
                        if (lower.includes(entry.firma.toLowerCase())) {
                          return entry.pic;
                        }
                      }
                      return "/vis-2.0/doki/Tankstellen/default.png";
                    }
                    
                    // Funktion zur Erstellung der HTML-Tabelle
                    function createTankstellenHTML(tankstellen, titel, type) {
                      let html = `
                      <style>
                        table.tankstellen {
                          width: 100%;
                          border-collapse: collapse;
                          font-family: Arial, sans-serif;
                          font-size: 14px;
                        }
                        table.tankstellen th {
                          background-color: #ddd;
                          padding: 8px;
                          text-align: left;
                        }
                        table.tankstellen td {
                          padding: 8px;
                          border-bottom: 1px solid #ccc;
                        }
                        table.tankstellen img {
                          width: 50px;
                          height: auto;
                        }
                        h3.titel {
                          font-family: Arial, sans-serif;
                          margin-bottom: 8px;
                          margin-top: 10px;
                        }
                      </style>
                    
                      <h3 class="titel">${titel}</h3>
                      <table class="tankstellen">
                        <tr>
                          <th>Logo</th>
                          <th>Name</th>
                          <th>Adresse</th>
                          <th>Preis (€)</th>
                        </tr>`;
                    
                      for (let t of tankstellen) {
                        // Logo-Feld je nach Typ
                        let logo = type === 'DIE' ? t.DIE : t.SUP;
                    
                        // Wenn leer → anhand des Namens bestimmen
                        if (!logo || logo.trim() === '') {
                          logo = getLogoByName(t.Name);
                        }
                    
                        html += `
                        <tr>
                          <td style="text-align:center;"><img src="${logo}" alt="Logo"></td>
                          <td>${t.Name || '-'}</td>
                          <td>${t.Adresse || '-'}</td>
                          <td>${t.Preis ? t.Preis.toFixed(3) : '-'}</td>
                        </tr>`;
                      }
                    
                      html += `</table>`;
                      return html;
                    }
                    
                    // Ziel-Datenpunkte anlegen, falls nicht vorhanden
                    if (!existsState(dpDIE)) {
                      createState(dpDIE, { name: 'DIE Tankstellen HTML', type: 'string', role: 'html', read: true, write: true });
                    }
                    if (!existsState(dpSUP)) {
                      createState(dpSUP, { name: 'SUP Tankstellen HTML', type: 'string', role: 'html', read: true, write: true });
                    }
                    
                    // Hauptfunktion zum Aktualisieren der Tabellen
                    async function updateTankstellen() {
                      try {
                        // Diesel
                        const rawDIE = getState(srcDIE)?.val;
                        if (rawDIE) {
                          const dieselData = JSON.parse(rawDIE);
                          const htmlDIE = createTankstellenHTML(dieselData, 'Diesel – Tankstellen', 'DIE');
                          setState(dpDIE, htmlDIE, true);
                          log(`✅ Diesel-Tabelle aktualisiert (${dieselData.length} Einträge).`);
                        } else {
                          log(`⚠️ Keine Daten in ${srcDIE}`, 'warn');
                        }
                    
                        // Super
                        const rawSUP = getState(srcSUP)?.val;
                        if (rawSUP) {
                          const superData = JSON.parse(rawSUP);
                          const htmlSUP = createTankstellenHTML(superData, 'Super – Tankstellen', 'SUP');
                          setState(dpSUP, htmlSUP, true);
                          log(`✅ Super-Tabelle aktualisiert (${superData.length} Einträge).`);
                        } else {
                          log(`⚠️ Keine Daten in ${srcSUP}`, 'warn');
                        }
                    
                      } catch (err) {
                        log('❌ Fehler beim Erstellen der Tankstellen-Tabellen: ' + err, 'error');
                      }
                    }
                    
                    // Trigger bei Änderungen an den JSON-Datenpunkten
                    on({ id: srcDIE, change: 'any' }, updateTankstellen);
                    on({ id: srcSUP, change: 'any' }, updateTankstellen);
                    
                    // Beim Start sofort ausführen
                    updateTankstellen();
                    
                    

                    Gibt es noch eine Möglichkeit die fuelpricemonitor.0.0_Home_Diesel und nicht die fuelpricemonitor.0.cheapestOverAll_DIE für die Erstellung der jsonAusgabe zu verwenden? vv Super

                    1 Reply Last reply Reply Quote 0
                    • liv-in-sky
                      liv-in-sky last edited by

                      @australien das Script ist nicht von mir, du musst den erstellen fragen

                      A 1 Reply Last reply Reply Quote 0
                      • A
                        australien @liv-in-sky last edited by

                        @liv-in-sky ok, dachte ist von dir, das dein username vermerkt ist.

                        @mrfloppy
                        @Chaot
                        @Negalein

                        liv-in-sky 1 Reply Last reply Reply Quote 0
                        • liv-in-sky
                          liv-in-sky @australien last edited by

                          @australien

                          im ersten post dieses threads ist mein script - was du gepostet hast, kenn ich nicht - evtl hat es jmd weiterntwickelt ? wie erwähnt - ich nutze das ja nicht und bin somit nicht auf dem laufenden 😞

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

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          1.0k
                          Online

                          32.2k
                          Users

                          80.9k
                          Topics

                          1.3m
                          Posts

                          6
                          77
                          6160
                          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