def set_state(self, new_state): if (self.state[0] == "Closed" or self.state[0] == "Waiting") and new_state[0] == "Open": ns = (new_state[0], self.off_time) self.last_open_time = None Device.set_state(self, ns) elif self.state[0] == "Open" and new_state[0] == "Closed": ns = ("Waiting", self.off_time) self.last_open_time = datetime.now() Device.set_state(self, ns)
def set_state(self, new_state): if (self.state[0] == 'Off' or self.state[0] == 'Waiting') \ and new_state[0] == 'On': ns = (new_state[0], self.off_time) self.last_motion_time = None Device.set_state(self, ns) elif self.state[0] == 'On' and new_state[0] == 'Off': ns = ('Waiting', self.off_time) self.last_motion_time = datetime.now() Device.set_state(self, ns)