Group
The virtual Group
component is used to store a list of components keys. It uses Group
as RPC namespace and has the following methods:
Group.SetConfig
to update the component's configurationGroup.GetConfig
to obtain the component's configurationGroup.GetStatus
to obtain the component's statusGroup.Set
to update the component's value
Methods
Group.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
Group.GetConfig
Properties:
Property | Type | Description |
---|---|---|
| number | Id of the component instance |
Find the Group.GetConfig response properties in config section
Group.GetStatus
Properties:
Property | Type | Description |
---|---|---|
| number | Id of the component instance |
Find more about the status response properties in status section
Group.Set
This method updates the value of the Group component.
Request
Parameters:
Property | Type | Description |
---|---|---|
| number | Id of the component instance. Required |
| array of strings | List of valid components keys (in format |
Configuration
The configuration of the Group component contains information about the default value, whether it should persist after reboot,
and properties of how it will be rendered in the UI. To Get/Set the configuration of the Group component its id
must be specified.
Properties:
Property | Type | Description | |||
---|---|---|---|---|---|
| number | Id of the component instance | |||
| string or null | Name of the component instance | |||
| object | Object for storing meta data |
| object | Properties of how the component will be rendered in the UI |
Status
The status of the Group component contains information about its current value, the timestamp for the value update, and the source of the last command. To obtain the status of the Group component its id
must be specified.
Properties:
Property | Type | Description |
---|---|---|
| string | Source of the last command |
| array of strings | List of valid components keys (in format |
| number | Unix timestamp for the value update |
Automatically generated script
Available as preview since 1.3.0-beta1
. The API is subject to change.
The local web interface has the capability to generate a script, facilitating easy interaction with virtual components within the group. The script has a region called AutoGeneratedCode
which is overwritten automatically whenever changes are saved within the local interface.
Each component within the group is represented in the script by an object with the same name as the component. By default, the naming convention is: component type + its id (e.g., Boolean200). Every component object supports the following methods:
Execute functions based on events or value changes.on(event, callback) -> undefined
Property | Type | Description |
---|---|---|
| string | Event name or 'value_change' for virtual components |
| function | Function to execute when the specified event occurs |
The value_change
event is a special internal event emitted by the script and is not exposed externally.
Find examples at Automatically generated script section.
Examples
Group.SetConfig example
- Group.SetConfig HTTP GET Request
- Group.SetConfig Curl Request
- Group.SetConfig Mos Request
http://192.168.33.1/rpc/Group.SetConfig?id=200&config={"name":"Thermostat"}
curl -X POST -d '{"id":1,"method":"Group.SetConfig","params":{"id":200,"config":{"name":"Thermostat"}}}' http://${SHELLY}/rpc
mos --port ${PORT} call Group.SetConfig '{"id":200,"config":{"name":"Thermostat"}}'
Response
- Group.SetConfig HTTP GET Response
- Group.SetConfig Curl Response
- Group.SetConfig Mos Response
{
"restart_required": false
}
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": {
"restart_required": false
}
}
{
"restart_required": false
}
Group.GetConfig example
- Group.GetConfig HTTP GET Request
- Group.GetConfig Curl Request
- Group.GetConfig Mos Request
http://192.168.33.1/rpc/Group.GetConfig?id=200
curl -X POST -d '{"id":1,"method":"Group.GetConfig","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call Group.GetConfig '{"id":200}'
Response
- Group.GetConfig HTTP GET Response
- Group.GetConfig Curl Response
- Group.GetConfig Mos Response
{
"id": 200,
"name": "Thermostat"
}
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": {
"id": 200,
"name": "Thermostat"
}
}
{
"id": 200,
"name": "Thermostat"
}
Group.GetStatus example
- Group.GetStatus HTTP GET Request
- Group.GetStatus Curl Request
- Group.GetStatus Mos Request
http://192.168.33.1/rpc/Group.GetStatus?id=200
curl -X POST -d '{"id":1,"method":"Group.GetStatus","params":{"id":200}}' http://${SHELLY}/rpc
mos --port ${PORT} call Group.GetStatus '{"id":200}'
Response
- Group.GetStatus HTTP GET Response
- Group.GetStatus Curl Response
- Group.GetStatus Mos Response
{
"value": [
"boolean:200",
"enum:200"
],
"source": "rpc",
"last_update_ts": 1700864253
}
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": {
"value": [
"boolean:200",
"enum:200"
],
"source": "rpc",
"last_update_ts": 1700864253
}
}
{
"value": [
"boolean:200",
"enum:200"
],
"source": "rpc",
"last_update_ts": 1700864253
}
Group.Set example
- Group.Set HTTP GET Request
- Group.Set Curl Request
- Group.Set Mos Request
http://192.168.33.1/rpc/Group.Set?id=200&value=["boolean:200","enum:200"]
curl -X POST -d '{"id":1,"method":"Group.Set","params":{"id":200,"value":["boolean:200","enum:200"]}}' http://${SHELLY}/rpc
mos --port ${PORT} call Group.Set '{"id":200,"value":["boolean:200","enum:200"]}'
Response
- Group.Set HTTP GET Response
- Group.Set Curl Response
- Group.Set Mos Response
null
{
"id": 1,
"src": "shelly1pmminig3-84fce63fe000",
"params": null
}
null
Automatically generated script example
Button200.on(
"single_push",
function(value) {
console.log("The button was pushed")
}
);
Number200.on(
"value_change",
function(value) {
if (value > 20) {
console.log("The value is greater than 20");
}
else {
console.log("The value is less than 20");
}
}
);