本文整理匯總了Python中domogik.common.database.DbHelper.update_actuator_feature_model方法的典型用法代碼示例。如果您正苦於以下問題:Python DbHelper.update_actuator_feature_model方法的具體用法?Python DbHelper.update_actuator_feature_model怎麽用?Python DbHelper.update_actuator_feature_model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類domogik.common.database.DbHelper
的用法示例。
在下文中一共展示了DbHelper.update_actuator_feature_model方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PackageData
# 需要導入模塊: from domogik.common.database import DbHelper [as 別名]
# 或者: from domogik.common.database.DbHelper import update_actuator_feature_model [as 別名]
class PackageData():
""" Tool to insert necessary data in database
"""
def __init__(self, json_path):
""" Init tool
@param plugin_name : plugin name
"""
self._db = DbHelper()
try:
self.pkg = PackageJson(path = json_path).json
except:
print(str(traceback.format_exc()))
return
print("Json file OK")
# check type == plugin
if self.pkg["identity"]["type"] not in ["plugin", "external"]:
print("Error : this package type is not recognized")
exit()
def insert(self):
""" Insert data for plugin
"""
### Technology
print("Technology %s" % self.pkg["technology"]["id"])
if self._db.get_device_technology_by_id(self.pkg["technology"]["id"]) == None:
# add if not exists
print("add...")
self._db.add_device_technology(self.pkg["technology"]["id"],
self.pkg["technology"]["name"],
self.pkg["technology"]["description"])
else:
# update if exists
print("update...")
self._db.update_device_technology(self.pkg["technology"]["id"],
self.pkg["technology"]["name"],
self.pkg["technology"]["description"])
### Device types
for device_type in self.pkg["device_types"]:
print("Device type %s" % device_type["id"])
if self._db.get_device_type_by_id(device_type["id"]) == None:
# add if not exists
print("add...")
self._db.add_device_type(device_type["id"],
device_type["name"],
self.pkg["technology"]["id"],
device_type["description"])
else:
# update if exists
print("update...")
self._db.update_device_type(device_type["id"],
device_type["name"],
self.pkg["technology"]["id"],
device_type["description"])
### Device feature model
for device_feature_model in self.pkg["device_feature_models"]:
print("Device feature model %s" % device_feature_model["id"])
print("M.P=%s" % device_feature_model["parameters"])
if self._db.get_device_feature_model_by_id(device_feature_model["id"]) == None:
# add if not exists
print("add...")
if device_feature_model["feature_type"] == "sensor":
self._db.add_sensor_feature_model(device_feature_model["id"],
device_feature_model["name"],
device_feature_model["device_type_id"],
device_feature_model["value_type"],
device_feature_model["parameters"],
device_feature_model["stat_key"])
elif device_feature_model["feature_type"] == "actuator":
self._db.add_actuator_feature_model(device_feature_model["id"],
device_feature_model["name"],
device_feature_model["device_type_id"],
device_feature_model["value_type"],
device_feature_model["return_confirmation"],
device_feature_model["parameters"],
device_feature_model["stat_key"])
else:
# update if exists
print("update...")
if device_feature_model["feature_type"] == "sensor":
self._db.update_sensor_feature_model(device_feature_model["id"],
device_feature_model["name"],
device_feature_model["parameters"],
device_feature_model["value_type"],
device_feature_model["stat_key"])
elif device_feature_model["feature_type"] == "actuator":
self._db.update_actuator_feature_model(device_feature_model["id"],
device_feature_model["name"],
device_feature_model["parameters"],
device_feature_model["value_type"],
device_feature_model["return_confirmation"],
device_feature_model["stat_key"])