CameraZone
The CameraZone component represents a user-defined area within the camera's field of view. Depending on its type, a zone is used either for motion detection or for blacking out the area in the video feed (privacy). It has the following methods:
CameraZone.SetConfigto update the component's configurationCameraZone.GetConfigto obtain the component's configurationCameraZone.GetStatusto obtain the component's status
CameraZone is a dynamic component. Instances are created via Camera.AddZone and removed via Camera.DeleteZone.
A default CameraZone covering the full frame is created automatically when the camera is initialized. The default zone cannot be deleted.
Coordinate System
The coordinates property uses a normalized grid rather than absolute pixels. Both the X (horizontal) and Y (vertical) axes range from 0 to 10000.
This abstraction ensures that zone definitions remain accurate and persistent even if the camera's stream resolution or aspect ratio changes (e.g., switching from High Definition to Standard Definition).
(0, 0): Top-Left corner of the frame.(10000, 0): Top-Right corner.(0, 10000): Bottom-Left corner.(10000, 10000): Bottom-Right corner.(5000, 5000): Exact center of the frame.
To convert a pixel coordinate to this format, use the following formula:
Val = (Pixel_Position / Total_Resolution_Dimension) * 10000
Methods
CameraZone.SetConfig
Update the configuration of a specific zone instance. Only the fields included in the request are modified; omitted fields are left unchanged.
Properties:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
| object | Configuration to apply (see the configuration section) |
CameraZone.GetConfig
Obtain the configuration of a specific zone instance.
Properties:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
See the configuration section for the response shape.
CameraZone.GetStatus
Obtain the status of a specific zone instance.
Properties:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
See the status section for the response shape.
Configuration
The configuration of the CameraZone component describes the zone's shape (coordinates), its purpose (type) and optional visual properties.
Properties:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
| boolean | Activate or deactivate zone processing. |
| string | Zone type. See accepted values. |
| array of numbers | Polygon coordinates in the format |
| array of numbers | Optional. Preview color in the format |
| string | Optional. Human-readable zone name. |
null is not accepted for enable, type, coordinates, color or name. To remove an optional value, omit the field from the request.
| Value | Description |
|---|---|
| Motion-detection zone. Motion events inside the zone are reported via webhooks and notifications, and contribute to the camera's overall |
| Privacy zone. The area is blacked out in all video streams; the zone never reports motion. |
Status
Properties:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance. |
| boolean |
|
Webhook Events
Available events from CameraZone component that can trigger webhooks (motion zones only):
camerazone.motion- produced when the motion status for this specific zone instance changes totrue.camerazone.motion_end- produced when the motion status for this specific zone instance changes tofalse.
Examples
CameraZone.SetConfig example
- CameraZone.SetConfig HTTP GET Request
- CameraZone.SetConfig Curl Request
- CameraZone.SetConfig Mos Request
http://192.168.33.1/rpc/CameraZone.SetConfig?id=200&config={"name":"Entrance","enable":true,"type":"motion","coordinates":[1000,2000,5000,2000,5000,8000,1000,8000],"color":[255,0,0]}
curl -X POST -d '{"id":1,"method":"CameraZone.SetConfig","params":{"id":200,"config":{"name":"Entrance","enable":true,"type":"motion","coordinates":[1000,2000,5000,2000,5000,8000,1000,8000],"color":[255,0,0]}}}' http://${SHELLY}/rpc
mos --port ${PORT} call CameraZone.SetConfig '{"id":200,"config":{"name":"Entrance","enable":true,"type":"motion","coordinates":[1000,2000,5000,2000,5000,8000,1000,8000],"color":[255,0,0]}}'
Response
- CameraZone.SetConfig HTTP GET Response
- CameraZone.SetConfig Curl Response
- CameraZone.SetConfig Mos Response
{
"restart_required": false
}
{
"id": 1,
"src": "shellycamera-xxx",
"params": {
"restart_required": false
}
}
{
"restart_required": false
}
CameraZone.GetConfig example
- CameraZone.GetConfig HTTP GET Request
- CameraZone.GetConfig Curl Request
- CameraZone.GetConfig Mos Request
http://192.168.33.1/rpc/CameraZone.GetConfig?id=200
curl -X POST -d '{"id":1,"method":"CameraZone.GetConfig","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call CameraZone.GetConfig '{"id":200}'
Response
- CameraZone.GetConfig HTTP GET Response
- CameraZone.GetConfig Curl Response
- CameraZone.GetConfig Mos Response
{
"id": 200,
"coordinates": [
1000,
2000,
5000,
2000,
5000,
8000,
1000,
8000
],
"enable": true,
"type": "motion",
"name": "Entrance",
"color": [
255,
0,
0
]
}
{
"id": 1,
"src": "shellycamera-xxx",
"params": {
"id": 200,
"coordinates": [
1000,
2000,
5000,
2000,
5000,
8000,
1000,
8000
],
"enable": true,
"type": "motion",
"name": "Entrance",
"color": [
255,
0,
0
]
}
}
{
"id": 200,
"coordinates": [
1000,
2000,
5000,
2000,
5000,
8000,
1000,
8000
],
"enable": true,
"type": "motion",
"name": "Entrance",
"color": [
255,
0,
0
]
}
CameraZone.GetStatus example
- CameraZone.GetStatus HTTP GET Request
- CameraZone.GetStatus Curl Request
- CameraZone.GetStatus Mos Request
http://192.168.33.1/rpc/CameraZone.GetStatus?id=200
curl -X POST -d '{"id":1,"method":"CameraZone.GetStatus","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call CameraZone.GetStatus '{"id":200}'
Response
- CameraZone.GetStatus HTTP GET Response
- CameraZone.GetStatus Curl Response
- CameraZone.GetStatus Mos Response
{
"id": 200,
"motion": true
}
{
"id": 1,
"src": "shellycamera-xxx",
"params": {
"id": 200,
"motion": true
}
}
{
"id": 200,
"motion": true
}