Is the Nx Cloud up? Visit our Status Page for the current health and performance of the Nx Cloud.

Status Page

Enable/disable plugin and change its settings via HTTP Api

Answered

Comments

4 comments

  • Andrey Terentyev
    • Network Optix team

    Hello Hendrick,

    Please, see this thread for the solution

    https://support.networkoptix.com/hc/en-us/community/posts/360049107474-How-to-disable-the-plugin-through-the-Metadata-SDK

    0
  • Hendrik Baekeland
    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
  • Andrey Terentyev
    • Network Optix team

    Hello Hendrik Baekeland,

    The recommended way for getting/changing plugin settings is utilizing the followoing API

    GET /ec2/deviceAnalyticsSettings
    POST /ec2/deviceAnalyticsSettings

     

    0
  • Hendrik Baekeland

    Thanks, Andrey.

    0

Please sign in to leave a comment.