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:
Burningstone91 2020-02-03 09:08:38 +01:00 committed by GitHub
parent 654fee7501
commit 58f726e0ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,34 +119,39 @@ automation:
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.)
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 %}
```yaml
# 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:
trigger:
platform: state
entity_id: input_boolean.example
to: 'on'
action:
# Sets time to '05:30:00
- service: input_datetime.set_datetime
entity_id: input_datetime.bedroom_alarm_clock_time
data:
time: '05:30:00'
# Sets time to time from datetime object (current time in this example)
- service: input_datetime.set_datetime
entity_id: input_datetime.another_time
data_template:
time: "{{ now().strftime('%H:%M:%S') }}"
# Sets date to date from timestamp (current date in this example)
- service: input_datetime.set_datetime
entity_id: input_datetime.another_date
data_template:
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
entity_id: input_datetime.date_and_time
data_template:
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
data_template:
entity_id: input_datetime.date_and_time