Skip to content

Commit 66cd7aa

Browse files
authored
Add text entity developer docs (#1536)
1 parent caf800d commit 66cd7aa

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/core/entity/text.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Text Entity
3+
sidebar_label: Text
4+
---
5+
6+
A text entity is an entity that allows the user to input a text value to an integration. Derive entity platforms from [`homeassistant.components.text.TextEntity`](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/components/text/__init__.py)
7+
8+
## Properties
9+
10+
:::tip
11+
Properties should always only return information from memory and not do I/O (like network requests). Implement `update()` or `async_update()` to fetch data or build a mechanism to push state updates to the entity class instance.
12+
:::
13+
14+
| Name | Type | Default | Description
15+
| ---- | ---- | ------- | -----------
16+
| mode | string | `text` | Defines how the text should be displayed in the UI. Can be `text` or `password`.
17+
| native_max | int | 100 | The maximum number of characters in the text value (inclusive).
18+
| native_min | int | 0 | The minimum number of characters in the text value (inclusive).
19+
| pattern | str | `None` | A regex pattern that the text value must match to be valid.
20+
| native_value | str | **Required** | The value of the text.
21+
22+
Other properties that are common to all entities such as `icon`, `name` etc are also applicable.
23+
24+
25+
## Methods
26+
27+
### Set value
28+
29+
```python
30+
class MyTextEntity(TextEntity):
31+
# Implement one of these methods.
32+
33+
def set_value(self, value: str) -> None:
34+
"""Set the text value."""
35+
36+
async def async_set_value(self, value: str) -> None:
37+
"""Set the text value."""
38+
```

0 commit comments

Comments
 (0)