strip leading underscore from secop parameter names
+ other fixes and debugging prints
This commit is contained in:
14
secop.py
14
secop.py
@ -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':
|
||||
|
Reference in New Issue
Block a user