本文整理汇总了Python中entities.Entity.control方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.control方法的具体用法?Python Entity.control怎么用?Python Entity.control使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entities.Entity
的用法示例。
在下文中一共展示了Entity.control方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: control
# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import control [as 别名]
def control(self, controller, command, value=None):
if command.id == COMMAND_ON.id:
controller.send_message(self.unique_id, [ chr(0x00), chr(0x01) ])
self.log_command('Turning the power on')
return
elif command.id == COMMAND_OFF.id:
controller.send_message(self.unique_id, [ chr(0x00), chr(0x00) ])
self.log_command('Turning the power off')
return
Entity.control(self, command, value=value)
示例2: control
# 需要导入模块: from entities import Entity [as 别名]
# 或者: from entities.Entity import control [as 别名]
def control(self, controller, command, value=None):
if command.id == COMMAND_LIGHT_LEVEL.id:
if value is not None:
msg = [ chr(0x00), chr(0x02), chr(int(round((int(value) * 255) / 100))) ]
controller.send_message(self.unique_id, msg)
self.log_command('Setting light level to ' + str(value))
return
elif command.id == COMMAND_ON.id:
controller.send_message(self.unique_id, [ chr(0x00), chr(0x01) ])
self.log_command('Turning the light on')
return
elif command.id == COMMAND_OFF.id:
controller.send_message(self.unique_id, [ chr(0x00), chr(0x00) ])
self.log_command('Turning the light off')
return
Entity.control(self, command, value=value)