Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Alexa Shopping List mit Bring synchronisieren

    NEWS

    • Monatsrückblick - April 2025

    • Minor js-controller 7.0.7 Update in latest repo

    • Save The Date: ioBroker@Smart Living Forum Solingen, 14.06.

    Alexa Shopping List mit Bring synchronisieren

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

      @heimweh
      Sehr geil, so etwas habe ich gesucht und funktioniert super... danke dir dafür! 👍 👍

      1 Reply Last reply Reply Quote 0
      • Heimweh
        Heimweh @Oreider last edited by

        @oreider - freut mich sehr 🙂

        1 Reply Last reply Reply Quote 0
        • I
          IOMax last edited by

          Bei mir ist im alexa2 Baum unter Lists nichts mehr vorhanden. In der Alexa App sehe ich aber meine Einkaufliste noch. Hat noch jemand das Problem ?

          mcBirne 1 Reply Last reply Reply Quote 0
          • mcBirne
            mcBirne @IOMax last edited by

            @iomax ich habe das gleiche Problem

            1 Reply Last reply Reply Quote 0
            • Marc Beckmann
              Marc Beckmann @Dicken last edited by

              @dicken Das gleiche Problem habe ich auch... 😞

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

                Schaut doch erstmal beim primären Adapter.

                https://github.com/Apollon77/ioBroker.alexa2/issues/1223

                Ro75.

                jomahol created this issue in Apollon77/ioBroker.alexa2

                open Shopping- und Todolist werden nicht mehr geladen. #1223

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

                  Mit dem Datenpunkt "Summary" hab ich hier einen Script der es wieder ermöglicht mit TODOIST zu synchronisieren. Allerdings nur noch in eine Richtung - die Punkte bleiben alle in den Alexa Listen bestehen....

                  Was macht das Skript?

                  Dieses ioBroker-Skript überwacht den Alexa-Datenpunkt alexa2.0.History.summary und erkennt Sätze wie:

                  „Setze Milch auf die Einkaufsliste“

                  „Setze zwei Packungen Nudeln auf meine Einkaufsliste“

                  „Setze Wasser holen auf die To-do Liste“

                  „Setze fünf hundert Gramm Hackfleisch auf die Einkaufsliste“

                  „Setze 1 x Tomaten auf die Einkaufsliste“

                  Erkannte Aufgaben werden automatisch als neue Todoist-Tasks erstellt – entweder:

                  ✅ in deiner Einkaufsliste (Todoist-Projekt-ID wird angegeben)

                  ✅ oder in der Inbox (wenn „To-do-Liste“ erkannt wird)

                  const axios = require('axios');
                  
                  // Konfiguration
                  const todoistShoppingListId = 'XXXXXXXXXXX';
                  const todoistToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
                  
                  on({ id: 'alexa2.0.History.summary', change: 'any' }, function (obj) {
                      const inputRaw = obj.state.val;
                  
                      if (typeof inputRaw !== 'string') {
                          console.warn('⚠️ Kein String erkannt in alexa2.0.History.summary:', inputRaw);
                          return;
                      }
                  
                      const input = inputRaw.trim();
                      console.log(`🔁 Neue Alexa-Eingabe erkannt: "${input}"`);
                  
                      const match = input.match(/^setze (.+) auf (?:meine|die) (einkaufsliste|todo[\s-]?liste)/i);
                  
                      if (match && match.length >= 3) {
                          const rohAufgabe = match[1];
                          const ziel = match[2].replace(/\s|-/g, '').toLowerCase();
                  
                          const mitZiffern = wordsToNumbersSmart(rohAufgabe);
                          const aufgabe = capitalizeFirst(mitZiffern);
                  
                          console.log(`🧠 Erkannt: Aufgabe = "${aufgabe}", Ziel = "${ziel}"`);
                  
                          let projektId = null;
                          if (ziel === 'einkaufsliste') {
                              projektId = todoistShoppingListId;
                          }
                  
                          addTaskToTodoist(aufgabe, projektId);
                      } else {
                          console.log('👂 Kein Todoist-Befehl erkannt. Erwartet: "Setze xyz auf [meine/die] Einkaufsliste" oder "To-do-Liste".');
                      }
                  });
                  
                  function addTaskToTodoist(text, projectId = null) {
                      const todoistData = { content: text };
                      if (projectId) todoistData.project_id = projectId;
                  
                      console.log(`📤 Sende an Todoist: "${text}" → ${projectId ? `Projekt-ID ${projectId}` : 'Inbox'}`);
                  
                      axios.post('https://api.todoist.com/rest/v2/tasks', todoistData, {
                          headers: {
                              'Content-Type': 'application/json',
                              'Authorization': `Bearer ${todoistToken}`
                          }
                      })
                      .then(() => {
                          console.log(`✅ Aufgabe "${text}" erfolgreich zu Todoist hinzugefügt.`);
                      })
                      .catch(error => {
                          console.error('❌ Fehler beim Hinzufügen zu Todoist:', error.message || error.response?.data || error);
                      });
                  }
                  
                  function capitalizeFirst(text) {
                      if (!text || typeof text !== 'string') return '';
                      return text.charAt(0).toUpperCase() + text.slice(1);
                  }
                  
                  // Zahlworte + Nach-Zahl-Großschreibung + Multiplikatoren
                  function wordsToNumbersSmart(text) {
                      const ones = {
                          'null': 0, 'eins': 1, 'eine': 1, 'einen': 1,
                          'zwei': 2, 'drei': 3, 'vier': 4, 'fünf': 5,
                          'sechs': 6, 'sieben': 7, 'acht': 8, 'neun': 9,
                          'zehn': 10, 'elf': 11, 'zwölf': 12, 'dreizehn': 13,
                          'vierzehn': 14, 'fünfzehn': 15, 'sechzehn': 16,
                          'siebzehn': 17, 'achtzehn': 18, 'neunzehn': 19
                      };
                  
                      const tens = {
                          'zwanzig': 20, 'dreißig': 30, 'vierzig': 40,
                          'fünfzig': 50, 'sechzig': 60, 'siebzig': 70,
                          'achtzig': 80, 'neunzig': 90
                      };
                  
                      const multipliers = {
                          'hundert': 100,
                          'tausend': 1000
                      };
                  
                      const skipWords = ['und', 'oder', 'mit', 'für', 'pro'];
                  
                      const words = text.toLowerCase().split(/\s+/);
                      const finalText = [];
                      let i = 0;
                      let capitalizeNext = 0;
                  
                      while (i < words.length) {
                          const word = words[i];
                  
                          // Fall: Zahlwort + "und" + Zehner
                          if (ones[word] !== undefined) {
                              if (i + 2 < words.length && words[i + 1] === 'und' && tens[words[i + 2]]) {
                                  const value = ones[word] + tens[words[i + 2]];
                                  finalText.push(value.toString());
                                  capitalizeNext = 2;
                                  i += 3;
                                  continue;
                              }
                  
                              // Fall: Zahlwort + "hundert"/"tausend"
                              if (i + 1 < words.length && multipliers[words[i + 1]]) {
                                  const value = ones[word] * multipliers[words[i + 1]];
                                  finalText.push(value.toString());
                                  capitalizeNext = 2;
                                  i += 2;
                                  continue;
                              }
                  
                              finalText.push(ones[word].toString());
                              capitalizeNext = 2;
                              i++;
                          } else if (tens[word] !== undefined) {
                              finalText.push(tens[word].toString());
                              capitalizeNext = 2;
                              i++;
                          } else if (!isNaN(word)) {
                              finalText.push(word);
                              capitalizeNext = 2;
                              i++;
                          } else {
                              if (capitalizeNext > 0 && !skipWords.includes(word)) {
                                  finalText.push(word.charAt(0).toUpperCase() + word.slice(1));
                                  capitalizeNext--;
                              } else {
                                  finalText.push(word);
                              }
                              i++;
                          }
                      }
                  
                      return finalText.join(' ');
                  }
                  
                  

                  Auch ich hinterfrage den Sinn meiner 10 Echos täglich. Außer Lichter / Geräte damit schalten wird es immer weniger.

                  M 1 Reply Last reply Reply Quote 0
                  • M
                    martin_olw @Heimweh last edited by martin_olw

                    @heimweh Danke für das Teilen deines Scripts. Ich habe es mit übernommen, in Zeile 4 und 5 meine Daten ergänzt, bekomme allerdings folgenden Fehler:

                    javascript.0	09:51:07.115	error	script.js.common.ToDoist.Einkaufsliste_Alexa_Todoist compile failed: at script.js.common.ToDoist.Einkaufsliste_Alexa_Todoist:12
                    

                    Woran kann das liegen? Zeilen sind exakt wie in deinem Script.

                    Im Log:
                    2b0553d1-1f18-4873-9ac0-a799fcde2bc7-image.png
                    Danke für die Hilfe!
                    VG Martin

                    Heimweh 1 Reply Last reply Reply Quote 0
                    • Heimweh
                      Heimweh @martin_olw last edited by

                      @martin_olw ist auf Deinem System Axios installiert?

                      M 1 Reply Last reply Reply Quote 0
                      • M
                        martin_olw @Heimweh last edited by

                        @heimweh Leider nein. Dann weiß ich ja warum es nicht läuft. Mit Axios auf dem Raspi habe ich mich auch noch nicht beschäftigt.

                        Ro75 1 Reply Last reply Reply Quote 0
                        • Ro75
                          Ro75 @martin_olw last edited by

                          @martin_olw brauchst du auch nicht. Füge axios als zusätzliches npm Paket im js-Adapter.

                          Ro75.

                          M 1 Reply Last reply Reply Quote 0
                          • M
                            martin_olw @Ro75 last edited by

                            @ro75 Ich habe jetzt eine Weile mit Hilfe von Google und diversen Foreneinträgen probiert, aber ich habe nicht verstanden, wie ich axios in meinen ioBroker hinein bekomme. Könnt ihr mir da im DAU-Style weiterhelfen?
                            Danke 😉

                            Ro75 Der-Jeti 2 Replies Last reply Reply Quote 0
                            • Ro75
                              Ro75 @martin_olw last edited by

                              @martin_olw habe ich doch geschrieben. Füge axios als zusätzliches NPM Modul in den Javascript Adapter ein. Fertig

                              Ro75.

                              1 Reply Last reply Reply Quote 0
                              • Der-Jeti
                                Der-Jeti @martin_olw last edited by

                                @martin_olw so.

                                Screenshot_20250402_111321_Chrome.jpg

                                M 1 Reply Last reply Reply Quote 0
                                • M
                                  martin_olw @Der-Jeti last edited by

                                  @Der-Jeti und @Ro75
                                  Das habe ich gestern direkt gemacht:
                                  e1d96d49-ee81-4533-b682-c4f8617af576-image.png
                                  Der Fehler kam weiterhin:

                                  javascript.0	15:15:26.709	error	script.js.common.ToDoist.Einkaufsliste_Alexa_Todoist compile failed: at script.js.common.ToDoist.Einkaufsliste_Alexa_Todoist:12
                                  

                                  Deswegen dachte ich, ich muss das NPM-Modul axios noch anderweitig im ioBroker installieren. Sorry für die Verwirrung.
                                  Aber dann liegt der Fehler nicht am fehlenden axios.

                                  Heimweh 2 Replies Last reply Reply Quote 0
                                  • Heimweh
                                    Heimweh @martin_olw last edited by

                                    @martin_olw ich schaue heute Abend nochmal. Läuft es bei irgendjemand sonst?

                                    1 Reply Last reply Reply Quote 0
                                    • Heimweh
                                      Heimweh @martin_olw last edited by

                                      @martin_olw kannst du mal posten was bei Dir in Zeile 12 steht im Skript?

                                      M 1 Reply Last reply Reply Quote 0
                                      • M
                                        martin_olw @Heimweh last edited by

                                        @heimweh Da steht bei mir:

                                        10  if (typeof inputRaw !== 'string') {
                                        11     console.warn(⚠️ Kein String erkannt in alexa2.0.History.summary:', inputRaw);
                                        12      return;
                                        13    }
                                        
                                        Heimweh M 2 Replies Last reply Reply Quote 0
                                        • Heimweh
                                          Heimweh @martin_olw last edited by

                                          @martin_olw auf den ersten Blick fehlt das Hochkomma vor dem Ausrufezeichen....

                                          1 Reply Last reply Reply Quote 0
                                          • M
                                            MCU @martin_olw last edited by

                                            @martin_olw

                                            10  if (typeof inputRaw !== 'string') {
                                            11     console.warn('⚠️ Kein String erkannt in alexa2.0.History.summary:' + inputRaw);
                                            12      return;
                                            13    }
                                            
                                            M 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            894
                                            Online

                                            31.6k
                                            Users

                                            79.4k
                                            Topics

                                            1.3m
                                            Posts

                                            25
                                            144
                                            13158
                                            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