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:

Interaction with virtual components

Virtual components are used to store/transfer data between scripts or runs, but they provide the possibility for the user to interact with them from the device's local home page. Each virtual group is added to the home page and is made up of cards. Each component has its own card with different inputs inside, based on the component's configuration.

Methods

Virtual.Add

Request

Properties:

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

Properties:

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