本文整理汇总了Python中ouimeaux.environment.Environment.get方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get方法的具体用法?Python Environment.get怎么用?Python Environment.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ouimeaux.environment.Environment
的用法示例。
在下文中一共展示了Environment.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wemo_env
# 需要导入模块: from ouimeaux.environment import Environment [as 别名]
# 或者: from ouimeaux.environment.Environment import get [as 别名]
class wemo_env(object):
def __init__(self):
self._watcheux = {}
self._env = Environment()
try:
self._env.start()
self._env.discover(3)
except:
print("WeMo environment cannot start ;( !!!!")
def start_watching(self):
statechange.connect(self.update_state,
unique=False,
dispatch_uid=id(self))
def get_device(self, name):
return self._env.get(name)
def register(self, name, fct):
if name not in self._watcheux:
self._watcheux[name] = []
self._watcheux[name].append(fct)
if len(self._watcheux) > 0:
self.start_watching()
def update_state(self, sender, **kwargs):
state = kwargs.get('state')
if state != 0:
state = 1
if sender.name in self._watcheux:
for watcheu in self._watcheux[sender.name]:
watcheu(state)
示例2: open
# 需要导入模块: from ouimeaux.environment import Environment [as 别名]
# 或者: from ouimeaux.environment.Environment import get [as 别名]
with open(sys.argv[1]) as conf:
config = json.loads(conf.read())
env = Environment(with_subscribers=False, with_cache=False)
env.start()
env.discover()
#env.wait(3)
found_wemos = False
for switch_name in env.list_switches():
for entry in config:
if switch_name == entry.get('wemo switch'):
# FIXME: log
print("Found Wemo: {}".format(switch_name))
button_switches[entry['button mac']] = env.get(switch_name)
found_wemos = True
for bridge_name in env.list_bridges():
bridge = env.get_bridge(bridge_name)
for light_name in bridge.bridge_get_lights():
for entry in config:
if light_name == entry.get('wemo light'):
light = Light('Garage North', bridge)
# FIXME: log
print("Found Wemo: {}".format(switch_name))
button_switches[entry['button mac']] = light
found_wemos = True
for entry in config:
if entry.get('email to'):