Ankündigung

Einklappen

Serverwartung 21.2.



Am 21.2. im Laufe des späten Abends wird eine Serverwartung durchgeführt. Das Forum ist dadurch für gut zwei Stunden nicht erreichbar.
Es wird eine Wartungsseite geschaltet.

Mehr anzeigen
Weniger anzeigen

V1.4 - Unhandled exception: 'str' object has no attribute 'get'

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

    V1.4 - Unhandled exception: 'str' object has no attribute 'get'

    Hallo zusammen,

    ich stelle gerade auf SmarthomeNG V1.4 um und bin am verzweifeln.
    Mein selbstgestricktes Plugin zur Rollo-Steuerung bekomme ich einfach nicht zum Laufen.
    Beim Starten bekomme ich immer diese Fehlermeldung:

    Code:
    2018-01-16  20:18:10 ERROR    Main         Unhandled exception: 'str' object has no attribute 'get'
    <class 'AttributeError'>
      File "/usr/local/smarthome/bin/smarthome.py", line 1055, in <module>
        sh.start()
      File "/usr/local/smarthome/bin/smarthome.py", line 435, in start
        self._plugins = lib.plugin.Plugins(self, configfile=self._plugin_conf_basename)
      File "/usr/local/smarthome/lib/plugin.py", line 98, in __init__
        plugin_name, self.meta = self._get_pluginname_and_metadata(plugin, _conf[plugin])
      File "/usr/local/smarthome/lib/plugin.py", line 141, in _get_pluginname_and_metadata
        plugin_name = plg_conf.get('plugin_name','').lower()
    Ich denke ich habe etwas grundlegendes vergessen, aber ich sehe gerade den Wald vor lauter Bäumen nicht.

    In der /etc/plugin.yaml steht
    Code:
    rollo:
        class_name = RRRollo
        class_path = plugins.rrrollo

    /plugins/rrrollo/plugin.yaml
    Code:
    # Metadata for the Smart-Plugin
    plugin:
        # Global plugin attributes
        type: system                      # plugin type (gateway, interface, protocol, system, web)
        description:
            de: 'Steuerung der Rollos'
            en: ''
        maintainer: rrauer
    #    tester: rrauer
    #    keywords: rrollo
    #   documentation:         # url of documentation (wiki) page
    #    support:
    
        version: 1.0.0                 # Plugin version
        sh_minversion: 1.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
        classname: RRRollo                 # class containing the plugin
    
    parameters:
        # Definition of parameters to be configured in etc/plugin.yaml
    
    item_attributes:
        # Definition of item attributes defined by this plugin

    /plugins/rrrollo/__init__.py
    Code:
    #!/usr/bin/env python3
    # vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab
    #########################################################################
    #  Copyright 2017 R.Rauer                                rainer@rrauer.de
    #########################################################################
    #  This file is part of SmartHomeNG.  
    #
    #  Sample plugin for new plugins to run with SmartHomeNG version 1.4 and
    #  upwards.
    #
    #  SmartHomeNG 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.
    #
    #  SmartHomeNG 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 SmartHomeNG. If not, see <http://www.gnu.org/licenses/>.
    #
    #########################################################################
    #
    # info
    # Das Plugin rr_rollo mit der Klasse RRRollo wird durch ein Item getriggert im dem der
    # Wert 'RRRollo_Trigger' steht.
    # Beim sh-Start werden alle Rollos im dict self.rollos gespeichert, welche die Werte
    # RolloAutoAuf, RolloAutoZu oder RolloAutoSonne enthalten.
    # sind die jeweiligen icons 'True', wird die Aktion ausgeführt.
    # In den icons muss ein Wert RolloAutoPause mit dem icon für die Automatikpause angegeben werden
    # dieser wird vor einer Aktualisierung auf 0 abgefragt
    #
    
    import logging
    import socket
    import threading
    import time
    from lib.model.smartplugin import SmartPlugin
    
    #import sys
    
    # debugging
    #import pydevd
    
    class RRRollo(SmartPlugin):
        PLUGIN_VERSION = "1.0.0"
        ALLOW_MULTIINSTANCE = False
        self.logger = logging.getLogger(__name__)
    #    pydevd.settrace('192.168.178.25', port=12000, stdoutToServer=True, stderrToServer=True)
    #    pydevd.settrace('192.168.178.66', port=12000, stdoutToServer=True, stderrToServer=True)
    
        def __init__(self):
            logger.info('Init rrrollo')
            #self._sh = smarthome
            self.rollos = {}
            self.trigger = []
    
        def run(self):
            self.logger.debug("Plugin '{}': run method called".format(self.get_fullname()))
            self.alive = True
            # if you want to create child threads, do not make them daemon = True!
            # They will not shutdown properly. (It's a python bug)
    
        def stop(self):
            self.logger.debug("Plugin '{}': stop method called".format(self.get_fullname()))
            self.alive = False
    
        def parse_item(self, item):
            #pydevd.settrace('192.168.178.25', port=12000, stdoutToServer=True, stderrToServer=True)
            if 'RolloAutoAuf' in item.conf:
                logger.debug("parse item: {0}".format(item))
                path = item._path
                #self.rollos[path]= {'item' : item, 'AutoZu' : True}
                self.rollos[item]= {'path' : path, 'AutoAuf' : True}
                #return self.update_item
            elif 'RolloAutoZu' in item.conf:
                logger.debug("parse item: {0}".format(item))
                path = item._path
                #self.rollos[path]= {'item' : item, 'AutoZu' : True}
                self.rollos[item]= {'path' : path, 'AutoAuf' : True}
                #return self.update_item
            elif 'RolloAutoSonne' in item.conf:
                logger.debug("parse item: {0}".format(item))
                path = item._path
                #self.rollos[path]= {'item' : item, 'AutoZu' : True}
                self.rollos[item]= {'path' : path, 'AutoAuf' : True}
                #return self.update_item
            elif 'RRRollo_Trigger' in item.conf:
                logger.debug("parse item: {0}".format(item))
                self.trigger = item
                return self.update_item
            else:
                return None
    
        def parse_logic(self, logic):
            if 'xxx' in logic.conf:
                # self.function(logic['name'])
                pass
    
        def update_item(self, item, caller=None, source=None, dest=None):
            #pydevd.settrace('192.168.178.25', port=12000, stdoutToServer=True, stderrToServer=True)
            if 'RRRollo_Trigger' in item.conf:
                logger.debug('RRRollo by: {0}{1}{2} '.format(caller, source, dest))
                try:
                    if item._value == 1:    # auf fahren
                        self.moved = []
                        self.move_up(item)
                        item(0, 'rrrollo')
                    elif item._value == 2:   # zu fahren
                        self.moved = []
                        self.move_down(item)
                        item(0, 'rrrollo')
                    elif item._value == 3:   # sonnenschutz
                        self.moved = []
                        self.move_sun(item)
                        item(0, 'rrrollo')
                    elif item._value == 4:   # sonnenschutz oder auf je nach Einstellung
                        self.moved = []
                        self.move_sun(item)
                        self.move_up(item)
                        item(0, 'rrrollo')
                except:
                    logger.warning('rrrollo: update item error {0}{1}'.format(item),format(item._value))
                    item(0, 'rrrollo')
    
            elif caller != 'plugin':
                logger.info("update item: {0}".format(item.id()))
    
    
        def move_up(self, item):
            self.move('RolloAutoAuf','RolloAutoPause', 'auf fahren')
            #item(0, 'rrrollo')
    
        def move_down(self, item):
            self.move('RolloAutoZu','RolloAutoPause', 'schließen')
            #item(0, 'rrrollo')
    
        def move_sun(self, item):
            self.move('RolloAutoSonne','RolloAutoPause', 'Sonnenschutz fahren')
            #item(0, 'rrrollo')
    
    
        def move(self, adressRollo, adressPause, text):
            for rollo in self.rollos:
                if adressRollo in rollo.conf:
                    autoPause = False
                    if adressPause in rollo.conf:
                        pauseItem = self._sh.return_item(rollo.conf[adressPause])
                        if pauseItem._value == 1:
                            autoPause = True
                    if rollo._value == True:
                        try:
                            moveItem = self._sh.return_item(rollo.conf[adressRollo])
                        except:
                            logger.warning('rrrollo: item not found {}'.format(rollo.conf[adressRollo]))
                            continue
                        try:
                            if autoPause == False:
                                if str(moveItem._Item__parent) in self.moved:
                                    logger.info('rrrollo; {} wiederholsperre'.format(str(moveItem._Item__parent)))
                                else:
                                    moveItem(rollo.conf['RolloAutoWert'], 'rrrollo')
                                    self.moved.append(str(moveItem._Item__parent))
                                    logger.info('rrrollo: {0} automatisch {1} '.format(str(moveItem._Item__parent), text))
                            else:
                                logger.info('rrrollo: {0} Automatik pausiert'.format(str(moveItem._Item__parent)))
                        except:
                            logger.warning('rrrollo: value not found {}'.format(rollo.conf[adressRollo]))
                            continue
    In meiner alten Smarthome läuft alles noch wunderbar, aber was mache ich falsch in der V1.4?
    Zuletzt geändert von ElektroRudi; 16.01.2018, 22:32.
    Gruß
    ElektroRudi

    ............kann,.muß aber net....

    #2
    in der etc/plugin.yaml vermischt du conf und yaml Syntax

    Kommentar


      #3


      Danke, das wars.
      Gruß
      ElektroRudi

      ............kann,.muß aber net....

      Kommentar

      Lädt...
      X