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

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    Alexa Shopping List mit Bring synchronisieren

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      martin_olw @MCU last edited by

      @mcu Guten Morgen und Danke! Jetzt kommt erstmal keine Fehlermeldung mehr. Ich probiere es dann heute Abend mal aus, ob nach Sprachbefehl an die Alexa wieder was auf die Einkaufsliste wandert.

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

        Es kommt nichts auf der Einkaufslisten an. Liegt es daran, dass die API von Alexa nun doch gekappt ist?

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

          @martin_olw der Datenpunkt "summary" funktioniert bei mir zumindest nach wie vor. Leider kann ich Dir nicht sagen wieso es bei Dir nicht geht - hast Du denn Deinen Token und die Nummer der Liste richtig drin? Bitte prüfe das mal - wieso es bei Dir beim kopieren und einfügen Zeichen verschluckt hat ist mir auch ein Rätsel.....

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

            @heimweh Wenn ich mir den Datenpunkt in den Listen so anschaue, dann denke ich der wird nicht mehr gefüllt, oder? Gerade mit Blick auf die Zeitstempel?
            21903515-8e21-4bd1-b31f-befdf18fa57c-image.png

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

              @martin_olw also bei mir geht alles. Lies mal unter folgendem Link, ob du im Adapter auch den Haken gesetzt hast: https://github.com/Apollon77/ioBroker.alexa2/issues/1223

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

                @heimweh Ich habe den Adapter noch einmal neu installiert und konfiguriert. Jetzt kommen auch wieder Daten in den history-Datenpunkt. Und immerhin jeden zweiten bis dritten Artikel setzt es auch auf die Einkaufsliste in ToDoist.
                Was mich wundert - die Alexa-interne Einkaufsliste füllt sich zuverlässig.

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

                  Mit der neuen Version vom Alexa Adapter 3.27.0 und dem Script funktioniert das Synchronisieren auf beiden Seiten wieder.

                  const bringBaseId = 'bring.0.xxxxxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxx';
                  const alexa2BaseId = 'alexa2.0.Lists.SHOP';
                  
                  const bringListId = bringBaseId + '.content';
                  const bringListCompletedId = bringBaseId + '.recentContent';
                  const bringAddToList = bringBaseId + '.saveItem';
                  const bringCompleteItem = bringBaseId + '.moveToRecentContent';
                  const alexaAddToList = alexa2BaseId + '.#New';
                  const alexaListId = alexa2BaseId + '.json';
                  
                  const printDebug = true;
                  function debug(msg) {
                      if (printDebug) log(msg);
                  }
                  
                  const TodoItemStatus = {
                      NeedsAction: 'needs_action',
                      Completed: 'completed',
                  };
                  
                  function ListCleaner(Eintrag = '') {
                      return Eintrag
                          .split(' ')
                          .map(w => w.charAt(0).toUpperCase() + w.slice(1))
                          .join(' ');
                  }
                  
                  function compareCompleted(alexaItem, bringItem) {
                      return (
                          (alexaItem.completed && bringItem.status === TodoItemStatus.Completed) ||
                          (!alexaItem.completed && bringItem.status === TodoItemStatus.NeedsAction)
                      );
                  }
                  
                  function eliminateDuplicated() {
                      const raw = getState(alexaListId).val;
                      if (!raw) return;
                      const list = JSON.parse(raw);
                      const seen = {};
                      for (const item of list) {
                          const cleaned = ListCleaner(item.value);
                          if (seen[cleaned]) {
                              debug(`Delete duplicate Alexa item: ${item.value}`);
                              setState(`${alexa2BaseId}.items.${item.id}.#delete`, true);
                          } else {
                              seen[cleaned] = true;
                          }
                      }
                  }
                  
                  function syncLists(alexaList, bringList, timestampBring, source, recentList) {
                      for (const alexaItem of alexaList) {
                          const cleanedName = ListCleaner(alexaItem.value);
                          alexaItem.found = false;
                  
                          // Suche im aktiven Bring-Einträgen
                          for (const bringItem of bringList) {
                              if (ListCleaner(bringItem.name) === cleanedName) {
                                  alexaItem.found = true;
                                  bringItem.found = true;
                  
                                  if (alexaItem.updatedDateTime > timestampBring) {
                                      if (!compareCompleted(alexaItem, bringItem)) {
                                          if (source === 'Alexa' && alexaItem.completed) {
                                              debug(`Markiere "${bringItem.name}" als erledigt in Bring (von Alexa)`);
                                              setState(bringCompleteItem, cleanedName);
                                          }
                                      }
                                  } else {
                                      if (!compareCompleted(alexaItem, bringItem)) {
                                          if (source === 'Bring') {
                                              debug(`Aktualisiere "${alexaItem.value}" in Alexa (von Bring)`);
                                              setState(`${alexa2BaseId}.items.${alexaItem.id}.completed`, bringItem.status === TodoItemStatus.Completed);
                                          }
                                      }
                                  }
                              }
                          }
                  
                          // Suche im "recentContent" von Bring
                          for (const bringItem of recentList) {
                              if (ListCleaner(bringItem.name) === cleanedName) {
                                  alexaItem.found = true;
                                  bringItem.found = true;
                  
                                  if (alexaItem.updatedDateTime > timestampBring) {
                                      if (source === 'Alexa' && !compareCompleted(alexaItem, bringItem)) {
                                          debug(`Füge "${bringItem.name}" erneut zu Bring hinzu (von Alexa)`);
                                          setState(bringAddToList, cleanedName);
                                      }
                                  } else {
                                      if (!compareCompleted(alexaItem, bringItem)) {
                                          if (source === 'Bring') {
                                              debug(`Lösche Alexa-Eintrag "${alexaItem.value}" (von Bring)`);
                                              setState(`${alexa2BaseId}.items.${alexaItem.id}.#delete`, true);
                                          }
                                      }
                                  }
                              }
                          }
                  
                          // Alexa-Item nicht gefunden in Bring
                          if (!alexaItem.found) {
                              if (alexaItem.completed) {
                                  debug(`Lösche erledigten Alexa-Eintrag "${alexaItem.value}", nicht in Bring gefunden.`);
                                  setState(`${alexa2BaseId}.items.${alexaItem.id}.#delete`, true);
                              } else if (source === 'Alexa') {
                                  debug(`Füge neuen Alexa-Eintrag "${alexaItem.value}" zu Bring hinzu`);
                                  setState(bringAddToList, cleanedName);
                              }
                          }
                      }
                  
                      // Bring-Einträge, die nicht in Alexa sind
                      for (const bringItem of bringList) {
                          if (!bringItem.found && bringItem.status !== TodoItemStatus.Completed && source === 'Bring') {
                              debug(`Füge Bring-Eintrag "${bringItem.name}" zu Alexa hinzu`);
                              setState(alexaAddToList, ListCleaner(bringItem.name));
                          }
                      }
                  }
                  
                  function doSync(source) {
                      eliminateDuplicated();
                  
                      const rawAlexa = getState(alexaListId).val;
                      const rawBring = getState(bringListId).val;
                      const rawCompleted = getState(bringListCompletedId).val;
                  
                      if (!rawAlexa || !rawBring || !rawCompleted) {
                          debug('Datenpunkte unvollständig');
                          return;
                      }
                  
                      const alexaList = JSON.parse(rawAlexa);
                      const bringList = JSON.parse(rawBring);
                      const bringCompleted = JSON.parse(rawCompleted);
                      const timestamp = getState(bringListId).ts;
                  
                      syncLists(alexaList, bringList, timestamp, source, bringCompleted);
                  }
                  
                  on({ id: bringListId, change: 'any' }, () => {
                      debug('Änderung durch Bring erkannt');
                      doSync('Bring');
                  });
                  
                  on({ id: alexaListId, change: 'any' }, () => {
                      debug('Änderung durch Alexa erkannt');
                      doSync('Alexa');
                  });
                  
                  // Initial Sync beim Start
                  doSync('Startup');
                  
                  
                  M 1 Reply Last reply Reply Quote 0
                  • M
                    MCU @Der-Jeti last edited by MCU

                    @der-jeti 3.27.0 gibt es nicht
                    5a708cda-cfe8-4011-a13e-69b8288ea640-image.png
                    EDIT: anscheinend doch
                    "version": "3.27.0",

                    T mcBirne 2 Replies Last reply Reply Quote 0
                    • T
                      thorschtn @MCU last edited by

                      @mcu Funktioniert einwandfrei. Lediglich die noch nicht offiziell releaste 3.27.0 laden und im Javascript die const alexa2BaseId ändern.

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

                        @mcu Wo findest du die v3.27.0? Ich finde nur die v3.26.7

                        Der-Jeti M 2 Replies Last reply Reply Quote 0
                        • Der-Jeti
                          Der-Jeti @mcBirne last edited by

                          @mcbirne mit der Katze von github laden.

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

                            @mcbirne
                            https://github.com/Apollon77/ioBroker.alexa2/blob/9baece37d4796b88d8debb7af9cbfef50cfc92c8/io-package.json#L4

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

                              @Heimweh - kann mit der neuen Version vom Alexa Adapter 3.27.x über die Datenpunkte in alexa2.0.Lists.SHOP mit TODOIST gesycnt oder zuverlässig nach TODOIST geschrieben werden? Aktuell klappt das bei mir mit deinem Skript nur in 30 % der Fälle.
                              Danke!
                              VG Martin

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

                                @martin_olw bei mir hat das zu 100% funktioniert. Ich habe mir zuletzt einen eigenen Alexa Skill gebastelt für Einkaufs und Todoliste mit Todoist. Es hat auch geklappt allerdings blöd zum aufrufen. Bsp.: Alexa sag meinen Projekten, ich muss Fenster putzen. - bei dem Script den ich online gestellt hatte war bei mir öfters das Problem der summary Datenpunkt der zeitweise nicht funktioniert. Ich kann Dir derzeit nicht helfen weil ich noch 3 Wochen im Urlaub bin, habe aber interessiert hier mitgelesen und wollte mir das nach Rückkehr mal anschauen..... Ich denke schon dass man das wieder verknüpfen kann so das es mit Todoist läuft

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

                                Support us

                                ioBroker
                                Community Adapters
                                Donate

                                936
                                Online

                                31.9k
                                Users

                                80.1k
                                Topics

                                1.3m
                                Posts

                                25
                                152
                                16241
                                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