PresenceZone
The PresenceZone is a component stands for an individual physical sensor and has the following methods:
PresenceZone.SetConfigto update the component's configurationPresenceZone.GetConfigto obtain the component's configurationPresenceZone.GetStatusto obtain the component's status
PresenceZone is a dynamic component
Methods
PresenceZone.SetConfig
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
| object | Configuration that the method takes |
Find more about the config properties in config section
PresenceZone.GetConfig
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
Find the PresenceZone.GetConfig response properties in config section
PresenceZone.GetStatus
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
Find more about the status response properties in status section
Configuration
The configuration of the PresenceZone component contains information for name, area size, preview color and enable. To Get/Set the configuration of the PresenceZone component its id must be specified.
Parameters:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
| string or null | Name of the component instance |
| boolean | Activate or deactivate zone |
| array of type int | Preview color defined in format [R, G, B] where every color element is within limit of 0 to 255 |
| number or null | Active period of presence before trigger (in seconds) |
| number or null | Active period of absence before trigger (in seconds) |
| array of type array | Zone area definition |
Zone Area
Zone area defines the grid cells of the zone. Every cell in grid is 0.5 meters by 0.5 meters. Every square shaped cells are grouped in segment with coordinates of starting point x0 , y0 and ending point x1, y1. The area can contains multiple segment definitions.
Example zone area with 3 segments:
- Segment 1 [x0, y0, x1, y1] : [2,0,0,2]
- Segment 2 [x0, y0, x1, y1] : [0,0,-2,3]
- Segment 3 [x0, y0, x1, y1] : [2,3,1,4]
area : [
[2,0,0,2],
[0,0,-2,3],
[2,3,1,4]
]
Status
The status of the PresenceZone component contains information about its id, state and objects located in zone. To obtain the status of the PresenceZone component its id must be specified.
Properties:
| Property | Type | Description |
|---|---|---|
| number | Id of the component instance |
| boolean | State of zone presence |
| number | Number of objects located in zone |
Webhook Events
Available events from PresenceZone component that can trigger webhooks:
presencezone.presence- produced when zone state is changed forpresence_delayorabsence_delayperiod.presencezone.presenceevent supports one attribute, that can be used to determine the state of zone and support conditional webhooks:Property Type Description stateboolean
State of presence in zone
presencezone.counter- produced on object in zone change event.presencezone.counterevent supports one attribute, that can be used to determine the number of objects in zone and support conditional webhooks:Property Type Description num_objectsnumber
Number of objects in zone
objectarray of type array
Location of objects. Every object is presented as array with
xandycoordinates.
presencezone.enter- produced when object enter into zone through zone border.presencezone.leave- produced when object leave zone through zone border.
Notifications
This section describes notifications for events specific to the PresenceZone component. For general information please see this page.
Instances of the PresenceZone component can send notifications for the following events:
presencecounterenterleave
Example for notification for event:
{"component":"presencezone:200","id":200,"event":"presence","state":true,"ts":1731931521.19}
state contains state of presence in zone.
{"component":"presencezone:200","id":200,"event":"counter","num_objects":2,"object": [[0.1, 1.55], [-1.59, 0.93]],"ts":1731931521.19}
num_objects contains number of objects detected in zone.
object contains coordinates of every object.
Examples
PresenceZone.SetConfig example
- PresenceZone.SetConfig HTTP GET Request
- PresenceZone.SetConfig Curl Request
- PresenceZone.SetConfig Mos Request
http://192.168.33.1/rpc/PresenceZone.SetConfig?id=200&config={"name":"Zone 1","enable":true,"color":[0,255,0],"area":[[-8,16,8,0]]}
curl -X POST -d '{"id":1,"method":"PresenceZone.SetConfig","params":{"id":200,"config":{"name":"Zone 1","enable":true,"color":[0,255,0],"area":[[-8,16,8,0]]}}}' http://${SHELLY}/rpc
mos --port ${PORT} call PresenceZone.SetConfig '{"id":200,"config":{"name":"Zone 1","enable":true,"color":[0,255,0],"area":[[-8,16,8,0]]}}'
Response
- PresenceZone.SetConfig HTTP GET Response
- PresenceZone.SetConfig Curl Response
- PresenceZone.SetConfig Mos Response
{
"restart_required": false
}
{
"id": 1,
"src": "presenceg4-84fce63fe000",
"params": {
"restart_required": false
}
}
{
"restart_required": false
}
PresenceZone.GetConfig example
- PresenceZone.GetConfig HTTP GET Request
- PresenceZone.GetConfig Curl Request
- PresenceZone.GetConfig Mos Request
http://192.168.33.1/rpc/PresenceZone.GetConfig?id=200
curl -X POST -d '{"id":1,"method":"PresenceZone.GetConfig","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call PresenceZone.GetConfig '{"id":200}'
Response
- PresenceZone.GetConfig HTTP GET Response
- PresenceZone.GetConfig Curl Response
- PresenceZone.GetConfig Mos Response
{
"id": 200,
"name": "Zone 1",
"enable": true,
"color": [
0,
255,
0
],
"area": [
[
-8,
16,
8,
0
]
]
}
{
"id": 1,
"src": "presenceg4-84fce63fe000",
"params": {
"id": 200,
"name": "Zone 1",
"enable": true,
"color": [
0,
255,
0
],
"area": [
[
-8,
16,
8,
0
]
]
}
}
{
"id": 200,
"name": "Zone 1",
"enable": true,
"color": [
0,
255,
0
],
"area": [
[
-8,
16,
8,
0
]
]
}
PresenceZone.GetStatus example
- PresenceZone.GetStatus HTTP GET Request
- PresenceZone.GetStatus Curl Request
- PresenceZone.GetStatus Mos Request
http://192.168.33.1/rpc/PresenceZone.GetStatus?id=200
curl -X POST -d '{"id":1,"method":"PresenceZone.GetStatus","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call PresenceZone.GetStatus '{"id":200}'
Response
- PresenceZone.GetStatus HTTP GET Response
- PresenceZone.GetStatus Curl Response
- PresenceZone.GetStatus Mos Response
{
"id": 200,
"state": false,
"num_objects": 0
}
{
"id": 1,
"src": "presenceg4-84fce63fe000",
"params": {
"id": 200,
"state": false,
"num_objects": 0
}
}
{
"id": 200,
"state": false,
"num_objects": 0
}
Events
presence example
{
"component": "presencezone:200",
"id": 200,
"event": "presence",
"state": true,
"ts": 1706593991.91
}
counter example
{
"component": "presencezone:200",
"id": 200,
"event": "counter",
"num_objects": 2,
"object": [
[0.1, 1.55],
[-1.59, 0.93]
],
"ts": 1706593991.91
}
In object propery first array [0.1, 1.55] means that first person is located on X: 0.1 meters and Y: 1.55 meters from presence sensor.
enter example
{
"component": "presencezone:200",
"id": 200,
"event": "enter",
"ts": 1706593991.91
}
leave example
{
"component": "presencezone:200",
"id": 200,
"event": "leave",
"ts": 1706593991.91
}