本文整理汇总了Python中actions.Actions.ws_control方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.ws_control方法的具体用法?Python Actions.ws_control怎么用?Python Actions.ws_control使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类actions.Actions
的用法示例。
在下文中一共展示了Actions.ws_control方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from actions import Actions [as 别名]
# 或者: from actions.Actions import ws_control [as 别名]
class GUI:
def __init__(self):
self.wsControlLabels = []
self.wsControlLabels.append(settings.wireless_switch["ws_1_name"] + " On")
self.wsControlLabels.append(settings.wireless_switch["ws_1_name"] + " Off")
self.wsControlLabels.append(settings.wireless_switch["ws_2_name"] + " On")
self.wsControlLabels.append(settings.wireless_switch["ws_2_name"] + " Off")
self.wsControlLabels.append(settings.wireless_switch["ws_3_name"] + " On")
self.wsControlLabels.append(settings.wireless_switch["ws_3_name"] + " Off")
self.wsControlLabels.append("- - -")
self.wsControlLabels.append("Toggle Service on/off")
self.actions = Actions()
def toggleService(self):
settings.update_general()
if settings.general["service_enabled"]:
settings.set("service_enabled", "false")
else:
settings.set("service_enabled", "true")
settings.update_general()
def show(self):
## main loop ##
while True:
if settings.general["service_enabled"]:
self.wsControlLabels[7] = "Disable Service"
else:
self.wsControlLabels[7] = "Enable Service"
idx = Dialog().select(addonname, self.wsControlLabels)
xbmc.log(msg=self.wsControlLabels[idx], level=xbmc.LOGDEBUG)
if idx >= 0 and idx <= 5:
wsID = str(idx / 2 + 1)
powerState = "0"
if idx % 2 == 0:
powerState = "1"
self.actions.ws_control(wsID,powerState)
elif idx == 7:
self.toggleService()
elif idx == 8:
self.actions.start_settings_server()
elif idx == -1:
break
else:
break
sys.modules.clear()
示例2: __init__
# 需要导入模块: from actions import Actions [as 别名]
# 或者: from actions.Actions import ws_control [as 别名]
class Service:
def __init__(self):
self.monitor = CE_Monitor(self)
self.player = xbmc.Player()
self.actions = Actions()
self.blue = Bluetooth()
self.lightIsON=False
self.deviceFound=False
self.discoveryIsOn=False
self.delayToggle = 0
def run(self):
while not self.monitor.abortRequested():
waitForTime = 5
timeIntervalHit = True
if settings.general["use_time_interval"]:
startTime = settings.general["start_time"]
endTime = settings.general["end_time"]
currentTime = time.localtime()
if currentTime >= startTime and currentTime <= endTime:
timeIntervalHit = True
xbmc.log("ChyFy::service.py - Time Interval Hit", level=xbmc.LOGDEBUG)
else:
timeIntervalHit = False
xbmc.log("ChyFy::service.py - Current Time not in Time Interval", level=xbmc.LOGDEBUG)
if settings.general["service_enabled"] and timeIntervalHit:
self.startDiscovery()
waitForTime = settings.general["waiting_time"] + self.delayToggle
self.delayToggle = 0
else:
self.stopDiscovery()
#SleepTime in Minutes
waitForTime = settings.general["sleep_time"]
# Sleep/wait for abort for $waitForTime seconds
xbmc.log("ChyFy::service.py - Start waiting for %d seconds" % waitForTime, level=xbmc.LOGDEBUG)
if self.monitor.waitForAbort(waitForTime):
# Abort was requested while waiting. We should exit
break
xbmc.log("ChyFy::service.py - Run after wait", level=xbmc.LOGDEBUG)
if self.discoveryIsOn:
self.scan()
xbmc.log("ChyFy::service.py - discovery is on", level=xbmc.LOGDEBUG)
else:
xbmc.log("ChyFy::service.py - discovery is off", level=xbmc.LOGDEBUG)
def scan(self):
dbusDevices = self.blue.get_devices()
#Check if not None
if dbusDevices is not None:
deviceFound=False
rssiSensity = settings.general["rssi"]
#Get Devices
device_names = []
device_names.append(settings.bt_devices["bt_1_name"])
device_numbers = settings.bt_devices["bt_numbers"]
if device_numbers > 1:
for i in range(2,device_numbers):
device_names.append(settings.bt_devices["bt_"+i+"_name"])
for key in dbusDevices:
if 'Name' in dbusDevices[key]:
devName = dbusDevices[key]['Name']
devAddress = dbusDevices[key]['Address']
devRSSI = int(dbusDevices[key]['RSSI'])
xbmc.log("ChyFy::service.py - Device: %s -> %s (%s >= %s)" % (key, devName, devRSSI, rssiSensity), level=xbmc.LOGDEBUG)
if (devName in device_names or devAddress in device_names) and devRSSI >= rssiSensity:
xbmc.log("ChyFy::service.py - Device was found: %s" % devName, level=xbmc.LOGDEBUG)
deviceFound=True
break
if deviceFound:
self.handle_device_found()
else:
self.handle_device_notfound()
else:
xbmc.log("ChyFy::service.py - dbusDevices is None", level=xbmc.LOGERROR)
def handle_device_found(self):
if not self.lightIsON:
for i in range(1,4):
if settings.wireless_switch["ws_"+str(i)+"_auto_on"]:
self.actions.ws_control(str(i), "1")
if settings.media_control["mc_auto_play"] and not self.player.isPlaying():
self.player.pause()
self.delayToggle = 30
self.lightIsON=True
def handle_device_notfound(self):
if self.lightIsON:
for i in range(1,4):
if settings.wireless_switch["ws_"+str(i)+"_auto_off"]:
self.actions.ws_control(str(i), "0")
if settings.media_control["mc_auto_pause"] and self.player.isPlaying():
self.player.pause()
#.........这里部分代码省略.........