Skip to main content
Version: 1.0

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:

Methods

Group.SetConfig

PropertyTypeDescription

id

number

Id of the component instance

config

object

Configuration that the method takes

Find more about the config properties in config section

Group.GetConfig

Properties:

PropertyTypeDescription

id

number

Id of the component instance

Find the Group.GetConfig response properties in config section

Group.GetStatus

Properties:

PropertyTypeDescription

id

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:

PropertyTypeDescription

id

number

Id of the component instance. Required

value

array of strings

List of valid components keys (in format <type>:<cid>, e.g. boolean:200) Required

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:

PropertyTypeDescription

id

number

Id of the component instance

name

string or null

Name of the component instance

meta

object

Object for storing meta data

ui

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:

PropertyTypeDescription

source

string

Source of the last command

value

array of strings

List of valid components keys (in format <type>:<cid>, e.g. boolean:200)

last_update_ts

number

Unix timestamp for the value update

Automatically generated script

caution

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:

  • on(event, callback) -> undefined

    Execute functions based on events or value changes.
PropertyTypeDescription

event

string

Event name or 'value_change' for virtual components

callback

function

Function to execute when the specified event occurs

note

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

http://192.168.33.1/rpc/Group.SetConfig?id=200&config={"name":"Thermostat"}

Response

{
"restart_required": false
}

Group.GetConfig example

http://192.168.33.1/rpc/Group.GetConfig?id=200

Response

{
"id": 200,
"name": "Thermostat"
}

Group.GetStatus example

http://192.168.33.1/rpc/Group.GetStatus?id=200

Response

{
"value": [
"boolean:200",
"enum:200"
],
"source": "rpc",
"last_update_ts": 1700864253
}

Group.Set example

http://192.168.33.1/rpc/Group.Set?id=200&value=["boolean:200","enum:200"]

Response

null

Automatically generated script example

Event from virtual button
Button200.on(
"single_push",
function(value) {
console.log("The button was pushed")
}
);
Event from virtual number
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");
}
}
);