Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Brauche Hilfe bei Anrufer Ansage

    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

    Brauche Hilfe bei Anrufer Ansage

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

      Re: [Vorlage] Simple Anrufer-Ansage via Alexa/tr-064

      Das Script läuft an ohne Fehler. Jedoch wenn ein Anruf reinkommt werden folgende Fehler rausgeschmissen.
      Wie kann ich das reparieren? Ich wäre Euch dankbar für Eure Hilfe oder einen funktionierenden Code 😉

      
      31.5.2024, 13:49:05.347	[error]: javascript.0 (5076) script.js.common.ANRUFER_ANSAGE_: The "getState" method cannot be used synchronously, because the adapter setting "Do not subscribe to all states on start" is enabled.
      31.5.2024, 13:49:05.348	[error]: javascript.0 (5076) script.js.common.ANRUFER_ANSAGE_: Please disable that setting or use "getState" with a callback, e.g.: getState('tr-064.0.callmonitor.inbound.callee', (err, state) => { ... });
      31.5.2024, 13:49:05.359	[error]: javascript.0 (5076)     at tellMeWhoCalls (script.js.common.ANRUFER_ANSAGE_:14:63)
      31.5.2024, 13:49:05.360	[error]: javascript.0 (5076)     at Object.<anonymous> (script.js.common.ANRUFER_ANSAGE_:66:9)
      31.5.2024, 13:49:09.347	[error]: javascript.0 (5076) script.js.common.ANRUFER_ANSAGE_: The "getState" method cannot be used synchronously, because the adapter setting "Do not subscribe to all states on start" is enabled.
      31.5.2024, 13:49:09.348	[error]: javascript.0 (5076) script.js.common.ANRUFER_ANSAGE_: Please disable that setting or use "getState" with a callback, e.g.: getState('tr-064.0.callmonitor.inbound.callee', (err, state) => { ... });
      31.5.2024, 13:49:09.354	[error]: javascript.0 (5076)     at tellMeWhoCalls (script.js.common.ANRUFER_ANSAGE_:14:63)
      31.5.2024, 13:49:09.355	[error]: javascript.0 (5076)     at Object.<anonymous> (script.js.common.ANRUFER_ANSAGE_:61:9)
      

      MOD-EDIT: Code in code-tags gesetzt!

      Homoran paul53 2 Replies Last reply Reply Quote 0
      • Homoran
        Homoran Global Moderator Administrators @WUCHTTIGER last edited by

        @wuchttiger sagte in Brauche Hilfe bei Anrufer Ansage:

        Das Script

        und warum zeigst du es nicht?

        WUCHTTIGER 1 Reply Last reply Reply Quote 0
        • WUCHTTIGER
          WUCHTTIGER @Homoran last edited by

          @homoran Das Script war im original Thread zu sehen, deswegen habe ich es nicht erneut gepostet. Hatte nur auf Empfehlung hin einen neuen Thread eröffnet, weil der originale schon etwas älter war.

          Anbei der Code, welche ich nutze

          //* Insert own numbers with description
          const numbers = {
              '01234512345': 'privat',
              '01234522222': 'Büro'
          };
           
          function tellMeWhoCalls(sayattention) {
              let curtime = new Date();
              //* not between 21pm and 7am UTC
              if(curtime.getHours() < 7 || curtime.getHours() > 21) {
                  return;
              }
              let targ = getState('tr-064.0.callmonitor.inbound.callee').val;
              let src = getState('tr-064.0.callmonitor.inbound.caller').val;
              let srcName = getState('tr-064.0.callmonitor.inbound.callerName').val;
           
              let targName = numbers[targ];
              if(!targName) {
                  targName = 'unbekannt';
              }
           
              let text = (sayattention ? 'Achtung! ' : '') + 'Anruf für ' + targName + ' von ';
              if(srcName) {
                  text += srcName;
              } else if(src) {
                  text += '<say-as interpret-as="digits">' + src + '</say-as>';
              } else {
                  text += 'unbekannter Nummer';
              }
              text += '.';
           
              text = '<speak>' + text + '</speak>';
           
              //* replace XXXXX by your echo device id and add further lines for more devices
              setState('alexa2.0.Echo-Devices.XXXXXXX.Commands.ssml', text);
           
              if(targName === 'privat') {
                  //* replace YYYYYY by your echo device id or delete this part if you don't need it
                  setState('alexa2.0.Echo-Devices.YYYYYYYY.Commands.ssml', text);
              }
          }
           
          let ringInterval = null;
           
          on({id: 'tr-064.0.callmonitor.ringing', change: 'ne'}, function(obj) {
              if(obj.state.val !== true) {
                  //* no longer ringing
                  if(ringInterval) {
                      clearInterval(ringInterval);
                      ringInterval = null;
                  }
                  return;
              }
           
              if(ringInterval) {
                  clearInterval(ringInterval);
              }
              //* repeat caller anouncement each 10 secs
              ringInterval = setInterval(function() {
                  tellMeWhoCalls();
              }, 10000);
           
              //* first time add "Achtung!" in front of the text
              setTimeout(function() {
                  tellMeWhoCalls(true);
              }, 1000);
          });
          
          1 Reply Last reply Reply Quote 0
          • paul53
            paul53 @WUCHTTIGER last edited by

            @wuchttiger sagte: because the adapter setting "Do not subscribe to all states on start" is enabled.

            Nimm in der Instanz-Konfiguration den Haken raus!

            WUCHTTIGER 2 Replies Last reply Reply Quote 0
            • WUCHTTIGER
              WUCHTTIGER @paul53 last edited by

              @paul53 Danke für deine schnelle Antwort. Ich gehe davon aus, dass du die TR-064 Instanz meinst.
              Aber welcher Haken ist das ?

              paul53 1 Reply Last reply Reply Quote 0
              • WUCHTTIGER
                WUCHTTIGER @paul53 last edited by

                @paul53 Habe es gefunden. Vielen Dank für den Tipp. Es war in der Java Script Instanz.

                1 Reply Last reply Reply Quote 0
                • paul53
                  paul53 @WUCHTTIGER last edited by paul53

                  @wuchttiger sagte: dass du die TR-064 Instanz meinst.

                  Nein, die Javascript-Instanz.

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

                  Support us

                  ioBroker
                  Community Adapters
                  Donate

                  939
                  Online

                  31.9k
                  Users

                  80.1k
                  Topics

                  1.3m
                  Posts

                  3
                  7
                  197
                  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