adds MacroButtonColorMixin.

This commit is contained in:
onyx-and-iris 2023-07-23 07:56:09 +01:00
parent bf77ded007
commit 46e7ffe478
3 changed files with 17 additions and 4 deletions

View File

@ -23,6 +23,7 @@ class Adapter(IRemote):
def output(self): def output(self):
pass pass
@property
def identifier(self): def identifier(self):
pass pass

View File

@ -33,6 +33,7 @@ class IRemote(metaclass=ABCMeta):
cmd += (f".{param}",) cmd += (f".{param}",)
return "".join(cmd) return "".join(cmd)
@property
@abstractmethod @abstractmethod
def identifier(self): def identifier(self):
pass pass

View File

@ -12,9 +12,6 @@ ButtonModes = IntEnum(
class Adapter(IRemote): class Adapter(IRemote):
"""Adapter to the common interface.""" """Adapter to the common interface."""
def identifier(self):
pass
def getter(self, mode): def getter(self, mode):
self.logger.debug(f"getter: button[{self.index}].{ButtonModes(mode).name}") self.logger.debug(f"getter: button[{self.index}].{ButtonModes(mode).name}")
return self._remote.get_buttonstatus(self.index, mode) return self._remote.get_buttonstatus(self.index, mode)
@ -26,7 +23,21 @@ class Adapter(IRemote):
self._remote.set_buttonstatus(self.index, val, mode) self._remote.set_buttonstatus(self.index, val, mode)
class MacroButton(Adapter): class MacroButtonColorMixin(IRemote):
@property
def identifier(self):
return f"command.button[{self.index}]"
@property
def color(self) -> int:
return int(IRemote.getter(self, "color"))
@color.setter
def color(self, val: int):
IRemote.setter(self, "color", val)
class MacroButton(Adapter, MacroButtonColorMixin):
"""Defines concrete implementation for macrobutton""" """Defines concrete implementation for macrobutton"""
def __str__(self): def __str__(self):