Ankündigung

Einklappen
Keine Ankündigung bisher.

Plugin-Entwickung: Fehler module 'plugins.viessmann' has no attribute 'viessmann'

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

    Plugin-Entwickung: Fehler module 'plugins.viessmann' has no attribute 'viessmann'

    Hallo,

    ich versuche mich an meinem ersten Plugin für shNG.
    Entwicklungsumgebung ist der aktuelle Master
    Aktuell bekomme ich beim initialisieren des Plugins folgenden Fehler
    Code:
    2019-12-19  12:04:06 WARNING  __main__            --------------------   Init SmartHomeNG 1.6.master (1dcb4fb5)   --------------------
    2019-12-19  12:04:06 WARNING  __main__            Running in Python interpreter 'v3.7.3 final' (pid=19431) on linux platform
    2019-12-19  12:04:09 WARNING  plugins.cli         CLI: You should set a password for this plugin.
    2019-12-19  12:04:10 ERROR    lib.plugin          Plugin 'viessmann' exception during execution of plugin: module 'plugins.viessmann' has no attribute 'viessmann'
    Traceback (most recent call last):
      File "/usr/local/smarthome/lib/plugin.py", line 553, in __init__
        exec("self.plugin = {0}.{1}.__new__({0}.{1})".format(classpath, classname))
      File "<string>", line 1, in <module>
    AttributeError: module 'plugins.viessmann' has no attribute 'viessmann'
    2019-12-19  12:04:10 ERROR    lib.plugin          Plugin 'viessmann' from section 'viessmann' exception: 'PluginWrapper' object has no attribute 'plugin'
    Traceback (most recent call last):
      File "/usr/local/smarthome/lib/plugin.py", line 145, in __init__
        plugin_thread = PluginWrapper(smarthome, plugin, classname, classpath, args, instance, self.meta, self._gtrans)
      File "/usr/local/smarthome/lib/plugin.py", line 571, in __init__
        if isinstance(self.get_implementation(), SmartPlugin):
      File "/usr/local/smarthome/lib/plugin.py", line 715, in get_implementation
        return self.plugin
    AttributeError: 'PluginWrapper' object has no attribute 'plugin'
    meine etc/plugin.yaml
    Code:
    viessmann:
        plugin_name: viessmann
        #class_name: viessmann
        #class_path: plugins.viessmann
        serialport: /dev/ttyUSB0
        cycle: 3000
        heating_type: V200KO1B
        protocol: P300
    das Plugin liegt im Ordner /plugins/viessmann/__init__.py
    Code:
    #!/usr/bin/env python
    #########################################################################
    # Copyright 2013 Stefan Kals
    #########################################################################
    #  Viessmann-Plugin for SmartHomeNG.  https://github.com/smarthomeNG//
    #
    #  This plugin is free software: you can redistribute it and/or modify
    #  it under the terms of the GNU General Public License as published by
    #  the Free Software Foundation, either version 3 of the License, or
    #  (at your option) any later version.
    #
    #  This plugin is distributed in the hope that it will be useful,
    #  but WITHOUT ANY WARRANTY; without even the implied warranty of
    #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    #  GNU General Public License for more details.
    #
    #  You should have received a copy of the GNU General Public License
    #  along with this plugin. If not, see <http://www.gnu.org/licenses/>.
    #########################################################################
    
    import logging
    import socket
    import time
    import serial
    import re
    import threading
    import binascii
    from . import commands
    
    from lib.module import Modules
    from lib.model.smartplugin import *
    
    logger = logging.getLogger(__name__)
    
    class Viessmann(SmartPlugin):
    
        ALLOW_MULTIINSTANCE = False
        PLUGIN_VERSION = '1.6.2'
    
        def __init__(self, smarthome, serialport='/dev/optolink', cycle=300, heating_type='V200KO1B', protocol='P300'):
        
            from bin.smarthome import VERSION
            if '.'.join(VERSION.split('.', 2)[:2]) <= '1.5':
                self.logger = logging.getLogger(__name__)
                
            self.logger.info('Initialisierung gestartet')
            # Grundwerte festlegen
            self.connected = False
            self._sh = smarthome
            self._params = {}
            self._init_cmds = []
            self._cyclic_cmds = {}
            self._lock = threading.Lock()
            self._host = host
            self._port = int(port)
            self._serialport = serialport
            self._connection_attempts = 0
            self._connection_errorlog = 60
            self._initread = False
            self._serial = False
            self._cycle = int(cycle)
            smarthome.connections.monitor(self)
            self._lastbyte = b''
            self._lastbytetime = time.time()
            # Untersetzung: Aktueller Zähler, 0=Init, 1=bei jedem Zyklus, 2=jeden 2. Zyklus, 3=jeden 3. Zyklus
            # Der Zähler ist nur bei Systemstart = 0
            # Anschließend zählt dieser immer von 1..maxreduction
            self._actreduction = 0
            # Untersetzung: Maximaler Wert, der über die Konfig projektiert wurde. Wird dynamisch ermittelt
            # Begrenzt auch den actreduction Zähler, dieser wird läuft immer von 1..maxreduction
            self._maxreduction = 0
            
            # Load controlset and commandset
            if protocol in commands.controlset and heating_type in commands.commandset:
                self._controlset = commands.controlset[protocol]
                self._commandset = commands.commandset[heating_type]
                self.log_info('Loaded commands for Heating type \'{}\''.format(heating_type))
            else:
                self.log_err('Commands for Heating type \'{}\' could not be found!'.format(heating_type))
                return None
    
            # Remember packet config
            self._packetstart = self.int2bytes(self._controlset['PacketStart'], 2)
            self._packetend = self.int2bytes(self._controlset['PacketEnd'], 2)
            self._acknowledge = self.int2bytes(self._controlset['Acknowledge'], 2)
            self._specialchar = self.int2bytes(self._controlset['SpecialCharacter'], 1)
            self._reponsecommandinc = self._controlset['ResponseCommandIncrement']
            self._commandlength = 2
            self._checksumlength = 1
    und die Metadaten /plugins/viessmann/plugin.yaml
    Code:
    # Metadata for the Smart-Plugin
    plugin:
        # Global plugin attributes
        type: protocol                  # plugin type (gateway, interface, protocol, system, web)
        description:
            de: 'Auslesen einer Viessmann Heizung'
            en: ''
        maintainer: tbd
        #keywords: viessmann optolink
        state: develop                 # change to ready when done with development
    
        version: 1.6.2                 # Plugin version
        sh_minversion: 1.4.2           # minimum shNG version to use this plugin
    #    sh_maxversion:                # maximum shNG version to use this plugin (leave empty if latest)
        multi_instance: False          # plugin supports multi instance
        restartable: unknown
        classname: viessmann           # class containing the plugin
    
    parameters:
    Was mache ich falsch?
    Danke für die Rückmeldung


    #2
    Als erstes fällt mir auf, dass Du in der etc/plugin.yaml Parameter angegeben hast, in den Metadaten (/plugins/viessmann/plugin.yaml) aber keine Parameter definiert hast.

    Als zweites fällt auf, dass Du in den Metadaten viessmann als classname angegeben hast und nicht Viessmann wie im Plugin Code.

    Ansonsten hilft ein vertiefender Blick in die Entwicklerdoku https://www.smarthomeng.de/dev/devel...t_plugins.html und auf das sample_plugin unter /dev.
    Zuletzt geändert von Msinn; 19.12.2019, 14:13.
    Viele Grüße
    Martin

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

    Kommentar


      #3
      Msinn
      Danke Dir!

      Zitat von Msinn Beitrag anzeigen
      Als erstes fällt mir auf, dass Du in der etc/plugin.yaml Parameter angegeben hast, in den Metadaten (/plugins/viessmann/plugin.yaml) aber keine Parameter definiert hast.
      Ich habe nur einen Teil der plugin.yaml gepostet. Die Paramater sind alle definiert

      Zitat von Msinn Beitrag anzeigen
      Als zweites fällt auf, dass Du in den Metadaten viessmann als classname angegeben hast und nicht Viessmann wie im Plugin Code.
      Das wars. Der classname aus den Metadaten muss mit der class in Plugin Code übeeinstimmen.

      Zitat von Msinn Beitrag anzeigen
      Ansonsten hilft ein vertiefender Blick in die Entwicklerdoku https://www.smarthomeng.de/dev/devel...t_plugins.html und auf das sample_plugin unter /dev.
      Das habe habe ich mir mehrfach durchgelesen. Habe aber den entscheidenden Hinweis wohl überlesen.

      Danke nochmal.

      Kommentar


        #4
        Der Hinweis steht schon drin. Was wohl nicht explizit drin steht, ist dass der classname Groß-/Kleinschreib sensitiv ist (ist halt Python Standard) war auch früher beim class_path in der /etc/plugin.yaml schon so.
        Viele Grüße
        Martin

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

        Kommentar

        Lädt...
        X