diff --git a/smartmeter/__init__.py b/smartmeter/__init__.py index 65fd18266..2376caa74 100755 --- a/smartmeter/__init__.py +++ b/smartmeter/__init__.py @@ -194,9 +194,12 @@ def create_items(self, data: dict = {}, file: str = '') -> bool: data = self.obis_results try: - id = data['1-0:96.1.0*255']['value'] - except (IndexError, AttributeError): - id = int(time.time()) + id = data['1-0:96.1.0*255'][0]['value'] + except (KeyError, IndexError, AttributeError): + try: + id = data['1-0:0.0.9*255'][0]['value'] + except (KeyError, IndexError, AttributeError): + id = int(time.time()) if not file: dir = self._sh._items_dir @@ -209,7 +212,9 @@ def create_items(self, data: dict = {}, file: str = '') -> bool: result = {} for nr, code in enumerate(data): item = f'item_{nr}' - d = data[code] + if len(data[code]) == 0: + continue + d = data[code][0] name = d.get('name', '') unit = d.get('unit') if isinstance(d['value'], str): diff --git a/smartmeter/plugin.yaml b/smartmeter/plugin.yaml index 8e9c46b88..bcd801c28 100644 --- a/smartmeter/plugin.yaml +++ b/smartmeter/plugin.yaml @@ -5,7 +5,7 @@ plugin: version: '0.0.1' # Plugin version sh_minversion: '1.10' # minimum shNG version to use this plugin py_minversion: '3.9' # minimum Python version to use for this plugin, due to f-strings - type: gateway # plugin type (gateway, interface, protocol, system, web) + type: interface # plugin type (gateway, interface, protocol, system, web) description: de: 'Unterstützung für Smartmeter, die DLMS (Device Language Message Specification, IEC 62056-21) oder SML (Smart Message Language) nutzen und OBIS Codes liefern' en: 'Support for smartmeter using DLMS (Device Language Message Specification, IEC 62056-21) or SML (Smart Message Language) and delivering OBIS codes'