Skip to main content
Version: 1.0

Virtual Components

caution

Available as preview since 1.1.0-beta3. The API is subject to change.

note

Available only for Gen3 and Gen2 Pro* devices.

Virtual components are a subset of dynamic components that allow the user to interact with scripts.

Creation and deletion of components is done through 2 methods from the Virtual namespace.

There is a limit of 10 instances per device.

A list with all virtual components can be fetched only by Shelly.GetComponents method.

Available virtual components:

Ownership and access​

Since version 2.0.0

Virtual components can be owned by a service or a script. Ownership metadata is not part of the component's configuration (<Type>.GetConfig), it is reported in the attrs object returned by Shelly.GetComponents:

PropertyTypeDescription

owner

string

Key of the owner, for example service:0 or script:1. Present only if the component has an owner.

access

string

Access permissions for everyone except the owner. Present if the component has an owner or if access is restricted. A combination of:

  • * — Full access (all operations).
  • C — Full config access (GetConfig and SetConfig).
  • c — Read-only config access (GetConfig only).
  • w — Write access (also implies read) — allows modifying the component's value.
  • r — Read-only access — allows reading the component's value.
  • m — Manage access — allows deleting the component with Virtual.Delete.

role

string

Role of the component within its owner. Present only if set.

Methods​

Virtual.Add​

Request​

Parameters:

PropertyTypeDescription

type

string

The type of virtual component to be created. Range of values: boolean, text, number, enum, group, button. Required

config

object

Configuration to be used for the new component. Optional

id

number

ID for the new component. Accepted range: [200..299]. Optional. If omitted, the first free ID will be used. If the desired ID is not available, an error will be returned.

Response​

The result from calling this method is a JSON object, with an id on success, otherwise it will return an error.

Received attributes:

PropertyTypeDescription

id

number

ID of the newly created component.

Virtual.Delete​

Request​

Parameters:

PropertyTypeDescription

key

string

Component key (in format <type>:<cid>, for example boolean:200). Required

Response​

The result from calling this method is null on success, otherwise it will return an error.

Examples​

Virtual.Add example​

http://192.168.33.1/rpc/Virtual.Add?type="boolean"

Response

{
"id": 200
}

Virtual.Delete example​

http://192.168.33.1/rpc/Virtual.Delete?key="boolean:200"

Response

null