本文整理汇总了Python中sensor.Sensor.add_action方法的典型用法代码示例。如果您正苦于以下问题:Python Sensor.add_action方法的具体用法?Python Sensor.add_action怎么用?Python Sensor.add_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sensor.Sensor
的用法示例。
在下文中一共展示了Sensor.add_action方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_sensors
# 需要导入模块: from sensor import Sensor [as 别名]
# 或者: from sensor.Sensor import add_action [as 别名]
def load_sensors(self):
if "sensors" not in config:
print("can not find the sensors segment in setting.cfg")
return
all_sensors = config["sensors"]
for sensor_id in all_sensors:
if sensor_id not in self.__sensors__:
sensor_object = all_sensors[sensor_id]
if "kind" in sensor_object:
sensor_object_kind = sensor_object["kind"]
if sensor_object_kind in self.__models__:
new_sensor = SensorLogic.copy_with_info(self.__models__[sensor_object_kind], sensor_id, sensor_object["name"])
self.__sensors__[sensor_id] = new_sensor
else:
new_sensor = Sensor(sensor_object_kind, sensor_id, sensor_object["name"])
if sensor_object["type"] is "action":
on_action = SAction("on")
off_action = SAction("off")
new_sensor.add_action(on_action)
new_sensor.add_action(off_action)
else:
value_property = SProperty("value", 0, None, 0)
new_sensor.add_property(value_property)
self.__sensors__[sensor_id] = new_sensor
else:
print("{0:s} sensor in setting.cfg lost kind property".format(sensor_id))