mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-03-12 04:59:09 +00:00
swap out implementation of {IRemote}.apply(). It now uses individual requests instead of script requests.
This commit is contained in:
parent
09259269d7
commit
f8b56b4a30
@ -48,26 +48,18 @@ class IRemote(abc.ABC):
|
|||||||
def apply(self, data):
|
def apply(self, data):
|
||||||
"""Sets all parameters of a dict for the channel."""
|
"""Sets all parameters of a dict for the channel."""
|
||||||
|
|
||||||
script = ''
|
|
||||||
|
|
||||||
def fget(attr, val):
|
def fget(attr, val):
|
||||||
if attr == 'mode':
|
if attr == 'mode':
|
||||||
return (f'mode.{val}', 1)
|
return (getattr(self, attr), val, 1)
|
||||||
elif attr == 'knob':
|
return (self, attr, val)
|
||||||
return ('', val)
|
|
||||||
return (attr, val)
|
|
||||||
|
|
||||||
for attr, val in data.items():
|
for attr, val in data.items():
|
||||||
if not isinstance(val, dict):
|
if not isinstance(val, dict):
|
||||||
if attr in dir(self): # avoid calling getattr (with hasattr)
|
if attr in dir(self): # avoid calling getattr (with hasattr)
|
||||||
attr, val = fget(attr, val)
|
target, attr, val = fget(attr, val)
|
||||||
if isinstance(val, bool):
|
setattr(target, attr, val)
|
||||||
val = 1 if val else 0
|
else:
|
||||||
|
self.logger.error(f'invalid attribute {attr} for {self}')
|
||||||
self._remote.cache[self._cmd(attr)] = val
|
|
||||||
script += f'{self._cmd(attr)}={val};'
|
|
||||||
else:
|
else:
|
||||||
target = getattr(self, attr)
|
target = getattr(self, attr)
|
||||||
target.apply(val)
|
target.apply(val)
|
||||||
|
|
||||||
self._remote.sendtext(script)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user