本文整理汇总了Python中pytomation.devices.StateDevice.off方法的典型用法代码示例。如果您正苦于以下问题:Python StateDevice.off方法的具体用法?Python StateDevice.off怎么用?Python StateDevice.off使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytomation.devices.StateDevice
的用法示例。
在下文中一共展示了StateDevice.off方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_binding_default
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_binding_default(self):
d1 = StateDevice()
d1.off()
d2 = StateDevice(d1)
self.assertEqual(d2.state, State.OFF)
d1.on()
self.assertEqual(d2.state, State.ON)
示例2: test_delay_multiple
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_delay_multiple(self):
d1 = StateDevice()
d2 = StateDevice()
d3 = StateDevice(
devices=(d1, d2),
delay=(
{Attribute.COMMAND: (Command.OFF),
Attribute.SOURCE: (d1),
Attribute.SECS: 2,
},
{Attribute.COMMAND: Command.OFF,
Attribute.SOURCE: d2,
Attribute.SECS: 4,
},
)
)
self.assertEqual(d3.state, State.UNKNOWN)
d3.on()
self.assertEqual(d3.state, State.ON)
d1.off()
self.assertEqual(d3.state, State.ON)
time.sleep(3)
self.assertEqual(d3.state, State.OFF)
#d2
d3.on()
self.assertEqual(d3.state, State.ON)
d2.off()
self.assertEqual(d3.state, State.ON)
time.sleep(3)
self.assertEqual(d3.state, State.ON)
time.sleep(1)
self.assertEqual(d3.state, State.OFF)
示例3: test_retrigger_delay
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_retrigger_delay(self):
d1 = StateDevice()
d2 = StateDevice(devices=d1,
retrigger_delay={
Attribute.SECS: 2
},
name='tested')
d3 = StateDevice(devices=d2)
d1.off()
self.assertEqual(d1.state, State.OFF)
self.assertEqual(d2.state, State.OFF)
self.assertEqual(d3.state, State.OFF)
d1.on()
self.assertEqual(d1.state, State.ON)
self.assertEqual(d2.state, State.ON)
self.assertEqual(d3.state, State.ON)
d3.off()
self.assertEqual(d3.state, State.OFF)
# set on again, this time no delegation
d1.on()
self.assertEqual(d3.state, State.OFF)
# after x amount of time allow dupes
time.sleep(3)
d1.on()
self.assertEqual(d3.state, State.ON)
示例4: test_last_command
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_last_command(self):
s1 = StateDevice()
s1.on()
self.assertEqual(s1.state, State.ON)
s1.off()
self.assertEqual(s1.state, State.OFF)
self.assertEqual(s1.last_command, Command.OFF)
示例5: test_device_on
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_device_on(self):
d=StateDevice(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=on'])
self.assertEqual(d.state, State.ON)
self.assertTrue('"name": "device_test_1"' in response)
示例6: test_delay_zero_secs
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_delay_zero_secs(self):
d1 = StateDevice()
d2 = StateDevice()
d3 = StateDevice(
devices=(d1, d2),
delay=({
Attribute.COMMAND: Command.OFF,
Attribute.SECS: 2
},
{
Attribute.COMMAND: Command.OFF,
Attribute.SECS: 0,
Attribute.SOURCE: d2,
}
),
initial=State.ON,
)
self.assertEqual(d3.state, State.ON)
d1.off()
self.assertEqual(d3.state, State.ON)
time.sleep(3)
self.assertEqual(d3.state, State.OFF)
d3.on()
self.assertEqual(d3.state, State.ON)
d2.off()
self.assertEqual(d3.state, State.OFF)
示例7: test_onStateChanged
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_onStateChanged(self):
s1 = StateDevice()
custom = Mock()
s1.on()
s1.onStateChanged(custom.method)
s1.off()
custom.method.assert_called_with(State.OFF, source=None, prev=State.ON)
示例8: test_previous_state_command
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_previous_state_command(self):
s1 = StateDevice()
s1.on()
self.assertEqual(s1.state, State.ON)
s1.off()
self.assertEqual(s1.state, State.OFF)
s1.previous()
self.assertEqual(s1.state, State.ON)
示例9: test_ignore_multi_command
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_ignore_multi_command(self):
s1 = StateDevice()
s2 = StateDevice(devices=s1,
ignore={
Attribute.COMMAND: (Command.ON, Command.OFF,)
},
)
self.assertEqual(s2.state, State.UNKNOWN)
s1.on()
self.assertEqual(s2.state, State.UNKNOWN)
s1.off()
self.assertEqual(s2.state, State.UNKNOWN)
示例10: test_ignore_state
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_ignore_state(self):
s1 = StateDevice()
s2 = StateDevice(s1)
s1.on()
self.assertEqual(s2.state, State.ON)
s1.off()
self.assertEqual(s2.state, State.OFF)
s2.ignore_on()
s1.on()
self.assertEqual(s2.state, State.OFF)
s2.ignore_on(False)
s1.on()
self.assertEqual(s2.state, State.ON)
示例11: test_delay_single
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_delay_single(self):
d1 = StateDevice(
delay={Attribute.COMMAND: Command.OFF,
Attribute.SECS: 2,
}
)
self.assertEqual(d1.state, State.UNKNOWN)
d1.on()
self.assertEqual(d1.state, State.ON)
d1.off()
self.assertEqual(d1.state, State.ON)
time.sleep(3)
# time.sleep(20000)
self.assertEqual(d1.state, State.OFF)
示例12: test_ignore_state
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_ignore_state(self):
s1 = StateDevice()
s2 = StateDevice(devices = s1,
ignore={
'command': Command.ON,
'source:': s1,
},
)
s1.on()
self.assertEqual(s2.state, State.UNKNOWN)
s1.off()
self.assertEqual(s2.state, State.OFF)
s1.on()
self.assertEqual(s2.state, State.OFF)
示例13: test_delay_single
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_delay_single(self):
d1 = StateDevice(
delay={'command': Command.OFF,
'secs': 2,
}
)
self.assertEqual(d1.state, State.UNKNOWN)
d1.on()
self.assertEqual(d1.state, State.ON)
d1.off()
self.assertEqual(d1.state, State.ON)
time.sleep(3)
# time.sleep(20000)
self.assertEqual(d1.state, State.OFF)
示例14: test_ignore_state
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_ignore_state(self):
s1 = StateDevice()
s2 = StateDevice(devices = s1,
ignore={
Attribute.COMMAND: Command.ON,
Attribute.SOURCE: s1,
},
)
s1.on()
self.assertEqual(s2.state, State.UNKNOWN)
s1.off()
self.assertEqual(s2.state, State.OFF)
s1.on()
self.assertEqual(s2.state, State.OFF)
示例15: test_state_remove_device
# 需要导入模块: from pytomation.devices import StateDevice [as 别名]
# 或者: from pytomation.devices.StateDevice import off [as 别名]
def test_state_remove_device(self):
s1 = StateDevice()
s2 = StateDevice(devices=s1)
s1.on()
self.assertEqual(s2.state, State.ON)
s2.off()
self.assertEqual(s2.state, State.OFF)
r=s2.remove_device(s1)
self.assertTrue(r)
self.assertEqual(s2.state, State.OFF)
s1.on()
self.assertEqual(s2.state, State.OFF)
# remove again and not error
r = s2.remove_device(s1)
self.assertFalse(r)