def switch(self, to): if to != self.status: get_device(self.comm).switch(self, to) if to: self.log("switched on") else: self.log("switched off") self.status = to
def execute(self, action, target=None): if action == "switch": device = get_device(target) device.switch(not device.get_status()) get_logger().event("core", "manually switched '%s' to '%s'" % (device.name, ("on" if device.get_status() else "off"))) if action == "dim": device = get_device(target) device.dim() if action == "undim": device = get_device(target) device.undim() if action == "toggle_ai": self.context.update("ai", not self.context.get("ai"))
def execute(self, action, target=None): if action == "switch": device = get_device(target) device.switch(not device.get_status()) get_logger().event( "core", "manually switched '%s' to '%s'" % (device.name, ("on" if device.get_status() else "off"))) if action == "dim": device = get_device(target) device.dim() if action == "undim": device = get_device(target) device.undim() if action == "toggle_ai": self.context.update("ai", not self.context.get("ai"))
def undim(self): get_device(self.comm).undim(self)
def dim(self): get_device(self.comm).dim(self)
def check(self): sensor = get_device(self.device) if not sensor.motion: return False return time.time() < (sensor.motion + self.timeout)
def check(self): return get_device(self.device).get_status() == self.status
def log(self, msg): super(Alarm, self).log(msg) if self.notify: get_device(self.notify).notify(msg)
def execute(self): logging.debug("executing action switch '%s' on device '%s' to '%s'" % (self.__class__.__name__, self.device, self.switch)) get_device(self.device).switch(self.switch)