Esempio n. 1
0
 def __init__(self, sid: str, gateway: ZigbeeGateway):
     super().__init__(sid, gateway)
     self.status.model = 'plug'
     self.status.add_alias('status', 'power')
     self.status.register_attribute(Attribute('inuse', str))
     self.status.register_attribute(Attribute('power_consumed', str))
     self.status.register_attribute(Attribute('load_power', str))
     self.gateway.register_sub_device(self)
Esempio n. 2
0
 def __init__(self, sid:str) -> None:
     self.status: DeviceStatus = DeviceStatus()
     for _attr in self._attr_list:
         self.status.register_attribute(deepcopy(_attr))
     self.status.register_attribute(Attribute('sid', str, value=sid, readonly=True))
     self.status.register_attribute(Attribute('name', dict))
     self.status.register_attribute(Attribute('place', dict))
     self.status.register_attribute(Attribute('model', str))
Esempio n. 3
0
class Hsv(Trait):
    _commands: Tuple[str, ...] = ('set_hsv', )
    _attributes: Tuple[Attribute,
                       Attribute] = (Attribute('hue',
                                               int), Attribute('sat', int))

    @abstractmethod
    def set_hsv(self, hue: int, sat: int):
        pass
Esempio n. 4
0
 def __init__(self, sid: str, gateway: ZigbeeGateway):
     super().__init__(sid, gateway)
     self.status.model = 'ctrl_neutral2'
     self.status.register_attribute(Attribute('left', str))
     self.status.register_attribute(Attribute('right', str))
     self.status.add_alias('channel_0', 'left')
     self.status.add_alias('channel_1', 'right')
     self.status.switches = ['left', 'right']
     self.gateway.register_sub_device(self)
Esempio n. 5
0
 def __init__(self, sid:str):
     super().__init__(sid)
     self.min_ct:int = 1700
     self.max_ct:int = 6500
     self.status.register_attribute(Attribute('ip', str))
     self.status.register_attribute(Attribute('port', int))
     self.status.register_attribute(Attribute('color_mode', int))
     self._init_device()
     self.api = YeelightApi(self.status.ip, self.status.port)
     
     self.watcher = Watcher(YeelightWatcher(self))
     self.watcher.add_report_handler(self.status.update)
Esempio n. 6
0
 def __init__(self,
              ip: str,
              mac: str = '',
              psk: str = '0000',
              sid: str = ''):
     super().__init__(sid)
     self.status.register_attribute(Attribute('ip', str, value=ip))
     self.status.register_attribute(Attribute('psk', str, value=psk))
     self.status.register_attribute(Attribute('mac', str, value=mac))
     self.status.add_alias('dispNum', 'channel')
     self._event: Event = None
     self.dev_api = BraviaApi(ip, mac, psk)
     self._dev_init()
     self.watcher = Watcher(BraviaWatcher(30, self))
Esempio n. 7
0
class Scene(Trait):
    _commands: Tuple[str, ...] = ('set_scene', )
    _attributes: Tuple[Attribute] = (Attribute('scene', str), )

    @abstractmethod
    def set_scene(self, scene: Any, args: List[Any] = []):
        pass
Esempio n. 8
0
class Dimmer(Trait):
    _commands: Tuple[str, ...] = ('set_bright', )
    _attributes: Tuple[Attribute, ...] = (Attribute('bright', int), )

    @abstractmethod
    def set_bright(self, value: int):
        pass
Esempio n. 9
0
class MultiSwitch(Trait):
    _commands: Tuple[str, ...] = ('on', 'off')
    _attributes: Tuple[Attribute, ...] = (Attribute('switches',
                                                    list,
                                                    readonly=True,
                                                    oneshot=True), )

    @abstractmethod
    def on(self, switch_name: str):
        pass

    @abstractmethod
    def off(self, switch_name: str):
        pass

    @abstractmethod
    def toggle(self, switch_name: str):
        pass

    @abstractmethod
    def is_on(self, switch_name: str) -> bool:
        pass

    @abstractmethod
    def is_off(self, switch_name: str) -> bool:
        pass
Esempio n. 10
0
class ColorTemperature(Trait):
    _commands: Tuple[str, ...] = ('set_ct_pc', )
    _attributes: Tuple[Attribute] = (Attribute('ct_pc', int), )

    @abstractmethod
    def set_ct_pc(self, pc: int):
        pass
Esempio n. 11
0
    def test_a_readonly_oneshot(self):
        ro_attr = Attribute('test_oneshot', str, readonly=True, oneshot=True)
        self.status.register_attribute(ro_attr)

        self.status.test_oneshot = 'foo'
        self.assertEqual(self.status.test_oneshot, 'foo')

        with self.assertRaises(AttributeError):
            self.status.test_oneshot = 'bar'
