Ankündigung

Einklappen
Keine Ankündigung bisher.

AVM Plugin

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Neuchr das Problem hatte schon mal wer. Bei mir ist es aber reproduzierbar die aktuell angerufene nummer.. ich hatte im backend das feld geleert und dann angerufen. daher bin ich aktuell ratlos, warum das bei bestimmten konstellationen sich anders verhält.

    du kannst mal via telnet auf den callmonitor connecten und schauen, was da passiert. das incoming event ist aber auf true? das bitte auch loggen!!!!

    eine these wäre, dass der callmonitor die verbindung verloren hat (warum auch immer). aktuell ist da kein reconnect drin. daher testweise auch mal shng durchstarten, bevor du testest

    Kommentar


      Das ist ja komisch ich habe die drei folgenden Zeilen am anfange der Logik eingetragen.

      Code:
      logger.error("Start")
      logger.error(sh.avm.monitor.incoming.last_called_n umber())
      logger.error(sh.avm.monitor.incoming.is_call_incom ing())
      Wenn ich die8xxxx anrufe und es zweimal Klingeln lasse und wieder auflege habe ich folgende Log Ausgabe.

      Code:
      [LIST=1][*]2018-02-03 16:46:36 ERROR logics.MusikLeiser Start[*]2018-02-03 16:46:36 ERROR logics.MusikLeiser 6xxxx[*]2018-02-03 16:46:36 ERROR logics.MusikLeiser True[*]2018-02-03 16:46:39 ERROR logics.MusikLeiser Start[*]2018-02-03 16:46:39 ERROR logics.MusikLeiser 8xxxxx[*]2018-02-03 16:46:39 ERROR logics.MusikLeiser False[/LIST]
      Beim eingehenden Anruf wird die Nr vom vorherigen Anruf angezeigt. (Zeile 1-3) Beim auflegen vom aktuellen. (Zeile 4-6) Deshalb bin ich der Meinung das das Item erst beim auflegen aktualisiert wird. Das ist beliebig oft reproduzierbar.

      Der Telnet auf den callmonitor zeigt mir die richtigen Daten an

      Code:
      03.02.18 16:46:36;RING;0;0172800xxxx;8xxxxx;SIP5;
      03.02.18 16:46:39;DISCONNECT;0;0;
      Die xxxxx habe ich eingetragen möchte meine Nummern hier nicht so Posten.

      Kommentar


        logge bitte mal den bool wert vor der nummernausgabe. wobei das wahrsch nicht viel bringt.ich teste morgen nochmal mit exakt der logik von dir. auf was hast du das watch item gelegt?

        heute sind die kinder schon im bett. da geht nichts mehr

        Kommentar


          Erst einmal Danke für die super Unterstützung. Das watch item habe ich auf avm.monitor.incoming.is_call_incoming gelegt aber meine logic.yaml steht auch weiter oben. Was meinst du mit bool wert von der nummernausgabe?

          Kommentar


            das is_call_incoming..

            Wenn Du selber weiterprobieren magst, könntest Du direkt im AVM Plugin in dieser Methode hier mal Debugausgaben einbauen:
            Code:
                            # process items specific to incoming calls
                            for item in self._items_incoming:  # update items for incoming calls
                                if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['is_call_incoming']:
                                    item(1)
                                elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['last_caller_incoming']:
                                    if call_from != '' and call_from is not None:
                                        name = self._callback(call_from)
                                        if name != '' and not name is None:
                                            item(name)
                                        else:
                                            item(call_from)
                                    else:
                                        item("Unbekannt")
                                elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in [
                                    'last_call_date_incoming']:
                                    item(time)
                                elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['call_event_incoming']:
                                    item(event.lower())
                                elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['last_number_incoming']:
                                    item(call_from)
                                elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in [
                                    'last_called_number_incoming']:
                                    item(call_to)
            Da werden die ganzen Flags gesetzt.. Du siehst, dass hier bspw. das call_event_incoming und das "last_called_number_incoming" im gleichen Block gesetzt werden. Daher ist mir derzeit schleierhaft, wie das Verhalten zustande kommt. wird denn die anrufende nummer richtig geupdated? kannst diese ja davor testweise im backend mal verändern.

            Achja, die Zeile die Du im telnet siehst, müsste im Debug-Modus des Plugins bereits geloggt werden - siehe das mit "line" unten:

            Code:
                def _parse_line(self, line):
                    """
                    Parses a data set in the form of a line.
            
                    Data Format:
                    Ausgehende Anrufe: datum;CALL;ConnectionID;Nebenstelle;GenutzteNummer;AngerufeneNummer;SIP+Nummer
                    Eingehende Anrufe: datum;RING;ConnectionID;Anrufer-Nr;Angerufene-Nummer;SIP+Nummer
                    Zustandegekommene Verbindung: datum;CONNECT;ConnectionID;Nebenstelle;Nummer;
                    Ende der Verbindung: datum;DISCONNECT;ConnectionID;dauerInSekunden;
            
                    :param line: data line which is parsed
                    """
                    self.logger.debug(line)
                    line = line.split(";")
            
                    if line[1] == "RING":
                        call_from = line[3]
                        call_to = line[4]
                        self._trigger(call_from, call_to, line[0], line[2], line[1], '')
                    elif line[1] == "CALL":
                        call_from = line[4]
                        call_to = line[5]
                        self._trigger(call_from, call_to, line[0], line[2], line[1], line[3])
                    elif line[1] == "CONNECT":
                        self._trigger('', '', line[0], line[2], line[1], line[3])
                    elif line[1] == "DISCONNECT":
                        self._trigger('', '', '', line[2], line[1], '')
            Dieser ganze Ablauf wäre mal zu prüfen, falls ich morgen das Ganze wirklich nicht nachgestellt kriege..

            Wobei ich mich gerade frage, ob schlichtweg die Abarbeitung im Code zwischen dem Event und dem abarbeiten der Zeile aus dem Telnet so lange dauert, dass Du ein True hast, die Nummer aber noch nicht gesetzt ist..

            Kannst Du nochmal länger klingeln lassen und das bitte im Blick behalten? Mit welcher Hardware bist Du unterwegs? Vielleicht merke ich das nur nicht, weil mein NAS einfach zu schnell abarbeitet..
            Zuletzt geändert von psilo; 03.02.2018, 17:37.

            Kommentar


              Ich habe im Backend die last_called_number geändert wenn ich das Feld verlasse trägt er von selber die vorherige Nr wieder ein. Wenn ich ein Anruf tätige taucht im Logfile beim Rufaufbau sprich beim ersten Logik durchlauf meine eingetragene Nr aus dem Backend auf. Daraus schließe ich dann wieder das warum auch immer beim Ruf Aufbau etwas falschläuft bzw. die Nr nicht aktualisiert wird. Beim Auflegen stimmt es dann wieder.

              Kommentar


                das ist dann aber ganz seltsam. du kannst via backend nicht die nummer ändern (speichern passiert erst nach verlassen des input felds)? oder bleibt kurzzeitig die geänderte nach verlassen des feldes da und ist erst nach reload der itemdetails anders?
                Zuletzt geändert von psilo; 03.02.2018, 18:09.

                Kommentar


                  in den rahmen noch die frage: welche version verwendest du?

                  Kommentar


                    Wenn ich das Feld verlasse führt er selbständig ein reload durch und ändert die Nr wieder. Solange ich im Feld bin bleibt die Nr stehen die ich Manuale eingetragen habe. Diese taucht dann beim Anruf im Log auf obwohl sie durch verlassen des Feldes sich wieder geändert hat.

                    SmartHomeNG 1.4.2
                    Phyton 3.5.3
                    SmartVisu 2.8
                    AVM Plugin 1.2.3

                    Kommentar


                      Neuchr das ist kein reload. er scheitert beim speichern des items und setzt den initialwert wieder... du müsstest mal rausfinden, ob da ein fehler vom backend geloggt wird? geht es bei anderen items bei dir

                      Kommentar


                        ich habe eben mehrere anrufe von mehreren quell und zielnummern getestet. bei mir steht definitiv immer die neuste nummer drin. allerdings hatte ich beim 3ten fall für is call incoming ein false im item. in den fall ging das fax fast sofort an meine 3te rufnummer. ich vermute, dass teilweise der callmonitor via telnet so schnell daten schickt, dass die abarbeitung im code nicht mehr hinterherkommt. ich schaue mir das mal über die nächsten wochen an, vielleicht kann man optimieren. vielleicht es da aber auch der wurm in der telnet schnittstelle. ich glaube mich zu erinnern, dass ich da mehrfach seltsames verhalten hatte.

                        ich bitte dich nochmal zu testen, was passiert, wenn du es länger klingeln lässt..


                        die anpassungen des plugin werden aber sicher nicht mehr im 1.4er master landen, da das plugin mitlerweile im dev ein webinterface hat und die aktuellen dev core implementierungen braucht.
                        es gab übrigens für den teil ausserhalb des callmonitors noch nen bug, so dass dem fritz device alle items der shng instanz übergeben wurden. diese wurden zwar nicht verändert, trotzdem musste das plugin bei jedem cycle alle items durchgehen, was sicher auch laufzeitrelevant ist. der bug ist leider derzeit auch nur im dev gefixt.

                        PS: wer im DEV unterwegs ist und das Problem hat, für den habe ich im Debugmodus des Plugins das Logging für eingehende Anrufe gerade ausgebaut.. Wer Master hat, könnte den MonitoringService einfach mal ersetzen:
                        Code:
                        class MonitoringService():
                            """
                            Class which connects to the FritzBox service of the Callmonitor: http://www.wehavemorefun.de/fritzbox/Callmonitor
                        
                            | Can currently handle three items:
                            | - avm_data_type = is_call_incoming, type = bool
                            | - avm_data_type = last_caller, type = str
                            | - avm_data_type = last_call_date, type = str
                            """
                        
                            def __init__(self, host, port, callback, call_monitor_incoming_filter, plugin_instance):
                                self.logger = logging.getLogger(__name__)
                                self.logger.debug("starting monitoring service")
                                self._host = host
                                self._port = port
                                self._plugin_instance = plugin_instance
                                self._callback = callback
                                self._trigger_items = []  # items which can be used to trigger sth, e.g. a logic
                                self._items = []  # more general items for the call monitor
                                self._items_incoming = []  # items for incoming calls
                                self._items_outgoing = []  # items for outgoing calls
                                self._duration_item = dict()  # 2 items, on for counting the incoming, one for counting the outgoing call duration
                                self._call_active = dict()
                                self._call_active['incoming'] = False
                                self._call_active['outgoing'] = False
                                self._call_incoming_cid = dict()
                                self._call_outgoing_cid = dict()
                                self._call_monitor_incoming_filter = call_monitor_incoming_filter
                                self.conn = None
                        
                            def connect(self):
                                """
                                Connects to the call monitor of the AVM device
                                """
                                self.conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                                try:
                                    self.conn.connect((self._host, self._port))
                                    self._listen_thread = threading.Thread(target=self._listen,
                                                                           name="MonitoringService_{}".format(self._plugin_instance.get_fullname())).start()
                                except Exception as e:
                                    self.conn = None
                                    self.logger.error("MonitoringService: Cannot connect to " + self._host + " on port: " + str(
                                        self._port) + ", CallMonitor activated by #96*5*? - Error: " + str(e))
                                    return
                        
                            def disconnect(self):
                                """
                                Disconnects from the call monitor of the AVM device
                                """
                                self._listen_active = False
                                self._stop_counter('incoming')
                                self._stop_counter('outgoing')
                                try:
                                    self._listen_thread.join(1)
                                except:
                                    pass
                                self.conn.shutdown(2)
                        
                            def reconnect(self):
                                """
                                Reconnects to the call monitor of the AVM device
                                """
                                self.disconnect()
                                self.connect()
                        
                            def register_item(self, item):
                                """
                                Registers an item to the MonitoringService
                        
                                :param item: item to register
                                """
                                if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['is_call_incoming',
                                                                                                         'last_caller_incoming',
                                                                                                         'last_number_incoming',
                                                                                                         'last_called_number_incoming',
                                                                                                         'last_call_date_incoming',
                                                                                                         'call_event_incoming']:
                                    self._items_incoming.append(item)
                                elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['is_call_outgoing',
                                                                                                           'last_caller_outgoing',
                                                                                                           'last_number_outgoing',
                                                                                                           'last_called_number_outgoing',
                                                                                                           'last_call_date_outgoing',
                                                                                                           'call_event_outgoing']:
                                    self._items_outgoing.append(item)
                                elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') == 'monitor_trigger':
                                    self._trigger_items.append(item)
                                else:
                                    self._items.append(item)
                        
                            def get_items(self):
                                return self._items
                        
                            def get_trigger_items(self):
                                return self._trigger_items
                        
                            def get_items_incoming(self):
                                return self._items_incoming
                        
                            def get_items_outgoing(self):
                                return self._items_outgoing
                        
                            def set_duration_item(self, item):
                                """
                                Sets specific items which count the duration of an incoming or outgoing call
                                """
                                self._duration_item[self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type').split("@")[0]] = item
                        
                            def _listen(self, recv_buffer=4096):
                                """
                                Function which listens to the established connection.
                                """
                                self._listen_active = True
                                buffer = ""
                                data = True
                                while self._listen_active:
                                    data = self.conn.recv(recv_buffer)
                                    if data == "":
                                        self.logger.error("CallMonitor connection not open anymore.")
                                    else:
                                        self.logger.debug("Data Received from CallMonitor: %s" % data.decode("utf-8"))
                                    buffer += data.decode("utf-8")
                                    while buffer.find("\n") != -1:
                                        line, buffer = buffer.split("\n", 1)
                                        self._parse_line(line)
                        
                                    #time.sleep(1)
                                return
                        
                            def _start_counter(self, timestamp, direction):
                                if direction == 'incoming':
                                    self._call_connect_timestamp = time.mktime(
                                        datetime.datetime.strptime(timestamp, "%d.%m.%y %H:%M:%S").timetuple())
                                    self._duration_counter_thread_incoming = threading.Thread(target=self._count_duration_incoming,
                                                                                              name="MonitoringService_Duration_Incoming_%s" % self._plugin_instance.get_instance_name()).start()
                                    self.logger.debug('Counter incoming - STARTED')
                                elif direction == 'outgoing':
                                    self._call_connect_timestamp = time.mktime(
                                        datetime.datetime.strptime(timestamp, "%d.%m.%y %H:%M:%S").timetuple())
                                    self._duration_counter_thread_outgoing = threading.Thread(target=self._count_duration_outgoing,
                                                                                              name="MonitoringService_Duration_Outgoing_%s" % self._plugin_instance.get_instance_name()).start()
                                    self.logger.debug('Counter outgoing - STARTED')
                        
                            def _stop_counter(self, direction):
                                # only stop of thread is active
                        
                                if self._call_active[direction]:
                                    self._call_active[direction] = False
                                    self.logger.debug('STOPPING ' + direction)
                                    try:
                                        if direction == 'incoming':
                                            self._duration_counter_thread_incoming.join(1)
                                        elif direction == 'outgoing':
                                            self._duration_counter_thread_outgoing.join(1)
                                    except:
                                        pass
                        
                            def _count_duration_incoming(self):
                                self._call_active['incoming'] = True
                                while self._call_active['incoming']:
                                    if not self._duration_item['call_duration_incoming'] is None:
                                        duration = time.time() - self._call_connect_timestamp
                                        self._duration_item['call_duration_incoming'](int(duration))
                                    time.sleep(1)
                        
                            def _count_duration_outgoing(self):
                                self._call_active['outgoing'] = True
                                while self._call_active['outgoing']:
                                    if not self._duration_item['call_duration_outgoing'] is None:
                                        duration = time.time() - self._call_connect_timestamp
                                        self._duration_item['call_duration_outgoing'](int(duration))
                                    time.sleep(1)
                        
                            def _parse_line(self, line):
                                """
                                Parses a data set in the form of a line.
                        
                                Data Format:
                                Ausgehende Anrufe: datum;CALL;ConnectionID;Nebenstelle;GenutzteNummer;AngerufeneNummer;SIP+Nummer
                                Eingehende Anrufe: datum;RING;ConnectionID;Anrufer-Nr;Angerufene-Nummer;SIP+Nummer
                                Zustandegekommene Verbindung: datum;CONNECT;ConnectionID;Nebenstelle;Nummer;
                                Ende der Verbindung: datum;DISCONNECT;ConnectionID;dauerInSekunden;
                        
                                :param line: data line which is parsed
                                """
                                self.logger.debug(line)
                                line = line.split(";")
                        
                                if line[1] == "RING":
                                    call_from = line[3]
                                    call_to = line[4]
                                    self._trigger(call_from, call_to, line[0], line[2], line[1], '')
                                elif line[1] == "CALL":
                                    call_from = line[4]
                                    call_to = line[5]
                                    self._trigger(call_from, call_to, line[0], line[2], line[1], line[3])
                                elif line[1] == "CONNECT":
                                    self._trigger('', '', line[0], line[2], line[1], line[3])
                                elif line[1] == "DISCONNECT":
                                    self._trigger('', '', '', line[2], line[1], '')
                        
                            def _trigger(self, call_from, call_to, time, callid, event, branch):
                                """
                                Triggers the event: sets item values and looks up numbers in the phone book.
                                """
                                self.logger.debug("Event: %s, Call From: %s, Call To: %s, Time: %s, CallID: %s" %(event, call_from, call_to, time, callid))
                                # in each case set current call event and direction
                                for item in self._items:
                                    if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') == 'call_event':
                                        item(event.lower())
                                    if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') == 'call_direction':
                                        if event == 'RING':
                                            item("incoming")
                                        else:
                                            item("outgoing")
                        
                                # call is incoming
                                if event == 'RING':
                                    # process "trigger items"
                                    for trigger_item in self._trigger_items:
                                        if self._plugin_instance.get_iattr_value(trigger_item.conf, 'avm_data_type') == 'monitor_trigger':
                                            trigger_item(0)
                                            # self.logger.debug(self._plugin_instance.get_iattr_value(trigger_item.conf, 'avm_data_type') + " " +trigger_item.conf['avm_incoming_allowed']+" "+trigger_item.conf['avm_target_number'])
                                            if 'avm_incoming_allowed' not in trigger_item.conf or 'avm_target_number' not in trigger_item.conf:
                                                self.logger.error(
                                                    "both 'avm_incoming_allowed' and 'avm_target_number' must be specified as attributes in a trigger item.")
                                            elif trigger_item.conf['avm_incoming_allowed'] == call_from and trigger_item.conf[
                                                'avm_target_number'] == call_to:
                                                trigger_item(1)
                        
                                    if self._call_monitor_incoming_filter in call_to:
                                        # set call id for incoming call
                                        self._call_incoming_cid = callid
                        
                                        # reset duration for incoming calls
                                        self._duration_item['call_duration_incoming'](0)
                        
                                        # process items specific to incoming calls
                                        for item in self._items_incoming:  # update items for incoming calls
                                            if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['is_call_incoming']:
                                                self.logger.debug("Setting is_call_incoming: %s" % True)
                                                item(True)
                                            elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['last_caller_incoming']:
                                                if call_from != '' and call_from is not None:
                                                    name = self._callback(call_from)
                                                    if name != '' and not name is None:
                                                        item(name)
                                                    else:
                                                        item(call_from)
                                                else:
                                                    item("Unbekannt")
                                            elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in [
                                                'last_call_date_incoming']:
                                                self.logger.debug("Setting last_call_date_incoming: %s" % time)
                                                item(time)
                                            elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['call_event_incoming']:
                                                self.logger.debug("Setting call_event_incoming: %s" % event.lower())
                                                item(event.lower())
                                            elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['last_number_incoming']:
                                                self.logger.debug("Setting last_number_incoming: %s" % call_from)
                                                item(call_from)
                                            elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in [
                                                'last_called_number_incoming']:
                                                self.logger.debug("Setting last_called_number_incoming: %s" % call_to)
                                                item(call_to)
                        
                                # call is outgoing
                                elif event == 'CALL':
                                    # set call id for outgoing call
                                    self._call_outgoing_cid = callid
                        
                                    # reset duration for outgoing calls
                                    self._duration_item['call_duration_outgoing'](0)
                        
                                    # process items specific to outgoing calls
                                    for item in self._items_outgoing:
                                        if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['is_call_outgoing']:
                                            item(True)
                                        elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['last_caller_outgoing']:
                                            name = self._callback(call_to)
                                            if name != '' and not name is None:
                                                item(name)
                                            else:
                                                item(call_to)
                                        elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['last_call_date_outgoing']:
                                            item(time)
                                        elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['call_event_outgoing']:
                                            item(event.lower())
                                        elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['last_number_outgoing']:
                                            item(call_from)
                                        elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in [
                                            'last_called_number_outgoing']:
                                            item(call_to)
                        
                                # connection established
                                elif event == 'CONNECT':
                                    # handle OUTGOING calls
                                    if callid == self._call_outgoing_cid:
                                        if not self._duration_item[
                                            'call_duration_outgoing'] is None:  # start counter thread only if duration item set and call is outgoing
                                            self._stop_counter('outgoing')  # stop potential running counter for parallel (older) outgoing call
                                            self._start_counter(time, 'outgoing')
                                        for item in self._items_outgoing:
                                            if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['call_event_outgoing']:
                                                item(event.lower())
                        
                                    # handle INCOMING calls
                                    elif callid == self._call_incoming_cid:
                                        if not self._duration_item[
                                            'call_duration_incoming'] is None:  # start counter thread only if duration item set and call is incoming
                                            self._stop_counter('incoming')  # stop potential running counter for parallel (older) incoming call
                                            self.logger.debug("Starting Counter for Call Time")
                                            self._start_counter(time, 'incoming')
                                        for item in self._items_incoming:
                                            if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') in ['call_event_incoming']:
                                                self.logger.debug("Setting call_event_incoming: %s" % event.lower())
                                                item(event.lower())
                        
                                # connection ended
                                elif event == 'DISCONNECT':
                                    # handle OUTGOING calls
                                    if callid == self._call_outgoing_cid:
                                        for item in self._items_outgoing:
                                            if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') == 'call_event_outgoing':
                                                item(event.lower())
                                            elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') == 'is_call_outgoing':
                                                item(False)
                                        if not self._duration_item['call_duration_outgoing'] is None:  # stop counter threads
                                            self._stop_counter('outgoing')
                                        self._call_outgoing_cid = None
                        
                                    # handle INCOMING calls
                                    elif callid == self._call_incoming_cid:
                                        for item in self._items_incoming:
                                            if self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') == 'call_event_incoming':
                                                self.logger.debug("Setting call_event_incoming: %s" % event.lower())
                                                item(event.lower())
                                            elif self._plugin_instance.get_iattr_value(item.conf, 'avm_data_type') == 'is_call_incoming':
                                                self.logger.debug("Setting is_call_incoming: %s" % False)
                                                item(False)
                                        if not self._duration_item['call_duration_incoming'] is None:  # stop counter threads
                                            self.logger.debug("Stopping Counter for Call Time")
                                            self._stop_counter('incoming')
                                        self._call_incoming_cid = None
                        Zuletzt geändert von psilo; 04.02.2018, 08:16.

                        Kommentar


                          Und hier mein Demo-Log nach frischem SHNG Start. Bei mir wird alles richtig gesetzt - zum Test idealerweise per logging.yaml ein eigenes File für das AVM Plugin definieren..:

                          Code:
                          2018-02-04  07:43:59 INFO     plugins.avm      __init__         Init AVM Plugin
                          2018-02-04  07:43:59 DEBUG    plugins.avm      __init__         starting monitoring service
                          2018-02-04  07:44:00 INFO     plugins.avm      __init__         Init AVM Plugin
                          2018-02-04  07:44:00 INFO     plugins.avm      __init__         Init AVM Plugin
                          
                          2018-02-04  07:44:30 DEBUG    plugins.avm      _parse_line      04.02.18 07:44:30;RING;0;0160xxxxxx82;xxxxx61;SIP0;
                          2018-02-04  07:44:30 DEBUG    plugins.avm      _trigger         Event: RING, Call From: 0160xxxxxx82, Call To: xxxxx61, Time: 04.02.18 07:44:30, CallID: 0
                          2018-02-04  07:44:30 DEBUG    plugins.avm      _trigger         Setting is_call_incoming: True
                          2018-02-04  07:44:31 DEBUG    plugins.avm      _trigger         Setting last_number_incoming: 0160xxxxxx82
                          2018-02-04  07:44:31 DEBUG    plugins.avm      _trigger         Setting last_called_number_incoming: xxxxx61
                          2018-02-04  07:44:31 DEBUG    plugins.avm      _trigger         Setting last_call_date_incoming: 04.02.18 07:44:30
                          2018-02-04  07:44:31 DEBUG    plugins.avm      _trigger         Setting call_event_incoming: ring
                          
                          2018-02-04  07:44:32 DEBUG    plugins.avm      _parse_line      04.02.18 07:44:32;DISCONNECT;0;0;
                          2018-02-04  07:44:32 DEBUG    plugins.avm      _trigger         Event: DISCONNECT, Call From: , Call To: , Time: , CallID: 0
                          2018-02-04  07:44:32 DEBUG    plugins.avm      _trigger         Setting is_call_incoming: False
                          2018-02-04  07:44:32 DEBUG    plugins.avm      _trigger         Setting call_event_incoming: disconnect
                          2018-02-04  07:44:32 DEBUG    plugins.avm      _trigger         Stopping Counter for Call Time
                          
                          2018-02-04  07:44:43 DEBUG    plugins.avm      _parse_line      04.02.18 07:44:43;RING;0;0160xxxxxx82;xxxxx62;SIP1;
                          2018-02-04  07:44:43 DEBUG    plugins.avm      _trigger         Event: RING, Call From: 0160xxxxxx82, Call To: xxxxx62, Time: 04.02.18 07:44:43, CallID: 0
                          2018-02-04  07:44:43 DEBUG    plugins.avm      _trigger         Setting is_call_incoming: True
                          2018-02-04  07:44:43 DEBUG    plugins.avm      _trigger         Setting last_number_incoming: 0160xxxxxx82
                          2018-02-04  07:44:43 DEBUG    plugins.avm      _trigger         Setting last_called_number_incoming: xxxxx62
                          2018-02-04  07:44:43 DEBUG    plugins.avm      _trigger         Setting last_call_date_incoming: 04.02.18 07:44:43
                          2018-02-04  07:44:43 DEBUG    plugins.avm      _trigger         Setting call_event_incoming: ring
                          
                          2018-02-04  07:44:45 DEBUG    plugins.avm      _parse_line      04.02.18 07:44:45;DISCONNECT;0;0;
                          2018-02-04  07:44:45 DEBUG    plugins.avm      _trigger         Event: DISCONNECT, Call From: , Call To: , Time: , CallID: 0
                          2018-02-04  07:44:45 DEBUG    plugins.avm      _trigger         Setting is_call_incoming: False
                          2018-02-04  07:44:45 DEBUG    plugins.avm      _trigger         Setting call_event_incoming: disconnect
                          2018-02-04  07:44:45 DEBUG    plugins.avm      _trigger         Stopping Counter for Call Time
                          Ich empfehle, das obere neue Logging des MonitoringServices zu verwenden, da die Logik oft zu lange braucht, um wirklich die Daten aus dem RING Event auszugeben. Oft ist bereits der Wert des CONNECT oder DISCONNECT Events im Item (False), wenn die Logik ausgibt... Daher auch mein Symptom weiter oben, dass beim Anrufbeantworter-Anrufen in False via Logik ausgegeben wurde.

                          PS: ich teste lokal bei mir derzeit auch noch ein mögliches Reconnect Handling, etwa wenn die Fritzbox durchstartet und damit die Connection auf das Telnet-Interface weg ist.
                          Zuletzt geändert von psilo; 04.02.2018, 08:15.

                          Kommentar


                            Ich stehe gerade auf dem Schlauch und bitte um Hilfe!

                            IMG 1.2.1 für Raspi
                            smarthome = SmartHomeNG 1.4.2.master (0dff0244)
                            smartVisu2.9

                            Die Grundfunktionen liefen auf Anhieb! Danach habe ich einige Zeit gesucht, bis ich den Pfad
                            "with open('/var/www/html/smartVISU2.9/temp/calllist.csv', 'w') as csvfile" :in der calllist_csv_logic.py entdeckt habe. Evtl. in der Doku ein Hinweis!

                            Jetzt scheitere ich an dem Aufruf zur Calllist. Alles wie im Beispiel: Items in avm7490 (Kopie aus Readme), Plugin = avm

                            2018-02-08 16:10:18 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.newest.direction = incoming via Logic None None
                            2018-02-08 16:10:18 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.newest.event = ring via Logic None None
                            2018-02-08 16:10:18 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.incoming.is_call_incoming = True via Logic None None
                            2018-02-08 16:10:18 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.incoming.last_caller = 0171485xxx via Logic None None
                            2018-02-08 16:10:18 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.incoming.last_call_date = 08.02.18 16:10:18 via Logic None None
                            2018-02-08 16:10:18 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.incoming.event = ring via Logic None None
                            2018-02-08 16:10:20 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.newest.direction = outgoing via Logic None None
                            2018-02-08 16:10:20 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.newest.event = disconnect via Logic None None
                            2018-02-08 16:10:20 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.incoming.is_call_incoming = False via Logic None None
                            2018-02-08 16:10:20 INFO MonitoringService_avm_fritzbox_7490 Item avm.monitor.incoming.event = disconnect via Logic None None
                            2018-02-08 16:10:20 ERROR logics.CallListCSVLogic Logic: logics.CallListCSVLogic, File: /usr/local/smarthome/logics/calllist_csv_logic.py, Line: 9, Method: <module>, Exception: 'Item' object has no attribute 'get_calllist'
                            Traceback (most recent call last):
                            File "/usr/local/smarthome/lib/scheduler.py", line 425, in _task
                            exec(obj.bytecode)
                            File "/usr/local/smarthome/logics/calllist_csv_logic.py", line 9, in <module>

                            calllist = sh.avm.monitor.get_calllist() Hier alles denkbare (?) ausgeführt
                            calllist = sh.fritzbox_7490.get_calllist()
                            calllist = sh.avm.get_calllist()

                            AttributeError: 'Item' object has no attribute 'get_calllist'
                            #calllist_csv_logic.py

                            import csv
                            if sh.avm.monitor.newest.event() == 'disconnect':
                            with open('/var/www/html/smartVISU2.9/temp/calllist.csv', 'w') as csvfile:
                            fieldnames = ['Device', 'Duration', 'Port', 'CalledNumber', 'Name', 'Date', 'Numbertype', 'Caller', 'Type', 'Id', 'Called']
                            writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
                            writer.writeheader()
                            calllist = sh.fritzbox_7490.get_calllist()
                            if not calllist is None:
                            if len(calllist) > 0:
                            if not calllist[0] is None:
                            for element in calllist:
                            writer.writerow(element)
                            Danke für jeden Hinweis!

                            Wolfgang

                            Kommentar


                              Du musst die Methode auf dem Plugin ausführen. Möglicherweise hast du das genauso wie Deine Items genannt? Wie sieht die plugin.yaml aus?

                              sh.<pluginbezeichner>.get_calllist()

                              Item' object has no attribute 'get_calllist' heisst auf jdn Fall, dass Du sie auf einem Item ausführen willst, was logischerweise nicht geht.
                              Zuletzt geändert von psilo; 08.02.2018, 18:09.

                              Kommentar


                                Danke für die schnelle Antwort.

                                Leider habe ich weiterhin Probleme. Meine ITEMS entsprechen dem Readme


                                Plugin.yaml
                                fb1:
                                class_name: AVM
                                class_path: plugins.avm
                                username: 'admin' # optional
                                password: 'xxxx7490'
                                host: 192.168.xxx.1
                                port: 49443 # bei ssl
                                # port: 48704 # ohne ssl
                                cycle: 300
                                ssl: True # use https or not True / False
                                verify: False # verify ssl certificate
                                call_monitor: 'True'
                                # call_monitor_incoming_filter: "... ## optional, don't set if you don't want to watch only one specific number with your call monitor"
                                instance: fritzbox_7490


                                Items aus Readme kopiert! Darf hier kein avm: stehen?

                                avm: Items aus Readme kopiert! Darf hier kein avm: stehen?

                                uptime_7490:
                                type: num
                                visu_acl: ro
                                avm_data_type@fritzbox_7490: uptime

                                uptime_1750:
                                type: num
                                visu_acl: ro
                                avm_data_type@wlan_repeater_1750: uptime

                                2018-02-08 19:47:18 ERROR logics.CallListCSVLogic Logic: logics.CallListCSVLogic, File: /usr/local/smarthome/logics/calllist_csv_logic.py, Line: 9, Method: &lt;module&gt;, Exception: 'SmartHome' object has no attribute 'fritzbox_7490'
                                Traceback (most recent call last):
                                File "/usr/local/smarthome/lib/scheduler.py", line 425, in _task
                                exec(obj.bytecode)
                                File "/usr/local/smarthome/logics/calllist_csv_logic.py", line 9, in &lt;module&gt;
                                calllist = sh.avm.get_calllist()
                                AttributeError: 'SmartHome' object has no attribute 'fritzbox_7490'

                                ebenso mit calllist = sh.fb1.get_calllist()

                                Danke!
                                Zuletzt geändert von schloessl; 08.02.2018, 22:01.

                                Kommentar

                                Lädt...
                                X