home-assistant.io/source/_components/input_text.markdown
DubhAd 26a3643f10 We didn't document the services (#8147)
Adding documentation on how to use the services. Actually, adding documentation on _what_ the service is ;)
2019-01-13 11:41:55 +01:00

120 lines
3.3 KiB
Markdown

---
layout: page
title: "Input Text"
description: "Instructions on how to integrate the Input Text component into Home Assistant."
date: 2016-03-15 06:00
sidebar: true
comments: false
sharing: true
footer: true
logo: home-assistant.png
ha_category: Automation
ha_release: 0.53
ha_qa_scale: internal
---
The `input_text` component allows the user to define values that can be controlled via the frontend and can be used within conditions of automation. Changes to the value stored in the text box generate state events. These state events can be utilized as `automation` triggers as well. It can also be configured in password mode (obscured text).
```yaml
# Example configuration.yaml entries
input_text:
text1:
name: Text 1
initial: Some Text
text2:
name: Text 2
min: 8
max: 40
text3:
name: Text 3
pattern: '[a-fA-F0-9]*'
text4:
name: Text 4
mode: password
```
{% configuration %}
input_text:
description: Alias for the input. Multiple entries are allowed.
required: true
type: map
keys:
name:
description: Friendly name of the text input.
required: false
type: String
min:
description: Minimum length for the text value.
required: false
type: integer
default: 0
max:
description: Maximum length for the text value.
required: false
type: integer
default: 100
initial:
description: Initial value when Home Assistant starts.
required: false
type: String
default: empty
pattern:
description: Regex pattern for client side validation.
required: false
type: String
default: empty
mode:
description: Can specify `text` or `password`. Elements of type "password" provide a way for the user to securely enter a value.
required: false
type: String
default: text
{% endconfiguration %}
### {% linkable_title Services %}
This components provide three services to modify the state of the `input_text`.
| Service | Data | Description |
| ------- | ---- | ----------- |
| `set_value` | `value`<br>`entity_id(s)` | Set the value for specific `input_text` entities.
### {% linkable_title Restore State %}
This component will automatically restore the state it had prior to Home Assistant stopping as long as your entity does **not** have a set value for `initial`. To disable this feature, set a valid value for `initial`.
## {% linkable_title Automation Examples %}
Here's an example using `input_text` in an action in an automation.
{% raw %}
```yaml
# Example configuration.yaml entry using 'input_text' in an action in an automation
input_select:
scene_bedroom:
name: Scene
options:
- Select
- Concentrate
- Energize
- Reading
- Relax
- 'OFF'
initial: 'Select'
input_text:
bedroom:
name: Brightness
automation:
- alias: Bedroom Light - Custom
trigger:
platform: state
entity_id: input_select.scene_bedroom
action:
- service: input_text.set_value
# Again, note the use of 'data_template:' rather than the normal 'data:' if you weren't using an input variable.
data_template:
entity_id: input_text.bedroom
value: "{{ states('input_select.scene_bedroom') }}"
```
{% endraw %}