Esempio n. 12
0
class OpenClose(Trait):
    _commands: Set[str] = set()
    _attributes: Tuple[Attribute, ...] = (Attribute('status', str), )

    @abstractmethod
    def is_open(self) -> bool:
        pass

    @abstractmethod
    def is_close(self) -> bool:
        pass
Esempio n. 13
0
class Rgb(Trait):
    _commands: Tuple[str, ...] = ('set_rgb', 'set_color')
    _attributes: Tuple[Attribute] = (Attribute('rgb', int), )

    @abstractmethod
    def set_rgb(self, red: int, green: int, blue: int):
        pass

    @abstractmethod
    def set_color(self, rgb: int):
        pass
Esempio n. 14
0
class SuspendResume(Trait):
    _commands: Tuple[str, ...] = ('suspend', 'resume')
    _attributes: Tuple[Attribute, ...] = (Attribute('power_state', str), )

    @abstractmethod
    def suspend(self) -> None:
        pass

    @abstractmethod
    def resume(self) -> None:
        pass
Esempio n. 15
0
class Contact(Trait):
    _commands: Set[str] = set()
    _attributes: Tuple[Attribute, ...] = (Attribute('contact', bool), )

    @abstractmethod
    def is_open(self) -> bool:
        pass

    @abstractmethod
    def is_close(self) -> bool:
        pass
Esempio n. 16
0
class Channels(Trait):
    _commands: Tuple[str, ...] = ('channel_up', 'channel_down', 'set_channel')
    _attributes: Tuple[Attribute] = (Attribute('channel', str), )

    @abstractmethod
    def channel_up(self):
        pass

    @abstractmethod
    def channel_down(self):
        pass

    @abstractmethod
    def set_channel(self, value: int):
        pass
Esempio n. 17
0
class Volume(Trait):
    _commands: Tuple[str, ...] = ('volume_up', 'volume_down', 'set_volume')
    _attributes: Tuple[Attribute] = (Attribute('volume', str), )

    @abstractmethod
    def volume_up(self):
        pass

    @abstractmethod
    def volume_down(self):
        pass

    @abstractmethod
    def set_volume(self, value: int):
        pass

    @abstractmethod
    def set_mute(self, status: bool):
        pass
Esempio n. 18
0
class OnOff(Trait):
    _commands: Tuple[str, ...] = ('on', 'off')
    _attributes: Tuple[Attribute, ...] = (Attribute('power', str), )

    @abstractmethod
    def on(self) -> None:
        """ Device power on """
        pass

    @abstractmethod
    def off(self) -> None:
        pass

    @abstractmethod
    def is_on(self) -> bool:
        pass

    @abstractmethod
    def is_off(self) -> bool:
        pass
Esempio n. 19
0
 def test_a_sid(self):
     sid_attr = Attribute('sid', str, value="123345678900")
     self.status.register_attribute(sid_attr)
     self.assertEqual(self.status.sid, "123345678900")
Esempio n. 20
0
 def __init__(self, sid: str, gateway: ZigbeeGateway) -> None:
     super().__init__(sid, gateway)
     self.status.model = 'GZCGQ01LM'
     self.status.register_attribute(Attribute('lux', int))
     self.gateway.register_sub_device(self)
Esempio n. 21
0
 def test_a_readonly(self):
     ro_attr = Attribute('test', str, readonly=True)
     self.status.register_attribute(ro_attr)
     with self.assertRaises(AttributeError):
         self.status.test = 'foo'
Esempio n. 22
0
 def __init__(self, sid: str, gateway: AqaraGateway):
     super().__init__(sid, gateway)
     self.status.register_attribute(Attribute('proto_version', str))
     self.status.bright = 255
     self.gateway.register_sub_device(self)
Esempio n. 23
0
class MotionStatus(Trait):
    _commands: Tuple[str, ...] = tuple()
    _attributes: Tuple[Attribute, ...] = (Attribute('occupancy', bool), )
Esempio n. 24
0
class TemperatureStatus(Trait):
    _commands: Tuple[str, ...] = tuple()
    _attributes: Tuple[Attribute] = (Attribute('temperature', str), )
Esempio n. 25
0
class HumidityStatus(Trait):
    _commands: Tuple[str, ...] = tuple()
    _attributes: Tuple[Attribute] = (Attribute('humidity', str), )
Esempio n. 26
0
class PressureStatus(Trait):
    _commands: Tuple[str, ...] = tuple()
    _attributes: Tuple[Attribute] = (Attribute('pressure', str), )
Esempio n. 27
0
 def __init__(self, sid:str):
     super().__init__(sid)
     self.status.register_attribute(Attribute('ct', int))
     self.min_ct = 2700
     self.max_ct = 6500
Esempio n. 28
0
class IlluminanceStatus(Trait):
    _commands: Tuple[str, ...] = tuple()
    _attributes: Tuple[Attribute] = (Attribute('illuminance', int), )