Ankündigung

Einklappen
Keine Ankündigung bisher.

Neues Plugin: DatabaseAddOn - Erweitere Testphase

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

    Neues Plugin: DatabaseAddOn - Erweitere Testphase

    Hallo,

    nachdem mich die Auswertung von Daten aus der Datenbank schon länger beschäftigt, aber alle Lösungsansätze mit eval, logic, userfunction mich nie voll endlich zufrieden gestellt haben, gibt es nun dazu einen Plugin-Entwurf!

    Was macht das Plugin?
    Das Plugin bietet eine Funktionserweiterung zum Database Plugin und ermöglicht somit die einfache Auswertung von Messdaten. Basierend auf den Daten in der Datenbank können bspw. Auswertungen zu Verbrauch (heute, gestern, ...) oder Auswertungen zu Minimal- und Maximalwerten gefahren werden. Diese Auswertungen werden zyklisch zum Tageswechsel, Wochenwechsel, Monatswechsel oder Jahreswechsel erzeugt. Um die Zugriffe auf die Datenbank zu minimieren, werden diverse Daten zwischengespeichert.

    Anforderungen
    Es muss eine Instanz des Datenbank vorhanden sein. Getestet ist es bislang mit dem Database-Plugin mit MySQL und nur einer laufenden Instanz. SQLite funktioniert aktuell (noch) nicht weil dort andere SQL Abfragen zum Einsatz kommen.

    Konfiguration
    Die Items mit einem DatabaseAddon-Attribut müssen im gleichen Pfad sein, wie das Item, für das das Database Attribut konfiguriert ist. Bedeutet. Die Items mit dem DatabaseAddon-Attribute müssen im Kinder oder Kindeskinder oder Kindeskinderkinder des Items sein, für das das Database Attribut konfiguriert ist.
    Beispiel:

    Code:
    temperatur:
        type: bool
        database: yes
    
        auswertung:
            type: foo
    
            heute_min:
                type: num
                database_addon_fct: heute_min
    
            gestern_max:
                type: num
                database_addon_fct: heute_minus1_max
    Auswertefunktionen:
    Verfügbar sind aktuell 3 Auswertegruppen mit Verbrauch, Zählerstand und Wertehistorie min/max. Auch diverse structs für die einfache Anwendung sind verfügbar.

    Wie geht es weiter?
    Alles weitere findet ihr hier: https://github.com/sisamiwe/shng-db_addon-plugin
    Wie ihr das am besten verwenden könnt, ist hier beschrieben: https://knx-user-forum.de/forum/supp...-herunterladen

    Ich möchte hier zum erweiterten Test einladen. Onkelandy und ich haben das Plugin bereits seit einiger Zeit in Betrieb bzw. getestet.

    Wenn das Plugin weiter getestet wurde, stelle ich einen PR, um das Plugin in das Repo aufnehmen zu lassen.


    Beste Grüße
    Zuletzt geändert von bmx; 02.04.2022, 16:50.

    #2
    Hallo Michael,

    da Du hier daraufhin gewiesen hast...
    Zitat von Sisamiwe Beitrag anzeigen
    schaut mal hier
    Ich habe den Ordner von Github im "plugins" Ordner abgelegt --> Im WebIF unter "Plugin hinzufügen" --> wird das "shng-db_addon-plugin" bei den Systemplugins angezeigt. Lässt sich auch aktivieren --> allerdings startet SHNG anschließend nicht mehr. Durch auskommentieren der beiden Zeilen in der "plugin.yaml" -->

    Code:
    #shng-db_addon-plugin-develop:
    # plugin_name: shng-db_addon-plugin-develop

    funktioniert das System wieder...

    Plugin : database v1.5.17 mit Treiber sqlite3


    Kommentar


      #3
      Minuszeichen im Plugin Namen sind unzulässig. Da versucht Python von shng drei Werte (db_addon, plugin, develop) abzuziehen.

      Viele Grüße
      Martin

      There is no cloud. It's only someone else's computer.

      Kommentar


        #4
        Msinn Ich hatte auch mal den langen Ordnernamen im Verdacht.

        aber auch umbennen der Ordner und in der plugin.yaml in shngdev brachte keine Verbesserung.
        Code:
        shngdev:
                 plugin_name: shngdev
        Ich werde das voerst mal ruhen lassen...

        Kommentar


          #5
          Zitat von Maexle Msinn Beitrag anzeigen
          aber auch umbenennen der Ordner und in der plugin.yaml in shngdev brachte keine Verbesserung.
          So schwer ist das doch nicht!

          Hier wird es gut erklärt: https://knx-user-forum.de/forum/supp...-herunterladen

          Meine Konfig:

          Der Plugin liegt im Ordner: \\192.168.2.13\SmartHomeNG\plugins\_priv_db_addon
          meine Konfig in der plugin.yaml ist:
          Code:
          maria_db_addon:
              plugin_name: [MARKIEREN]_priv_db_addon[/MARKIEREN]
              startup_run_delay: '300'
              ignore_0_at_temp_items: true
          Wichtig ist, dass der plugin_name in der plugin.yaml mit dem Ordernamen, in dem das Plugin liegt, identisch ist.

          Michael

          Kommentar


            #6
            Zitat von Sisamiwe Beitrag anzeigen
            Wichtig ist, dass der plugin_name in der plugin.yaml mit dem Ordernamen, in dem das Plugin liegt, identisch ist.
            das hatte ich ja siehe "auch umbennen der Ordner und in der plugin.yaml in shngdev"
            1. Github als Zip downloaden
            2. shng-db_addon-plugin-develop.zip --> entpacken
            3. ergibt einen Ordner "shng-db_addon-plugin-develop" mit Inhalt Ordner "shng-db_addon-plugin-develop" dessen Inhalt Ordner "Webif" plugin.yaml readme usw. in den plugin Ordner von shng kopiert.
            4. den gelben Ordner habe ich in shngdev umbenannt und in der Plugin.yaml ebenfalls so genannt...

            auch habe ich versucht den roten Ordner im Plugin Ordner abzulegen ohne den "gelben Ordner"


            Code:
            \\SMARTHOMENG\SmartHomeNG\plugins\testaddon\shng-db_addon-plugin-develop\webif
            muss der Ordner testaddon weg oder nicht?
            Zuletzt geändert von Maexle; 22.03.2022, 14:36.

            Kommentar


              #7
              Hört sich super an. Werde am Wochenende mal testen. Vielen Dank schonmal für das Plugin!

              Kommentar


                #8
                Zitat von Maexle Beitrag anzeigen
                muss der Ordner testaddon weg oder nicht?
                Ja, testaddon muss weg UND es dürfen keine Bindestriche in Namen sein. Siehe Kommentare von Msinn

                Meine Konfig ist bspw:
                Screenshot 2022-03-25 091621.png


                Code:
                maria_db_addon:
                    plugin_name: _priv_db_addon
                    startup_run_delay: '300'
                    ignore_0_at_temp_items: true

                Der Ablauf ist:
                1. Github als Zip downloaden
                2. shng-db_addon-plugin-develop.zip --> entpacken
                3. ergibt einen Ordner "shng-db_addon-plugin-develop" mit Inhalt Ordner "shng-db_addon-plugin-develop"
                4. Erstellen des Ordners "_priv_db_addon" unter \SmartHomeNG\plugins
                5. Kopieren des Inhaltes des Ordners (alle Files und Verzeichnisse) aus "shng-db_addon-plugin-develop" in ""_priv_db_addon""
                6. Ergänzen der plugin.yaml aus dem Ordner etc mit dem obigen Code

                Versuche es nochmal.

                Kommentar


                  #9
                  Zitat von Sisamiwe Beitrag anzeigen
                  Versuche es nochmal.
                  Leider erfolglos...

                  Code:
                  uzsu:
                     plugin_name: uzsu
                  
                  maria_db_addon:
                      plugin_name: _priv_db_addon
                      startup_run_delay: '300'
                      ignore_0_at_temp_items: true

                  mir fehlt der Ordner __pycache__ bzw. dieser liegt "eine Ebene höher" (SHNG\plugins\__pycache___ ) kann es daran liegen?
                  addon.png

                  Kommentar


                    #10
                    Hallo,

                    pycache wird automatisch erzeugt.
                    Eine Fehlermeldung aus dem Log hab ich bisher aber auch nicht gesehen. Gibt es keine?

                    Deine Einstellung sieht soweit aber richtig aus.

                    Gruß,
                    Hendrik

                    Kommentar


                      #11
                      Hier der Auszug aus der Log-Datei.

                      Code:
                      2022-03-25 10:22:29 NOTICE lib.smarthome -------------------- SmartHomeNG initialization finished --------------------
                      2022-03-25 10:25:21 NOTICE lib.smarthome -------------------- SmartHomeNG stopped --------------------
                      2022-03-25 10:25:21 ERROR asyncio Task was destroyed but it is pending!
                      task: <Task pending name='update_all_series' coro=<Websocket.update_all_series() running at /usr/local/smarthome/modules/websocket/__init__.py:741> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x63247808>()]>>
                      2022-03-25 10:25:21 ERROR asyncio Task was destroyed but it is pending!
                      task: <Task pending name='update_visu' coro=<Websocket.update_visu() running at /usr/local/smarthome/modules/websocket/__init__.py:842> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x62f2ef28>()]>>
                      2022-03-25 10:27:56 NOTICE lib.smarthome -------------------- Init SmartHomeNG v1.9.1-master (8133e714) --------------------
                      2022-03-25 10:27:56 NOTICE lib.smarthome Running in Python interpreter 'v3.9.2 final', from directory /usr/local/smarthome
                      2022-03-25 10:27:56 NOTICE lib.smarthome - on Linux-5.10.92-v7+-armv7l-with-glibc2.31 (pid=1542)
                      2022-03-25 10:27:58 NOTICE lib.smarthome - Nutze Feiertage für Land 'DE', Provinz 'BY', 1 benutzerdefinierte(r) Feiertag(e) definiert
                      2022-03-25 10:28:11 WARNING lib.item.item Item garage.tor.wechsel: _cast_duration (3/10) problem: invalid literal for int() with base 10: '3/10'
                      2022-03-25 10:28:11 WARNING lib.item.item Item garage.tor.oeffnen: _cast_duration (1.5) problem: invalid literal for int() with base 10: '1.5'
                      2022-03-25 10:28:12 WARNING plugins.openweathermap home@: owm.home.uvi The UVI API is deprecated - if you intend to query the current UV-index, use 'current/uvi' instead
                      2022-03-25 10:28:12 WARNING plugins.openweathermap home@: owm.home.uvi_date The UVI API is deprecated - if you intend to query the current UV-index, use 'current/uvi' instead
                      2022-03-25 10:28:12 WARNING plugins.knx Ignoring dg.dach.wind.alarm: please add knx_dpt.
                      2022-03-25 10:28:12 NOTICE lib.smarthome -------------------- SmartHomeNG initialization finished --------------------


                      Ich habe den Tab offen gelassen --> aktualisieren --> "FILE NOT FOUND!"


                      Wenn ich das "maria_db" aktiviere komme ich gar nicht an den Punkt um das Log anzusehen.
                      Zuletzt geändert von Maexle; 25.03.2022, 10:46.

                      Kommentar


                        #12
                        sudo systemctl status smarthome.service
                        --->
                        Code:
                        ● smarthome.service - SmartHomeNG daemon
                        Loaded: loaded (/lib/systemd/system/smarthome.service; enabled; vendor preset: enabled)
                        Active: active (running) since Fri 2022-03-25 10:46:13 CET; 1s ago
                        Process: 2458 ExecStart=/usr/bin/python /usr/local/smarthome/bin/smarthome.py (code=exited, status=0/SUCCESS)
                        Main PID: 2468 (python)
                        IO: 0B read, 0B written
                        Tasks: 1 (limit: 1597)
                        Memory: 19.1M
                        CPU: 5.505s
                        CGroup: /system.slice/smarthome.service
                        └─2468 /usr/bin/python /usr/local/smarthome/bin/smarthome.py
                        
                        Mär 25 10:46:10 SmartHomeNG systemd[1]: Starting SmartHomeNG daemon...
                        Mär 25 10:46:13 SmartHomeNG python[2467]: Daemon PID 2468
                        Mär 25 10:46:13 SmartHomeNG systemd[1]: smarthome.service: Supervising process 2468 which is not our child. We'll most likely not noti>
                        Mär 25 10:46:13 SmartHomeNG systemd[1]: Started SmartHomeNG daemon.

                        Nun hat sich doch mal etwas getan --> allerdings sehe ich da keinen Zusammenhang...

                        Code:
                        2022-03-25 10:48:48 CRITICAL lib.smarthome Python package requirements for configured plugins are not met and unable to install those requirements
                        2022-03-25 10:48:48 CRITICAL lib.smarthome Do you have multiple Python3 Versions installed? Maybe PIP3 looks into a wrong Python environment. Try to configure pip_command in etc/smarthome.yaml
                        2022-03-25 10:48:48 CRITICAL lib.smarthome Aborting
                        2022-03-25 10:48:52 NOTICE lib.smarthome -------------------- Init SmartHomeNG v1.9.1-master (8133e714) --------------------
                        2022-03-25 10:48:52 NOTICE lib.smarthome Running in Python interpreter 'v3.9.2 final', from directory /usr/local/smarthome
                        2022-03-25 10:48:52 NOTICE lib.smarthome - on Linux-5.10.92-v7+-armv7l-with-glibc2.31 (pid=2782)
                        2022-03-25 10:48:56 ERROR lib.shpypi test_requirements: 'sqlvalidator' not installed, any version needed
                        2022-03-25 10:48:56 WARNING lib.shpypi Installing plugin requirements for the current user, please wait...
                        2022-03-25 10:48:56 WARNING lib.shpypi > using PIP command: '/usr/bin/pip3'
                        2022-03-25 10:48:56 ERROR lib.shpypi /bin/sh: 1: /usr/bin/pip3: not found
                        
                        2022-03-25 10:48:56 CRITICAL lib.smarthome Python package requirements for configured plugins are not met and unable to install those requirements
                        2022-03-25 10:48:56 CRITICAL lib.smarthome Do you have multiple Python3 Versions installed? Maybe PIP3 looks into a wrong Python environment. Try to configure pip_command in etc/smarthome.yaml
                        2022-03-25 10:48:56 CRITICAL lib.smarthome Aborting
                        2022-03-25 10:48:59 NOTICE lib.smarthome -------------------- Init SmartHomeNG v1.9.1-master (8133e714) --------------------
                        2022-03-25 10:48:59 NOTICE lib.smarthome Running in Python interpreter 'v3.9.2 final', from directory /usr/local/smarthome
                        2022-03-25 10:48:59 NOTICE lib.smarthome - on Linux-5.10.92-v7+-armv7l-with-glibc2.31 (pid=2809)
                        2022-03-25 10:49:02 NOTICE lib.smarthome - Nutze Feiertage für Land 'DE', Provinz 'BY', 1 benutzerdefinierte(r) Feiertag(e) definiert
                        2022-03-25 10:49:05 ERROR lib.smarthome Unhandled exception: 'NoneType' object has no attribute 'stop'
                        <class 'AttributeError'>
                        File "/usr/local/smarthome/bin/smarthome.py", line 288, in <module>
                        sh.start()
                        File "/usr/local/smarthome/lib/smarthome.py", line 588, in start
                        self.modules.start()
                        File "/usr/local/smarthome/lib/module.py", line 362, in start
                        self.m.start()
                        File "/usr/local/smarthome/modules/admin/__init__.py", line 206, in start
                        self.mod_http.register_webif(WebInterface(self.web if_dir, self, self.shng_url_root, self.url_root),
                        File "/usr/local/smarthome/modules/admin/__init__.py", line 337, in __init__
                        SystemData.__init__(self)
                        File "/usr/local/smarthome/modules/admin/systemdata.py", line 60, in __init__
                        self.read_cpuinfo()
                        File "/usr/local/smarthome/modules/admin/systemdata.py", line 108, in read_cpuinfo
                        import lib.cpuinfo
                        File "/usr/local/smarthome/lib/cpuinfo.py", line 2421, in <module>
                        _check_arch()
                        File "/usr/local/smarthome/lib/cpuinfo.py", line 231, in _check_arch
                        arch, bits = _parse_arch(DataSource.arch_string_raw)
                        File "/usr/local/smarthome/lib/cpuinfo.py", line 624, in _parse_arch
                        elif re.match('^x64$|^x86_64$|^x86_64t$|^i686-64$|^amd64$|^ia64$|^ia-64$', arch_string_raw):
                        File "/usr/lib/python3.9/re.py", line 191, in match
                        return _compile(pattern, flags).match(string)
                        File "/usr/lib/python3.9/re.py", line 304, in _compile
                        p = sre_compile.compile(pattern, flags)
                        File "/usr/lib/python3.9/sre_compile.py", line 768, in compile
                        code = _code(p, flags)
                        File "/usr/lib/python3.9/sre_compile.py", line 607, in _code
                        _compile(code, p.data, flags)
                        File "/usr/lib/python3.9/sre_compile.py", line 209, in _compile
                        _compile(code, av, flags)
                        File "/usr/lib/python3.9/sre_compile.py", line 90, in _compile
                        for op, av in pattern:
                        File "/usr/lib/python3.9/sre_parse.py", line 165, in __getitem__
                        if isinstance(index, slice):
                        File "/usr/local/smarthome/lib/smarthome.py", line 677, in stop
                        self.items.stop()
                        
                        2022-03-25 10:51:38 NOTICE lib.smarthome -------------------- Init SmartHomeNG v1.9.1-master (8133e714) --------------------
                        2022-03-25 10:51:38 NOTICE lib.smarthome Running in Python interpreter 'v3.9.2 final', from directory /usr/local/smarthome
                        2022-03-25 10:51:38 NOTICE lib.smarthome - on Linux-5.10.92-v7+-armv7l-with-glibc2.31 (pid=2858)
                        2022-03-25 10:51:40 NOTICE lib.smarthome - Nutze Feiertage für Land 'DE', Provinz 'BY', 1 benutzerdefinierte(r) Feiertag(e) definiert
                        2022-03-25 10:51:53 WARNING lib.item.item Item garage.tor.wechsel: _cast_duration (3/10) problem: invalid literal for int() with base 10: '3/10'
                        2022-03-25 10:51:53 WARNING lib.item.item Item garage.tor.oeffnen: _cast_duration (1.5) problem: invalid literal for int() with base 10: '1.5'
                        2022-03-25 10:51:54 WARNING plugins.openweathermap home@: owm.home.uvi The UVI API is deprecated - if you intend to query the current UV-index, use 'current/uvi' instead
                        2022-03-25 10:51:54 WARNING plugins.openweathermap home@: owm.home.uvi_date The UVI API is deprecated - if you intend to query the current UV-index, use 'current/uvi' instead
                        2022-03-25 10:51:54 WARNING plugins.knx Ignoring dg.dach.wind.alarm: please add knx_dpt.
                        2022-03-25 10:51:54 NOTICE lib.smarthome -------------------- SmartHomeNG initialization finished --------------------
                        Zuletzt geändert von Maexle; 25.03.2022, 10:58.

                        Kommentar


                          #13
                          Maexle

                          Das db_addon Plugin hat 2 bzw. 3 requirements zu "externen" Python Libs u.a. sqlvalidator. Diese müssen nachinstalliert werden. shNG macht das automatisch.

                          Im Log steht das auch
                          Code:
                          2022-03-25 10:48:56 ERROR lib.shpypi test_requirements: 'sqlvalidator' not installed, any version needed
                          2022-03-25 10:48:56 WARNING lib.shpypi Installing plugin requirements for the current user, please wait...
                          2022-03-25 10:48:56 WARNING lib.shpypi > using PIP command: '/usr/bin/pip3'
                          2022-03-25 10:48:56 ERROR lib.shpypi /bin/sh: 1: /usr/bin/pip3: not found
                          2022-03-25 10:48:56 CRITICAL lib.smarthome Python package requirements for configured plugins are not met and unable to install those requirements
                          2022-03-25 10:48:56 CRITICAL lib.smarthome Do you have multiple Python3 Versions installed? Maybe PIP3 looks into a wrong Python environment. Try to configure pip_command in etc/smarthome.yaml
                          2022-03-25 10:48:56 CRITICAL lib.smarthome Aborting
                          shNG versucht die fehlenden PythonLibs nachzuinstallieren. Dort tritt eine Problem auf, dass der PIP nicht findet.

                          Die für das Plugin notwendigen Python Libs sind jeweils in der Datei "requirements.txt" enthalten.
                          Im WebIF kannst Du unter System\SystemPropoerties\PyPI Check nachschauen, ob die Libs geladen wurden.

                          Kommentar


                            #14
                            Logs sind schon besser als "geht nicht"

                            Kommentar


                              #15
                              Zitat von Sisamiwe Beitrag anzeigen
                              Im WebIF kannst Du unter System\SystemPropoerties\PyPI Check nachschauen, ob die Libs geladen wurden.
                              wenn ich das plugin "addon" aktiviere --> geht "Dienste" nicht über das ? hinaus und der PyPiCheck schreibt nur "Loading"

                              Kommentar

                              Lädt...
                              X