|  Developer
Updated on May 16, 2022

Discovery

Edit
Edit

Script name:

Edit
Field Type Required Description
script string + Value:
scriptParams.action string + Possible values: , ,
scriptParams.model string Possible values: ,
scriptParams.timeout int The number of seconds the script will remain in discovery mode. Default:
Edit

There are two possible ways to discover Ezviz cameras:

  1. Using UDP broadcast
  2. Using DHCP

The plugin script that handles the camera discovery is:

It has one mandatory parameter: action.

The possible values for the action parameter are:

  • udp_discovery : This makes the plugin send an UDP broadcast to find Ezviz cameras on the network.
  • start_dhcp_discovery : This puts the plugin in DHCP discovery mode. The plugin will listen to all DHCP request messages on the network, and if it finds an Ezviz camera, it will create a device for it.
  • stop_dhcp_discovery : This puts the plugin out of DHCP discovery mode; the plugin will stop listening to DHCP request messages.

After the plugin finds a camera and creates a device, it will broadcast this info to the websocket:

				
					{
    "id": "ui_broadcast",
    "msg_subclass": "hub.device.added",
    "result": {
        "_id": "5efda8a913f97f257a614db9",
        "batteryPowered": false,
        "category": "camera",
        "deviceTypeId": "ezviz_camera",
        "gatewayId": "5ef4c5baabd97f6ee8c55e5f",
        "info": {
            "firmware": "V5.2.7 build 200528",
            "mac": "44:47:cc:0d:df:03",
            "manufacturer": "Ezlo",
            "model": "VistaCam702",
            "serial_number": "85000001",
            "uuid": "e9b92ac0-df8d-11e9-91cd-273af3fa6fc6"
        },
        "name": "VistaCam702_85000001",
        "parentDeviceId": "",
        "reachable": true,
        "ready": true,
        "roomId": "",
        "security": "no",
        "serviceNotification": false,
        "status": "idle",
        "subcategory": "indoor_cam",
        "syncNotification": true,
        "type": "camera"
    }
}				
			
Edit

This is the preferred discovery method, as it has several advantages over the DHCP discovery method:

  1. It doesn’t require rebooting the camera.
  2. It’s faster.
  3. It’s more reliable.
  4. Sometimes the HUB freezes when DHCP discovery is enabled. To unfreeze the HUB, you have to reboot it.

Call the discovery script with .

You can filter which Ezviz camera model to add by passing in the model parameter.

Current valid values for model are:

  • VistaCam702
  • VistaCam1102

The model parameter is mandatory, because cameras with older firmware versions (a.k.a. the factory provisioned ones) don’t respond to UDP broadcasts that don’t contain the camera model.

The UDP broadcast discovery can be called in 2 modes:

1. Create mode (default)

In “create” mode, the script will scan for the first new camera with the specified model (or any Ezviz camera if the model is not specified), and add it as a device on the hub.

If no new camera is found, no device is created.

To call the script in “create” mode, set the “mode” parameter to “create“, or don’t set the “mode” parameter at all.

Examples

Add a VistaCam 702:

				
					{
   "method": "hub.extensions.plugin.run",
   "id": "_AUTO_370954",
   "params": {
      "script": "HUB:ezviz/scripts/discovery",
      "scriptParams": {
         "action": "udp_discovery",
         "model": "VistaCam702"
      }
   }
}				
			
2. Scan mode

In “scan” mode, the script will scan for cameras with the specified model (or any Ezviz camera if the model is not specified) and broadcast an array with the cameras found.

To call the script in “scan” mode, set the “mode” parameter to “scan:

Examples

Call UDP discovery in scan mode, for any camera model:

				
					{
    "method": "hub.extensions.plugin.run",
    "id": "_ID_",
    "params": {
        "script": "HUB:ezviz/scripts/discovery",
        "scriptParams": {
            "action": "udp_discovery",
            "mode": "scan"
        }
    }
}				
			
The broadcasted response looks like this:
				
					{
    "id": "ui_broadcast",
    "msg_subclass": "hub.extensions.plugin.ui_broadcast",
    "result": {
        "discovered_devices": [
            {
                "device_name": "VistaCam 702",
                "ip": "192.168.87.29",
                "mac": "44:47:cc:0d:df:03",
                "model": "VistaCam702",
                "serial": "85000001",
                "ssid": "VistaCam702_85000001"
            },
            {
                "device_name": "VistaCam 1200",
                "ip": "192.168.87.26",
                "mac": "80:91:33:d1:97:71",
                "model": "VistaCam1200",
                "serial": "12345678",
                "ssid": "VistaCam1200_12345678"
            }
        ],
        "plugin": "ezviz"
    }
}
				
			

In “*scan” mode the device is not created automatically. You must create the device yourself.*


To create a device, call , passing as parameters the device information from the broadcasted response:

				
					{
   "method": "hub.extensions.plugin.run",
   "id": "_ID_",
   "params": {
      "script": "HUB:ezviz/scripts/create_device",
      "scriptParams": {
            "device_name": "VistaCam 702",
            "ip": "192.168.87.29",
            "mac": "44:47:cc:0d:df:03",
            "model": "VistaCam702",
            "serial": "85000001",
            "ssid": "VistaCam702_85000001"
        }
    }
}				
			
Edit

Please use the UDP broadcast discovery method if possible!


Call the discovery script with .

You can filter which Ezviz camera model to add by passing in the model parameter.

Current valid values for model are:

  • VistaCam702
  • VistaCam1102

By default, the script remains in discovery mode for 30 seconds.

You can change how much the script remains in discovery mode by passing in the timeout parameter.

The value must be an integer number representing the number of seconds the script will remain in discovery mode.

To remove the script from discovery mode manually, call the discovery script with .

Examples

Add any camera model and set the timeout to 1 minute:

				
					{
    "method": "hub.extensions.plugin.run",
    "id": "_AUTO_370954",
    "params": {
        "script": "HUB:ezviz/scripts/discovery",
        "scriptParams": {
            "action": "start_dhcp_discovery",
            "timeout": 60
        }
    }
}				
			

Add a VistaCam 702:

				
					{
    "method": "hub.extensions.plugin.run",
    "id": "_AUTO_370954",
    "params": {
        "script": "HUB:ezviz/scripts/discovery",
        "scriptParams": {
            "action": "start_dhcp_discovery",
            "model: "VistaCam702"
        }
    }
}