strip leading underscore from secop parameter names

+ other fixes and debugging prints
This commit is contained in:
l_samenv
2025-03-28 11:37:11 +01:00
parent 029309a06b
commit 335d0a5078
4 changed files with 37 additions and 23 deletions

View File

@ -54,7 +54,7 @@ class SecopStream(Stream):
self.device = self.device[:-7]
self.tags['device'] = self.device
self.modules = self.descr['modules']
self.convert = {}
self.param_info = {}
self.tags_dict = TagsDict(self.tags)
for mod, moddesc in self.modules.items():
for key in ('_original_id', 'original_id'):
@ -62,10 +62,12 @@ class SecopStream(Stream):
if value:
self.tags_dict[mod] = dict(self.tags, device=value)
break
for param, desc in moddesc['accessibles'].items():
parameters = moddesc['accessibles']
for param, desc in parameters.items():
dt = desc['datainfo']
if dt['type'] in ('double', 'int', 'enum'):
self.convert[mod, param] = float
stripped = param[1:] if param.startswith('_') else param
self.param_info[mod, param] = float, (mod, param if stripped in parameters else stripped)
self.send('activate')
def ping(self):
@ -81,9 +83,9 @@ class SecopStream(Stream):
if match:
cmd, ident, data = match.groups()
mod, _, param = ident.partition(':')
key = (mod, param or 'value')
cvt = self.convert.get(key)
if cvt:
cvt_key = self.param_info.get((mod, param or 'value'))
if cvt_key:
cvt, key = cvt_key
data = json.loads(data)
tags = self.tags_dict[key[0]]
if cmd == 'error_update':