Enable/disable plugin and change its settings via HTTP Api
AnsweredI want to test my plugin on dozens of cameras.
Is there a program way to change the plugin's settings and turn it on and off?
-
Hello Hendrick,
Please, see this thread for the solution
0 -
import json
import requests
import typing
USERNAME = "user"
PASSWORD = "pass"
SERVER_IP = "localhost"
SERVER_PORT = 7001
SERVER_URL = F"https://{USERNAME}:{PASSWORD}@{SERVER_IP}:{SERVER_PORT}"
SET_RESOURCES_STR=F"{SERVER_URL}/ec2/setResourceParams"
GET_ALL_PLUGINS_STR=F"{SERVER_URL}/ec2/getAnalyticsEngines"
def get_plugin_id(plugin_name:str):
resp = requests.get(GET_ALL_PLUGINS_STR, verify=False)
resp_json = resp.json()
res = next(filter(lambda x: plugin_name in x['name'], resp_json ))
return res['id']
def change_plugin_settings(camera_id:str, plugin_id:str, settings:dict):
plugin_settings = {'key':plugin_id,
'value':settings
}
plugin_settings = json.dumps(plugin_settings)
query_params = [
{'name': "deviceAgentsSettingsValuesProperty",
'value': plugin_settings,
'resourceId': camera_id }
]
resp = requests.post(SET_RESOURCES_STR,
json=query_params,
verify=False)
print(resp)
if __name__ == "__main__":
camera_id = "3ce36e62-7416-4f42-0339-0adca55a9091"
plugin_id = get_plugin_id("pluginName")
#include all plugins params in the settings dict
settings = {'param1':False,
'param2':True,
'param3':0.88 }
change_plugin_settings(camera_id, plugin_id, settings)Hello Andrey,
Thanks for your help.
I was able to enable/disable plugins. However, is it possible to change plugin's settings? I've tried the above code, and it doesn't work. Nx returns 200 on any settings combination but doesn't change settings.
Could you please help me with this issue?0 -
Hello Hendrik Baekeland,
The recommended way for getting/changing plugin settings is utilizing the followoing API
GET /ec2/deviceAnalyticsSettings
POST /ec2/deviceAnalyticsSettings0 -
Thanks, Andrey.
0
Please sign in to leave a comment.
Comments
4 comments