Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Juergen Sußner

    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

    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 1
    • Best 0
    • Groups 0

    Juergen Sußner

    @Juergen Sußner

    0
    Reputation
    8
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Juergen Sußner Follow

    Latest posts made by Juergen Sußner

    • RE: Alexa Shopping List mit Bring synchronisieren

      @dicken

      Zumindest einen oneWay Sync mit todoist konnte ich bauen,

      const axios = require('axios');
      
      // Überwachen der Änderung des JSON-Arrays
      on({id: 'alexa2.0.Lists.SHOPPING_LIST.json', change: 'any'}, function (obj) {
          try {
              const jsonArray = JSON.parse(obj.state.val);
              if (jsonArray && jsonArray.length > 0) {
                  const currentTime = Date.now();
                  const timeLimit = 30 * 60 * 1000; // 30 Minuten in Millisekunden
      
                  // Überprüfen, ob das erste Element innerhalb der letzten 30 Minuten erstellt wurde
                  const createdDateTime = jsonArray[0].createdDateTime;
                  const completed=jsonArray[0].completed;
                  console.log(jsonArray[0]);
                  if (currentTime - createdDateTime < timeLimit && !completed ) {
                      const item = jsonArray[0].value;
      
                      const data = {
                          content: item,
                          project_id: '12345678'
                      };
      
                      axios.post('https://api.todoist.com/rest/v2/tasks', data, {
                          headers: {
                              'Content-Type': 'application/json',
                              'X-Request-Id': '598cee9a-cec2-44c0-9cc6-e3eae1608c53',
                              'Authorization': 'Bearer $token'
                          }
                      })
                      .then(response => {
                          console.log('Task created successfully:', response.data);
                      })
                      .catch(error => {
                          console.error('Error creating task:', error);
                      });
                  } else {
                      console.log('The item is older than 30 minutes, no task created.');
                  }
              }
          } catch (e) {
              console.error('Error parsing JSON:', e);
          }
      });
      
      
      posted in Skripten / Logik
      Juergen Sußner
      Juergen Sußner
    Community
    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
    The ioBroker Community 2014-2023
    logo