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 for Gen3 only.

Virtual components are a special set of components that do not exist in the device initially and are created dynamically by the user.

All virtual components use the general component interface, which means that they can be accessed using the standard methods <Component>.GetStatus, <Component>.GetConfig, and <Component>.SetConfig.

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

There is a limit of 10 instances per device. IDs for these components start from 200 and are limited to 299.

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. Required

config

object

Configuration to be used for the new component. Optional

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