def test_location_triggered(self): home = Location('35.2269', '-80.8433') home.local_time = datetime(2012,6,1,12,0,0) light = Light('D1', home) self.assertEqual(light.state, State.OFF) home.local_time = datetime(2012,6,1,0,0,0) self.assertEqual(home.state, State.DARK) self.assertEqual(light.state, State.ON)
def test_location_triggered(self): home = Location('35.2269', '-80.8433') home.local_time = datetime(2012, 6, 1, 12, 0, 0) light = Light('D1', home) self.assertEqual(light.state, State.OFF) home.local_time = datetime(2012, 6, 1, 0, 0, 0) self.assertEqual(home.state, State.DARK) self.assertEqual(light.state, State.ON)
def test_civil(self): ph_standard = Location('35.2269', '-80.8433', tz='US/Eastern', mode=Location.MODE.CIVIL, is_dst=True, local_time=datetime(2012,11,26,17,15,0)) self.assertIsNotNone(ph_standard)
def test_gc_1(self): twilight_standard = Location('42.2671389', '-71.8756111', tz='US/Eastern', mode=Location.MODE.STANDARD, is_dst=True, name='Standard Twilight') twilight_standard.local_time = datetime(2012, 6, 1, 0, 0, 0) self.assertEqual(twilight_standard.state, State.DARK) _back_porch = Light( address='21.03.24', devices=(twilight_standard), initial=twilight_standard, # command=( { Attribute.COMMAND: (Command.DARK), Attribute.MAPPED: (Command.ON), Attribute.SOURCE: (twilight_standard), }, # { Attribute.COMMAND: (Command.LIGHT), Attribute.MAPPED: (Command.OFF), Attribute.SOURCE: (twilight_standard), }, ), map=( { Attribute.COMMAND: (Command.DARK), Attribute.MAPPED: (Command.ON), Attribute.SOURCE: (twilight_standard), }, { Attribute.COMMAND: (Command.LIGHT), Attribute.MAPPED: (Command.OFF), Attribute.SOURCE: (twilight_standard), }, ), ignore=({ Attribute.COMMAND: Command.OFF, Attribute.SOURCE: twilight_standard, }, ), time=({ Attribute.COMMAND: (Command.LEVEL, 30), Attribute.TIME: '11:15pm', }, ), name="Back porch light") self.assertEqual(twilight_standard.state, State.DARK) self.assertEqual(_back_porch.state, State.ON)
def test_gc_1(self): twilight_standard = Location( '42.2671389', '-71.8756111', tz='US/Eastern', mode=Location.MODE.STANDARD, is_dst=True, name='Standard Twilight') twilight_standard.local_time = datetime(2012,6,1,0,0,0) self.assertEqual(twilight_standard.state, State.DARK) _back_porch = Light(address='21.03.24', devices=(twilight_standard), initial=twilight_standard, # command=( { Attribute.COMMAND: (Command.DARK), Attribute.MAPPED: (Command.ON), Attribute.SOURCE: (twilight_standard), }, # { Attribute.COMMAND: (Command.LIGHT), Attribute.MAPPED: (Command.OFF), Attribute.SOURCE: (twilight_standard), }, ), map=( { Attribute.COMMAND: (Command.DARK), Attribute.MAPPED: (Command.ON), Attribute.SOURCE: (twilight_standard), }, { Attribute.COMMAND: (Command.LIGHT), Attribute.MAPPED: (Command.OFF), Attribute.SOURCE: (twilight_standard), }, ), ignore=( { Attribute.COMMAND: Command.OFF, Attribute.SOURCE: twilight_standard, }, ), time=( { Attribute.COMMAND:(Command.LEVEL, 30), Attribute.TIME: '11:15pm', }, ), name="Back porch light") self.assertEqual(twilight_standard.state, State.DARK) self.assertEqual(_back_porch.state, State.ON)
# Import all the Pytomation interfaces we are going to use. from pytomation.interfaces import UPB, InsteonPLM, TCP, Serial, Stargate, W800rf32, NamedPipe, StateInterface, Command, RPIInput, InsteonPLM2, HTTPServer # Import all the Pytomation Devices we will use. from pytomation.devices import Motion, Door, Light, Location, InterfaceDevice, Photocell, Generic, StateDevice, State, Attribute, Scene, Controller #Create PLM and setup Raspberry PI board and web server #Note: Raspberry PI inputs require root access insteon = InsteonPLM2(Serial('/dev/ttyUSB0', 19200, xonxoff=False)) GPIO.setmode(GPIO.BOARD) web = HTTPServer(address='raspberrypi.home') ph_standard = Location('53.55', '-113.5', tz='Canada/Mountain', mode=Location.MODE.STANDARD, is_dst=True, name='Standard Photocell') ll_livingroom1 = Light(address='18.97.08', devices=(insteon), name="Living Room Lamp 1") ll_livingroom2 = Light(address='14.27.D3', devices=(insteon), name="Living Room Lamp 2") sl_livingroom1 = Light(address='17.F7.8C', devices=(insteon), name="Living Room Lamps") sl_livingroom2 = Light(address='16.67.06', devices=(insteon),
def setUp(self): self.loc = Location('35.2269', '-80.8433')
name='Stair Motion') m_recroom = Motion(address='I1', devices=w800, name='Recroom Motion') m_backdoor = Motion(address='J1', devices=w800, name='Backdoor Motion') # ______ DOOR CONTACTS ______________________________________________ d_back = Door(address='AG', devices=wtdio, name='Backdoor Contact') # ______ LOCATION ___________________________________________________ # ph_standard = Location('48.9008', '-119.8463', #moved this east a bit tz='America/Vancouver', mode=Location.MODE.STANDARD, is_dst=True, name='Standard Photocell') # ______ GENERICS ___________________________________________________ # # Use this for a oneshot at dark. on_at_night = Generic(devices=ph_standard, ignore=({Attribute.COMMAND: Command.LIGHT}), name='Dark oneshot') # Cheap way to say some one is in the house # Make sure the signal lasts at least one loop through mainloop, my mainloop # is set to 30 seconds
#Thermostat (override available commads) thermostat_commands = [ Command.AUTOMATIC, Command.COOL, Command.HEAT, Command.HOLD, Command.SCHEDULE, Command.OFF, Command.LEVEL, Command.CIRCULATE, Command.STILL, Command.VACATE, Command.OCCUPY, Command.SETPOINT ] hall_thermostat = Thermostat(commands=thermostat_commands, name="Thermostat", devices=VenstarThermostat( HTTP(host='HallThermostat'), type='commercial')) #Sensors ph_calculated = Location('38.576492', '-121.493375', tz='America/Los_Angeles', mode=Location.MODE.STANDARD, is_dst=True, name='Calculated Photocell') #Front Door sensor, remove non functional status command d_front_door = Door(address='2AF9B7', devices=(insteon), name="Front Door Sensor", commands=[Command.OPEN, Command.CLOSE]) #Front Door Deadbolt (key set in config.xml, in config_path) lk_front_door = Lock(address='4', devices=(ozw, d_front_door), name="Front Door Deadbolt", mapped={ Attribute.COMMAND: Command.CLOSE,
#keypads k_master = Generic(address=(49, 8), devices=(upb, ), name='Master Bed Keypad') #Scenes #s_all_indoor_off = InterfaceDevice( # address=(49,4,'L'), # devices=(upb,), # ) s_all_indoor_off = StateDevice() #photocell ph_standard = Location('35.2269', '-80.8433', tz='US/Eastern', mode=Location.MODE.STANDARD, is_dst=True, name='Standard Photocell') ph_civil = Location('35.2269', '-80.8433', tz='US/Eastern', mode=Location.MODE.CIVIL, is_dst=True, name='Civil Photocell') # Rooms r_foyer = Room(name='Foyer', devices=(m_foyer)) r_den = Room(name='Den', devices=(m_den, r_foyer)) r_family = Room( name='Family', devices=(m_family, r_foyer),