|
| 1 | +--- |
| 2 | +layout: page |
| 3 | +title: "Input Datetime" |
| 4 | +description: "Instructions how to integrate the Input Datetime component into Home Assistant." |
| 5 | +date: 2017-09-14 16:01 |
| 6 | +sidebar: true |
| 7 | +comments: false |
| 8 | +sharing: true |
| 9 | +footer: true |
| 10 | +logo: home-assistant.png |
| 11 | +ha_category: Automation |
| 12 | +ha_release: TODO |
| 13 | +--- |
| 14 | + |
| 15 | +The `input_datetime` component allows the user to define date and time values that can be controlled via the frontend and can be used within automations and templates. |
| 16 | + |
| 17 | +To add three datetime inputs to your installation, one with both date and time, and one with date or time each, add the following lines to your `configuration.yaml`: |
| 18 | + |
| 19 | +```yaml |
| 20 | +# Example configuration.yaml entry |
| 21 | +input_datetime: |
| 22 | + both_date_and_time: |
| 23 | + name: Input with both date and time |
| 24 | + has_date: true |
| 25 | + has_time: true |
| 26 | + only_date: |
| 27 | + name: Input with only date |
| 28 | + has_date: true |
| 29 | + has_time: false |
| 30 | + only_time: |
| 31 | + name: Input with only time |
| 32 | + has_date: false |
| 33 | + has_time: true |
| 34 | +``` |
| 35 | +
|
| 36 | +Configuration variables: |
| 37 | +
|
| 38 | +- **[alias]** (*Required*): Alias for the datetime input. Multiple entries are allowed. |
| 39 | + - **name** (*Optional*): Friendly name of the datetime input. |
| 40 | + - **has_time** (*Optional*): Set to `true` if this input should have time. Defaults to `false`. |
| 41 | + - **has_date** (*Optional*): Set to `true` if this input should have a date. Defaults to `false`. |
| 42 | + - **initial** (*Optional*): Set the initial value of this input. Defaults to '1970-01-01 00:00'. |
| 43 | + |
| 44 | +A datetime input entity's state exports several attributes that can be useful in automations and templates: |
| 45 | + |
| 46 | +- **has_time**: `true` if this entity has time. |
| 47 | +- **has_date**: `true` if this entity has a date. |
| 48 | +- **year**, **month**, **day** (Only available if *has_date* is true): The year, month and day of the date. |
| 49 | +- **hour**, **minute**, **second** (Only available if *has_time* is true): The hour, minute and second of the time. |
| 50 | +- **timestamp**: A timestamp representing the time held in the input. If *has_date* is true, this is the UNIX timestamp of the date / time held by the input. Otherwise (i.e., if only *has_time* is true) the number of seconds since midnight representing the time held by the input. |
0 commit comments