本文整理汇总了Python中pytomation.devices.Light.off方法的典型用法代码示例。如果您正苦于以下问题:Python Light.off方法的具体用法?Python Light.off怎么用?Python Light.off使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytomation.devices.Light
的用法示例。
在下文中一共展示了Light.off方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delay_normal
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_delay_normal(self):
# Door Open events retrigger delay
# Instead of turning off in 2 secs should be 4
door = Door()
self.assertIsNotNone(door)
light = Light(address='D1',
devices=(self.interface, door),
delay={
'command': Command.OFF,
'secs': 3,
'source': door}
)
door.open()
self.assertEqual(light.state, State.ON)
door.close()
self.assertEqual(light.state, State.ON)
time.sleep(2)
self.assertEqual(light.state, State.ON)
time.sleep(2)
self.assertEqual(light.state, State.OFF)
# Check to see if we can immediately and directly still turn off
light.off()
door.open()
self.assertEqual(light.state, State.ON)
light.off()
self.assertEqual(light.state, State.OFF)
示例2: test_light_scenario_2
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_light_scenario_2(self):
m = Motion()
l = Light(
address=(49, 3),
devices=(m),
ignore=({
Attribute.COMMAND: Command.DARK,
},
{
Attribute.COMMAND: Command.STILL}
),
time={
Attribute.TIME: '11:59pm',
Attribute.COMMAND: Command.OFF
},
mapped={
Attribute.COMMAND: (
Command.MOTION, Command.OPEN,
Command.CLOSE, Command.LIGHT,
),
Attribute.MAPPED: Command.OFF,
Attribute.SECS: 2,
},
name='Foyer Light',
)
l.off()
self.assertEqual(l.state, State.OFF)
m.motion()
self.assertEqual(l.state, State.OFF)
time.sleep(3)
self.assertEqual(l.state, State.OFF)
示例3: test_device_level_encoded
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_device_level_encoded(self):
d=Light(name='device_test_1')
d.off()
self.assertEqual(d.state, State.OFF)
response = self.api.get_response(method='POST', path="device/" + str(d.type_id), data=['command=level%2C72'])
self.assertEqual(d.state, (State.LEVEL, 72))
self.assertTrue('"name": "device_test_1"' in response)
示例4: test_light_restricted
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_light_restricted(self):
photo = Photocell("D1", initial_state=State.LIGHT)
motion = Motion("D1", initial_state=State.STILL)
light = Light("D2", (motion, photo))
self.assertEqual(light.state, State.OFF)
motion.motion()
self.assertEqual(light.state, State.OFF)
photo.dark()
self.assertEqual(light.state, State.ON)
light.off()
self.assertEqual(light.state, State.OFF)
motion.motion()
self.assertEqual(light.state, State.ON)
示例5: test_ignore_subcommand_wildcard
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_ignore_subcommand_wildcard(self):
s1 = Light()
s2 = Light(devices = s1,
ignore={
Attribute.COMMAND: Command.LEVEL,
},
)
s1.on()
self.assertEqual(s2.state, State.ON)
s1.off()
self.assertEqual(s2.state, State.OFF)
s1.level(80)
self.assertEqual(s2.state, State.OFF)
示例6: test_light_restricted
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_light_restricted(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)
photo.dark()
self.assertEqual(light.state, State.ON)
light.off()
self.assertEqual(light.state, State.OFF)
motion.motion()
self.assertEqual(light.state, State.ON)
示例7: test_scenario_g2
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_scenario_g2(self):
d = StateDevice()
l = Light(address='1E.39.5C',
devices=(d),
delay={
Attribute.COMMAND: Command.OFF,
Attribute.SECS: 2
},
name='Stair Lights up')
self.assertEqual(l.state, State.UNKNOWN)
l.off()
time.sleep(3)
self.assertEqual(l.state, State.OFF)
l.on()
self.assertEqual(l.state, State.ON)
示例8: test_read_only
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_read_only(self):
self.loc.local_time = datetime(2012,6,1,0,0,0)
self.assertEqual(self.loc.state, State.DARK)
l2 = Light()
l = Light(devices=(self.loc, l2))
self.assertEqual(self.loc.state, State.DARK)
l.on()
self.assertEqual(l.state, State.ON)
self.assertEqual(self.loc.state, State.DARK)
l.off()
self.assertEqual(self.loc.state, State.DARK)
l2.off()
self.assertEqual(self.loc.state, State.DARK)
l2.on()
self.assertEqual(self.loc.state, State.DARK)
示例9: test_light_idle
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_light_idle(self):
m = Motion()
m.still()
l = Light(
devices=(m),
idle={Attribute.MAPPED: (Command.LEVEL, 30),
Attribute.SECS: 2,
}
)
l.on()
self.assertEqual(l.state, State.ON)
time.sleep(3)
self.assertEqual(l.state, (State.LEVEL, 30))
#Light shouldnt idle if it is off
l.off()
self.assertEqual(l.state, State.OFF)
time.sleep(3)
self.assertEqual(l.state, State.OFF)
示例10: test_motion_retrigger
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_motion_retrigger(self):
i = Mock()
m = Motion(devices=i,
retrigger_delay={
Attribute.SECS: 2,
},
)
s = Light(devices=m)
s.off()
self.assertEqual(s.state, State.OFF)
m.command(command=Command.ON, source=i)
self.assertEqual(s.state, State.ON)
s.off()
self.assertEqual(s.state, State.OFF)
m.command(command=Command.ON, source=i)
self.assertEqual(s.state, State.OFF)
time.sleep(3)
m.command(command=Command.ON, source=i)
self.assertEqual(s.state, State.ON)
示例11: test_trigger_in_range_gc
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
def test_trigger_in_range_gc(self):
(s_h, s_m, s_s) = datetime.now().timetuple()[3:6]
e_h = s_h
e_m = s_m
e_s = s_s + 2
d1 = StateDevice()
d2 = Light(
devices=d1,
trigger={
Attribute.COMMAND: Command.ON,
Attribute.MAPPED: Command.OFF,
Attribute.SECS: 2,
Attribute.START: '{h}:{m}:{s}'.format(
h=s_h,
m=s_m,
s=s_s,
),
Attribute.END: '{h}:{m}:{s}'.format(
h=e_h,
m=e_m,
s=e_s,
),
}
)
self.assertEqual(d2.state, State.UNKNOWN)
d1.on()
self.assertEqual(d2.state, State.ON)
time.sleep(3)
self.assertEqual(d2.state, State.OFF)
#Out range
d2.off()
self.assertEqual(d2.state, State.OFF)
d1.on()
self.assertEqual(d2.state, State.ON)
time.sleep(3)
self.assertEqual(d2.state, State.ON)
示例12: Location
# 需要导入模块: from pytomation.devices import Light [as 别名]
# 或者: from pytomation.devices.Light import off [as 别名]
ph_sun = Location('35.2269', '-80.8433', tz='US/Eastern', mode=Location.MODE.STANDARD, is_dst=True)
# Turn on the foyer light at night when either the door is opened or family PIR is tripped.
l_foyer = Light((49, 3), (upb, d_foyer, m_family, ph_sun))
# After being turned on, turn off again after 2 minutes of inactivity.
l_foyer.delay_off(2*60)
# Turn off the light no matter what at 11:59pm
l_foyer.time_off('11:59pm')
# Do not turn on the light automatically when it is night time (indoor light)
# Only looks at dark for restricing the whether the light should come on
l_foyer.ignore_dark(True)
##################### USER CODE ###############################
#Manually controlling the light
l_foyer.on()
l_foyer.off()
# Loop control
def MainLoop(*args, **kwargs):
print 'Im in a main loop!'
if l_foyer.state == State.ON:
l_foyer.off()
else:
l_foyer.on()
# Start the whole system. pytomation.common.system.start()
start(
loop_action=MainLoop,
loop_time=1, # Loop every 1 sec
admin_user='pyto',