Skip to main content
Version: 1.0

Enum

The virtual Enum component is used to store a set of constant values. It uses Enum as RPC namespace and has the following methods:

Methods

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

Enum.GetConfig

Properties:

PropertyTypeDescription

id

number

Id of the component instance

Find the Enum.GetConfig response properties in config section

Enum.GetStatus

Properties:

PropertyTypeDescription

id

number

Id of the component instance

Find more about the status response properties in status section

Enum.Set

This method updates the value of the Enum component. It can be used to trigger webhooks. More information about the events triggering webhooks available for this component can be found below.

Request

Parameters:

PropertyTypeDescription

id

number

Id of the component instance. Required

value

string or null

One of the items from options or null Required

Configuration

The configuration of the Enum 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 Enum component its id must be specified.

Properties:

PropertyTypeDescription

id

number

Id of the component instance

name

string or null

Name of the component instance

persisted

boolean

true for the value to be persist, default false

default_value

object or null

Option selected on reboot if persisted is set to false

options

array of options objects

Values that can be set for this enum instance Required

meta

object

Object for storing meta data

ui

object

Properties of how the component will be rendered in the UI

PropertyTypeDescription

view

string

Specifies the type of card used for showing the component. Supported values: "" (empty string), dropdown, label.

titles

object

Allows defining custom titles for each option in format (option: title).

images

object

Allows defining custom images for each option in format (option: image url). Only for view=label.

icon

string or null

Allows setting custom icon for the component's card by providing an external hosted image via link.

info
  • "" (empty string): The component does not have a card;
  • "dropdown": Card with a dropdown field;
  • "label": Card showing an image if defined, otherwise the title.

Status

The status of the Enum 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 Enum component its id must be specified.

Properties:

PropertyTypeDescription

source

string

Source of the last command

value

string or null

One of the items from options or null

last_update_ts

number

Unix timestamp for the value update

Webhook Events

Currently, there is one event related to the Enum component that can trigger webhooks:

  • enum.change - produced when the value changes.

Examples

Enum.SetConfig example

http://192.168.33.1/rpc/Enum.SetConfig?id=200&config={"name":"Light to toggle","options":["kitchen_light","bedroom_light","bathroom_light","entrance_light"],"meta":{"ui":{"titles":{"kitchen_light":"Kitchen light","bedroom_light":"Bedroom light","bathroom_light":"Bathroom light","entrance_light":"Entrance light"}}}}

Response

{
"restart_required": false
}

Enum.GetConfig example

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

Response

{
"id": 200,
"name": "",
"options": [
"kitchen_light",
"bedroom_light",
"bathroom_light",
"entrance_light"
],
"meta": {
"ui": {
"view": "",
"titles": {
"kitchen_light": "Kitchen light",
"bedroom_light": "Bedroom light",
"bathroom_light": "Bathroom light",
"entrance_light": "Entrance light"
},
"icon": "",
"images": {}
}
},
"persisted": true,
"default_value": "kitchen_light"
}

Enum.GetStatus example

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

Response

{
"value": "kitchen_light",
"source": "rpc",
"last_update_ts": 1700864253
}

Enum.Set example

http://192.168.33.1/rpc/Enum.Set?id=200&value="kitchen_light"

Response

null