mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 17:27:19 +00:00
Adjust example (#11950)
Example comment is a bit confusing by saying it sets the input_datetime to 05:30, however the actual examples shows different ways to set the input_datetime, not only setting it to 05:30
This commit is contained in:
parent
654fee7501
commit
58f726e0ec
@ -119,34 +119,39 @@ automation:
|
|||||||
To dynamically set the `input_datetime` you can call
|
To dynamically set the `input_datetime` you can call
|
||||||
`input_datetime.set_datetime`. The values for `date` and `time` must be in a certain format for the call to be successful. (See service description above.)
|
`input_datetime.set_datetime`. The values for `date` and `time` must be in a certain format for the call to be successful. (See service description above.)
|
||||||
If you have a `datetime` object you can use its `strftime` method. Of if you have a timestamp you can use the `timestamp_custom` filter.
|
If you have a `datetime` object you can use its `strftime` method. Of if you have a timestamp you can use the `timestamp_custom` filter.
|
||||||
The following example can be used in an automation rule:
|
The following example shows the different methods in an automation rule:
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
```yaml
|
```yaml
|
||||||
# Example configuration.yaml entry
|
# Example configuration.yaml entry
|
||||||
# Sets input_datetime to '05:30' when an input_boolean is turned on.
|
# Shows different ways to set input_datetime when an input_boolean is turned on
|
||||||
automation:
|
automation:
|
||||||
trigger:
|
trigger:
|
||||||
platform: state
|
platform: state
|
||||||
entity_id: input_boolean.example
|
entity_id: input_boolean.example
|
||||||
to: 'on'
|
to: 'on'
|
||||||
action:
|
action:
|
||||||
|
# Sets time to '05:30:00
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
entity_id: input_datetime.bedroom_alarm_clock_time
|
entity_id: input_datetime.bedroom_alarm_clock_time
|
||||||
data:
|
data:
|
||||||
time: '05:30:00'
|
time: '05:30:00'
|
||||||
|
# Sets time to time from datetime object (current time in this example)
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
entity_id: input_datetime.another_time
|
entity_id: input_datetime.another_time
|
||||||
data_template:
|
data_template:
|
||||||
time: "{{ now().strftime('%H:%M:%S') }}"
|
time: "{{ now().strftime('%H:%M:%S') }}"
|
||||||
|
# Sets date to date from timestamp (current date in this example)
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
entity_id: input_datetime.another_date
|
entity_id: input_datetime.another_date
|
||||||
data_template:
|
data_template:
|
||||||
date: "{{ as_timestamp(now())|timestamp_custom('%Y-%m-%d') }}"
|
date: "{{ as_timestamp(now())|timestamp_custom('%Y-%m-%d') }}"
|
||||||
|
# Sets date and time to date and time from datetime object (current date and time in this example)
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
entity_id: input_datetime.date_and_time
|
entity_id: input_datetime.date_and_time
|
||||||
data_template:
|
data_template:
|
||||||
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
|
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
|
||||||
|
# Sets date and time to date and time from timestamp (current date and time in this example)
|
||||||
- service: input_datetime.set_datetime
|
- service: input_datetime.set_datetime
|
||||||
data_template:
|
data_template:
|
||||||
entity_id: input_datetime.date_and_time
|
entity_id: input_datetime.date_and_time
|
||||||
|
Loading…
x
Reference in New Issue
Block a user