Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Alexa Einkaufsliste löschen

    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 Einkaufsliste löschen

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

      Hallo. Ich betreibe einen cubinote Thermodrucker mit untenstehenden Script. Kann mir vielleicht jemand helfen? Ich möchte das die Einkaufsliste nach dem Drucken gelöscht wird oder zumindest ein Dp. den ich nach Bedarf aktivieren kann.
      Vielleicht nimmt sich ja jemand die Zeit, danke.

          var aLists = JSON.parse(getState(list).val);
          var printList = '';
          var TimeStampList = moment().format('DD.MM.YYYY HH:mm');
          if(list == 'alexa2.0.Lists.SHOPPING_LIST.json'){
              printList = 'Einkaufsliste '+TimeStampList+'\n\r';
              printList += '================================\n\n\r';
          }
          if(list == 'alexa2.0.Lists.TO_DO.json'){
              printList = 'TODO Liste '+TimeStampList+'\n\r';
              printList += '================================\n\n\r';
          }
           printList += aLists.map(function (val) {
              var item = val.value
              item = item[0].toUpperCase() + item.substring(1);
              return (val.completed ? '[X] ' : '[ ] ') + item;
          }).join('\n\n\r');
         
        //es sind keine Umlaute zulässig somit müssen diese ersetzt werden
          printList = printList.replace(/Ä/g, 'Ae');
          printList = printList.replace(/ä/g, 'ae');
          printList = printList.replace(/Ö/g, 'Oe');
          printList = printList.replace(/ö/g, 'oe');
          printList = printList.replace(/Ü/g, 'Ue');
          printList = printList.replace(/ü/g, 'ue');
          printList = printList.replace(/ß/g, 'ss');
      
          var base64 = new Buffer(printList).toString('base64');
      
          apiUrl += base64;
        
          //console.log(apiUrl);
          const request = require('request');
          request({ 'uri': apiUrl}, function (error, response, json) {
              if (!error && response.statusCode === 200) {
      
                  var aReturn = JSON.parse(json);
                  //{"showapi_res_code":1,"showapi_res_error":"ok","result":2,"printcontentid":52476}
                  if (aReturn.result == 2) {
                      var statusUrl = aApiSettings.url + aApiSettings.action.printstatus + aApiSettings.appid + aApiSettings.accesskey + sTimestamp;
                      statusUrl += '&printcontentid=' + aReturn.printcontentid;
      
                      request({ 'uri': statusUrl }, function (err, resp, jsonStatus) {
                          //{"showapi_res_code":1,"showapi_res_error":"ok","printflag":1,"printcontentid":52476}
                          var outputDevice = aApiSettings.echodevice;
                          
                          setState(outputDevice + ".Commands.speak", '50; Drucken Liste erfolgreich');
      
                      });
      
                  }
      
              }
          });
      
          setStateDelayed(state, false, 2000, false);
      });
      

      }

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

        @toni

        könnte so funktionieren:

        
           let theArr=JSON.parse(getState('alexa2.0.Lists.SHOPPING_LIST.json').val)
        
          for(let i=0;i<theArr.length;i++){
        
           let toDelete=theArr[i].id;
               setTimeout( function timer(){
              var stateHelp="alexa2.0.Lists.SHOPPING_LIST.items."+toDelete+".#delete"
            log("Statehelp: "+stateHelp)
            setState(stateHelp,true);
            }, i*2500 );
          }
        
        toni 1 Reply Last reply Reply Quote 0
        • toni
          toni @liv-in-sky last edited by

          @liv-in-sky danke dir, funktioniert wunderbar.

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

          Support us

          ioBroker
          Community Adapters
          Donate

          946
          Online

          31.9k
          Users

          80.1k
          Topics

          1.3m
          Posts

          2
          3
          274
          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