Skip to content

Commit 89846dc

Browse files
committed
Clarify state attributes rules for entity
1 parent 3bfd684 commit 89846dc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/core/entity.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@ The following properties are also available on entities. However, they are for a
119119
| state_attributes | <code>dict &#124; None</code> | `None` | State attributes of a base domain. This property is implemented by the domain base entity and should not be implemented by integrations.
120120
| unit_of_measurement | <code>str &#124; None</code> | The unit of measurement that the entity's state is expressed in. In most cases, for example for the `number` and `sensor` domains, this is implemented by the domain base entity and should not be implemented by integrations.
121121

122+
## State attributes
123+
124+
Entities can provide additional state attributes besides the built-in ones, to provide further details to it's state.
125+
This should be done by providing a dictionary with keys and values to the `extra_state_attributes` property.
126+
127+
Providing additional state attributes comes with some rules:
128+
129+
- If an attribute is expected, it should be in the dictionary. Attributes should not "come and go".
130+
- If an attribute is expected, but it's not providing a value right now, its value should be `None` and remain in the dictionary
131+
- If an attributes is not expected, it should not be in the dictionary. As example, only some attributes might provide additional context to the state when the entity runs with a certain configuration.
132+
122133
## System properties
123134

124135
The following properties are used and controlled by Home Assistant, and should not be overridden by integrations.

0 commit comments

Comments
 (0)