2022-06-16 14:07:12 +01:00
|
|
|
from .iremote import IRemote
|
|
|
|
|
|
|
|
|
|
|
|
class Adapter(IRemote):
|
|
|
|
"""Adapter to the common interface."""
|
|
|
|
|
|
|
|
def identifier(self):
|
|
|
|
pass
|
|
|
|
|
2022-06-21 23:21:55 +01:00
|
|
|
def getter(self, mode):
|
|
|
|
return self._remote.get_buttonstatus(self.index, mode)
|
2022-06-16 14:07:12 +01:00
|
|
|
|
2022-06-21 23:21:55 +01:00
|
|
|
def setter(self, val, mode):
|
|
|
|
self._remote.set_buttonstatus(self.index, val, mode)
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
class MacroButton(Adapter):
|
|
|
|
"""Defines concrete implementation for macrobutton"""
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"{type(self).__name__}{self._remote.kind}{self.index}"
|
|
|
|
|
|
|
|
@property
|
|
|
|
def state(self) -> bool:
|
2022-06-21 23:21:55 +01:00
|
|
|
return self.getter(1) == 1
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
@state.setter
|
2023-07-20 11:11:34 +01:00
|
|
|
def state(self, val: bool):
|
2022-06-21 23:21:55 +01:00
|
|
|
self.setter(1 if val else 0, 1)
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def stateonly(self) -> bool:
|
2022-06-21 23:21:55 +01:00
|
|
|
return self.getter(2) == 1
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
@stateonly.setter
|
2023-07-20 11:11:34 +01:00
|
|
|
def stateonly(self, val: bool):
|
2022-06-21 23:21:55 +01:00
|
|
|
self.setter(1 if val else 0, 2)
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def trigger(self) -> bool:
|
2022-06-21 23:21:55 +01:00
|
|
|
return self.getter(3) == 1
|
2022-06-16 14:07:12 +01:00
|
|
|
|
|
|
|
@trigger.setter
|
2023-07-20 11:11:34 +01:00
|
|
|
def trigger(self, val: bool):
|
2022-06-21 23:21:55 +01:00
|
|
|
self.setter(1 if val else 0, 3)
|