Skip to content

The Entity State tool

1.0.0 · Output

The Entity State tool displays the Home Assistant Entity State value and unit of measurement.

88 % 88 % 88 % 88

Basic usage

The Entity State tool needs a center position and the entity_index from which the state value is used.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
- type: 'state'             # tooltype is 'state'
  position:                 # Position on (100x100) canvas
    cx: 50                  # cx=50 is center position
    cy: 50                  # cy=50 is center position
  entity_index: 0           # connect to state of entity 0
  styles:
    state:
      font-size: 6em
    uom:
      opacity: 0.8

Advanced usage

The unit of measurement can be placed at the end (default), above (top), under (bottom) or not (none) alongside the state value.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
- type: 'state'             # tooltype is 'state'
  position:
    cx: 50
    cy: 50
  entity_index: 0
  show:
    uom: bottom             # default = end. Other top/bottom/none
  styles:
    state:
      font-size: 6em
    uom:
      opacity: 0.8

State, Attribute, Attribute lists and Secondary Info

The state tool can do more than just display the state value of an entity. An attribute, or attribute from an attribute list and secondary info can also be used by the state tool.

Displaying attributes

Nothing special, but of course attributes can be used for displaying the state of an entity.

views/view-sake8.yaml
1
2
3
4
5
6
7
8
entities:
  - entity: weather.tha_moon
    attribute: temperature
    decimals: 1
    unit: '°C'
    icon: mdi:thermometer
    area: 'Tha Moon'
    name: 'Temperature'

Displaying attributes from attribute list

In some cases, attributes are a list. This applies to the 5 day weather forecast for instance. By indexing the array, you can get the right attribute you want.

views/view-sake1.yaml
1
2
3
4
5
entities:
  - entity: weather.zoefdehaas
    attribute: forecast[0].temperature
    decimals: 1
    unit: '°C'

State converter options

2.5.1 · Experimental · BREAKING CHANGE

A state can have a predefined converter option. See The supported converter options.

State formatting options

2.5.1 · Experimental · BREAKING CHANGE

A state can have a format option. See The supported format options.

Displaying secondary info

Any entity can have secondary info. There is support for some of these attributes and formatting.

Depending on the secondary_info attribute type, the format can specify:

  • brightness for a brightness attribute
  • duration for a duration
  • relative, date, time, datetime for attribute types of last_updated/changed/triggered.
views/view-sake8.yaml
1
2
3
4
entities:
  - entity: weather.tha_moon
    secondary_info: last_updated  # last_updated, last_changed, last_triggered
    format: relative              # relative, date, time, datetime

Styling

The Entity State tool has support for the following forms of styling:

Method Support Description
classes Using SAK or User defined class definitions
styles Using inline SVG and CSS styles

The Entity State tool is composed of a two objects: "state" and "uom" as the selectors for styling:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
- type: 'state'
  position:
    cx: 50
    cy: 50
  entity_index: 0
  classes:
    state:                   # state value selector
      <...>
    uom:                     # state uom selector
      <...>
  styles:
    state:                   # state value selector
      <...>
    uom:                     # state uom selector
      <...>
Populair properties:

Property Does what? Example
font-size Font size font-size: 12em sets RELATIVE font size
text-anchor Anchor of text text-anchor: start or middle, or end
fill Fill color fill: red sets fill to color red
opacity Opacity (stroke/fill) opacity: 0.7 sets the opacity of text to 70%

Haptics

The tool supports haptic feedback through user_actions/ tap_action definition

Action Haptic Description
Click haptic Uses the haptic property defined in the user_actions definition of the tool. If not specified, a default of medium is used
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
  tools:
    - type: icon
      position:
        cx: 10
        cy: 10
        align: center
        icon_size: 15
      entity_index: 0
      user_actions:
        tap_action:
          haptic: success
          actions:
            - action: more-info

Possible values for haptic feedback:

Haptic Description
success Indicates that a task or action has completed.
warning Indicates that a task or action has produced a warning of some kind.
failure Indicates that a task or action has failed.
light Provides a physical metaphor that complements the visual experience.
medium Provides a physical metaphor that complements the visual experience.
heavy Provides a physical metaphor that complements the visual experience.
selection Indicates that the selection is actively changing.

Animations

The Entity State tool has support for the following forms of animations:

Method Support Description
colorstops List of state values to set the color
colorlists Using a colorlist definition
animations Operator state based animations with class/style styling