Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Select Entity

[!NOTE] The Home Assistant integration is used as the first reference implementation.

The select entity offers a limited set of selectable options. The available options are defined by the integration driver. They can be a static list or dynamically generated and changed at runtime.

Features

The select entity has no features.

Attributes

AttributeTypeValuesDescription
stateenumStatesOptional state of the select entity.
current_optionstringThe currently selected option.
optionslisttextThe available options to choose from.

States

The state attribute is optional for a select entity and defaults to ON if not specified.

The select entity only supports the ON state and the common entity states.

ValueDescription
ONThe selection is available.

Device Classes

None.

Options

None.

Integration API

Commands

The integration driver has to implement a handler for the entity_command message to process the following command requests in msg_data.cmd_id.

cmd_idParametersDescription
select_optionoptionSelect a specific option. The option parameter must be one of the values in the options attribute.
select_first-Select the first option in the list.
select_last-Select the last option in the list.
select_nextcycleSelect the next option in the list. If cycle is true, it wraps around to the first option.
select_previouscycleSelect the previous option in the list. If cycle is true, it wraps around to the last option.

Events

The entity_change event must be emitted by the integration driver if the state or an attribute of the select entity changes.

The following attributes are supported:

AttributeDescription
stateNew entity state.
current_optionCurrently selected option changed.
optionsAvailable options changed.

At least one attribute must be specified in the entity_change message. If the entity state and a select-entity attribute changed at the same time, they may both be included in the same message. It's also valid to always send every attribute.

Command examples

select_option

{
  "kind": "req",
  "id": 124,
  "msg": "entity_command",
  "msg_data": {
    "entity_type": "select",
    "entity_id": "select-1",
    "cmd_id": "select_option",
    "params": {
      "option": "foobar"
    }
  }
}

select_first

{
  "kind": "req",
  "id": 124,
  "msg": "entity_command",
  "msg_data": {
    "entity_type": "select",
    "entity_id": "select-1",
    "cmd_id": "select_first"
  }
}

select_last

{
  "kind": "req",
  "id": 124,
  "msg": "entity_command",
  "msg_data": {
    "entity_type": "select",
    "entity_id": "select-1",
    "cmd_id": "select_last"
  }
}

select_next

{
  "kind": "req",
  "id": 124,
  "msg": "entity_command",
  "msg_data": {
    "entity_type": "select",
    "entity_id": "select-1",
    "cmd_id": "select_next",
    "params": {
      "cycle": true
    }
  }
}

select_previous

{
  "kind": "req",
  "id": 124,
  "msg": "entity_command",
  "msg_data": {
    "entity_type": "select",
    "entity_id": "select-1",
    "cmd_id": "select_previous",
    "params": {
      "cycle": false
    }
  }
}

Event examples

Option changed

{
  "kind": "event",
  "msg": "entity_change",
  "cat": "ENTITY",
  "msg_data": {
    "entity_type": "select",
    "entity_id": "select-1",
    "attributes": {
      "current_option": "Foobar"
    }
  }
}

Options list and current option changed

{
  "kind": "event",
  "msg": "entity_change",
  "cat": "ENTITY",
  "msg_data": {
    "entity_type": "select",
    "entity_id": "select-1",
    "attributes": {
      "options": ["Foo", "Bar", "Foobar"],
      "current_option": "Bar"
    }
  }
}