Skip to content

Commit

Permalink
sml2 plugin: fix webinterface missing item column
Browse files Browse the repository at this point in the history
  • Loading branch information
bmxp committed Oct 14, 2023
1 parent 90f8db3 commit 6f7cae0
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 228 deletions.
11 changes: 7 additions & 4 deletions sml2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vim: set encoding=utf-8 tabstop=4 softtabstop=4 shiftwidth=4 expandtab
#########################################################################
# Copyright 2012-2014 Oliver Hinckel [email protected]
# Copyright 2018-2021 [email protected]
# Copyright 2018-2023 [email protected]
# Copyright 2022-2022 Julian Scholle [email protected]
#########################################################################
#
Expand Down Expand Up @@ -35,6 +35,7 @@
import traceback
from smllib import SmlStreamReader
from smllib import const as smlConst
from .const import FURTHER_OBIS_NAMES

from lib.module import Modules
from lib.item import Items
Expand Down Expand Up @@ -95,7 +96,7 @@ def connection_lost(self, exc):
self.smlx.logger.error("Connection so serial device was closed")
self.smlx.connected = False

PLUGIN_VERSION = '2.0.0'
PLUGIN_VERSION = '2.0.1'

def __init__(self, sh):
"""
Expand Down Expand Up @@ -135,6 +136,8 @@ def __init__(self, sh):
self.init_webinterface(WebInterface)
self.task = None
self.values = {}
self.obis_names = { **smlConst.OBIS_NAMES, **FURTHER_OBIS_NAMES }
self.obis_units = smlConst.UNITS

def run(self):
"""
Expand Down Expand Up @@ -339,8 +342,8 @@ def parse_data(self):
obis_code = sml_entry.obis.obis_code
if obis_code not in self.values:
self.values[obis_code] = dict()
self.values[obis_code]['name'] = smlConst.OBIS_NAMES.get(sml_entry.obis)
self.values[obis_code]['unit'] = smlConst.UNITS.get(sml_entry.unit)
self.values[obis_code]['name'] = self.obis_names.get(sml_entry.obis)
self.values[obis_code]['unit'] = self.obis_units.get(sml_entry.unit)
if obis_code in self._items:
if 'valueReal' in self._items[obis_code]:
for item in self._items[obis_code]['valueReal']:
Expand Down
15 changes: 15 additions & 0 deletions sml2/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python3

FURTHER_OBIS_NAMES = {
'010000020000': 'Firmware Version, Firmware Prüfsumme CRC, Datum',
'0100010800ff': 'Bezug Zählerstand Total',
'0100010801ff': 'Bezug Zählerstand Tarif 1',
'0100010802ff': 'Bezug Zählerstand Tarif 2',
'0100011100ff': 'Total-Zählerstand',
'0100020800ff': 'Einspeisung Zählerstand Total',
'0100020801ff': 'Einspeisung Zählerstand Tarif 1',
'0100020802ff': 'Einspeisung Zählerstand Tarif 2',
'0100600100ff': 'Server-ID',
'010060320101': 'Hersteller-Identifikation',
'0100605a0201': 'Prüfsumme',
}
2 changes: 1 addition & 1 deletion sml2/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugin:
documentation: https://www.smarthomeng.de/developer/plugins/smlx/user_doc.html
support: https://knx-user-forum.de/forum/supportforen/smarthome-py/39119-sml-plugin-datenblock-größenfehler
restartable: True
version: 2.0.0 # Plugin version
version: 2.0.1 # 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: True # plugin supports multi instance
Expand Down
5 changes: 1 addition & 4 deletions sml2/webif/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ def index(self, reload=None):
"""
tmpl = self.tplenv.get_template('index.html')
# Setting pagelength (max. number of table entries per page) for web interface
try:
pagelength = self.plugin.webif_pagelength
except Exception:
pagelength = 100
pagelength = self.plugin.get_parameter_value('webif_pagelength')
# add values to be passed to the Jinja2 template eg: tmpl.render(p=self.plugin, interface=interface, ...)
return tmpl.render(p=self.plugin,
webif_pagelength=pagelength,
Expand Down
Loading

0 comments on commit 6f7cae0

Please sign in to comment.