def test_light_scenario_g1(self): d = Door() p = Photocell() p.light() l = Light(address='xx.xx.xx', devices=(d, p), mapped={ Attribute.COMMAND: (Command.CLOSE), Attribute.MAPPED: Command.OFF, Attribute.SECS: 2, }, ignore=({Attribute.COMMAND: Command.DARK}), name="Hallway Lights",) l.on() self.assertEqual(l.state, State.ON) d.close() self.assertEqual(l.state, State.ON) time.sleep(3) self.assertEqual(l.state, State.OFF) d.open() self.assertEqual(l.state, State.OFF)
def test_light_scenario_g1(self): d = Door() p = Photocell() p.light() l = Light( address='xx.xx.xx', devices=(d, p), mapped={ Attribute.COMMAND: (Command.CLOSE), Attribute.MAPPED: Command.OFF, Attribute.SECS: 2, }, ignore=({ Attribute.COMMAND: Command.DARK }), name="Hallway Lights", ) l.on() self.assertEqual(l.state, State.ON) d.close() self.assertEqual(l.state, State.ON) time.sleep(3) self.assertEqual(l.state, State.OFF) d.open() self.assertEqual(l.state, State.OFF)
def test_light_photocell_delay(self): # Delay off should not trigger when photocell tells us to go dark. # Do it immediately photo = Photocell() photo.dark() light = Light(address="e3", devices=photo, delay_off=3) self.assertEqual(light.state, State.ON) photo.light() self.assertEqual(light.state, State.OFF)
def test_light_restriction_idle(self): ph = Photocell() m = Motion() ph.dark() l = Light(devices=(ph, m), idle={ Attribute.MAPPED: (Command.LEVEL, 30), Attribute.SECS: 2, }) m.motion() self.assertEqual(l.state, State.ON) ph.light() self.assertEqual(l.state, State.OFF) m.motion() self.assertEqual(l.state, State.OFF) time.sleep(3) self.assertEqual(l.state, State.OFF)
def test_light_restriction_idle(self): ph = Photocell() m = Motion() ph.dark() l = Light( devices=(ph, m), idle={Attribute.MAPPED: (Command.LEVEL, 30), Attribute.SECS: 2, } ) m.motion() self.assertEqual(l.state, State.ON) ph.light() self.assertEqual(l.state, State.OFF) m.motion() self.assertEqual(l.state, State.OFF) time.sleep(3) self.assertEqual(l.state, State.OFF)