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_unrestricted(self): photo = Photocell('D1', initial=State.LIGHT) self.assertEqual(photo.state, State.LIGHT) motion = Motion('D1', initial=State.STILL) light = Light('D2', devices=(motion, photo), initial=photo) self.assertEqual(light.state, State.OFF) motion.motion() self.assertEqual(light.state, State.OFF) motion.unrestricted = True motion.motion() self.assertEqual(light.state, State.ON)
def test_light_photocell_intial(self): motion = Motion() motion.still() photo = Photocell(address='asdf') photo.dark() light = Light( address='e3', devices=(photo, motion), initial=photo, ) self.assertEqual(light.state, State.ON)
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_photocell_triggered(self): photo = Photocell('D1', initial=State.LIGHT) light = Light('D1', devices=photo) self.assertEquals(light.state, State.OFF) photo.dark() self.assertEquals(light.state, State.ON)
def setUp(self): self.interface = Mock() self.interface.state = State.UNKNOWN self.device = Photocell('D1', self.interface)
#motion # Motion sensor is hardwired and immediate OFF.. Want to give it some time to still detect motion right after m_family = Motion(address='D8', devices=(sg), delay={ Attribute.COMMAND: Command.STILL, Attribute.SECS: 30, }, name='Family Motion') m_front_porch = Motion( address='F1', devices=w800, name='Front Porch Motion', ) ph_front_porch = Photocell(address='F2', devices=w800) m_front_garage = Motion(address='F3', devices=w800, name='Front Garage Motion') ph_front_garage = Photocell(address='F4', devices=w800) m_front_driveway = Motion(address='F5', devices=w800, name='Front Driveway Motion') ph_front_driveway = Photocell(address='F6', devices=w800) m_front_camera = Motion(address=None, devices=pipe_front_yard_motion) m_garage = Motion(address='G1', devices=w800, name='Garage Motion') ph_garage = Photocell(address='G2', devices=w800) m_utility = Motion(address='G3', devices=w800, name='Utility Motion') ph_utility = Photocell(address='G4', devices=w800) m_breakfast = Motion(address='G7', devices=w800, name='Breakfast Motion')