From e081ef352a842f4cba986add63f713d8cf8e925f Mon Sep 17 00:00:00 2001 From: Marc Forth Date: Tue, 20 Feb 2018 11:39:09 +0000 Subject: [PATCH 1/8] Update input_datetime.markdown Fixes #4259 --- source/_components/input_datetime.markdown | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/source/_components/input_datetime.markdown b/source/_components/input_datetime.markdown index 73371143576..19f3a8b5ef9 100644 --- a/source/_components/input_datetime.markdown +++ b/source/_components/input_datetime.markdown @@ -75,3 +75,46 @@ A datetime input entity's state exports several attributes that can be useful in ### {% linkable_title Restore State %} This component supports the `restore_state` function which restores the state after Home Assistant has started to the value it has been before Home Assistant stopped. To use this feature please make sure that the [`recorder`](/components/recorder/) component is enabled and your entity does not have a value set for `initial`. Additional information can be found in the [Restore state](/components/recorder/#restore-state) section of the [`recorder`](/components/recorder/) component documentation. + +### {% linkable_title Services %} + +This component provides a service to modify the state of the `input_datetime`. + +| Service | Data | Description | +| ------- | ---- | ----------- | +| `set_datetime` | `time` | This can be used to dynamically set the time. +| `set_datetime` | `date` | This can be used to dynamically set the date. + +## {% linkable_title Automation Examples %} + +The following example shows the usage of the `input_datetime` as a trigger in an automation (note that you will need a [time sensor](https://home-assistant.io/components/sensor.time_date/) elsewhere in your configuration): + + +```yaml +# Example configuration.yaml entry +# Turns on bedroom light at the time specifiedateutomadate: + trigger: + platform: template + + value_template: '{{ states.sensor.time.state == (states.input_datetime.bedroom_alarm_clock_time.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}' + action: + - service: light.turn_on + entity_id: light.bedroom +``` + +To dynamically set the `input_datetime` you can call `input_datetime.set_datetime`. The following example can be used in an automation rule: + +```yaml +# Example configuration.yaml entry +# Sets input_datetime to '05:30' when an input_boolean is turned on. +automation: + trigger: + platform: state + entity_id: input_boolean.example + to: 'on' + action: + service: input_datetime.set_datetime + entity_id: input_datetime.bedroom_alarm_clock_time + data: + time: '05:30:00' +``` From a33ed1d11f51ff96ccc74402f9035d512f0f2aff Mon Sep 17 00:00:00 2001 From: Marc Forth Date: Tue, 20 Feb 2018 11:54:40 +0000 Subject: [PATCH 2/8] Update input_datetime.markdown --- source/_components/input_datetime.markdown | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/_components/input_datetime.markdown b/source/_components/input_datetime.markdown index 19f3a8b5ef9..1b2098bd267 100644 --- a/source/_components/input_datetime.markdown +++ b/source/_components/input_datetime.markdown @@ -89,10 +89,10 @@ This component provides a service to modify the state of the `input_datetime`. The following example shows the usage of the `input_datetime` as a trigger in an automation (note that you will need a [time sensor](https://home-assistant.io/components/sensor.time_date/) elsewhere in your configuration): - +{% raw %} ```yaml # Example configuration.yaml entry -# Turns on bedroom light at the time specifiedateutomadate: +# Turns on bedroom light at the time specified. trigger: platform: template @@ -101,6 +101,7 @@ The following example shows the usage of the `input_datetime` as a trigger in an - service: light.turn_on entity_id: light.bedroom ``` +{% endraw %} To dynamically set the `input_datetime` you can call `input_datetime.set_datetime`. The following example can be used in an automation rule: From 289e1092f15dfbd59410cbdc81d6484ff8f07744 Mon Sep 17 00:00:00 2001 From: Marc Forth Date: Tue, 20 Feb 2018 11:55:35 +0000 Subject: [PATCH 3/8] Update input_datetime.markdown --- source/_components/input_datetime.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_components/input_datetime.markdown b/source/_components/input_datetime.markdown index 1b2098bd267..50e20b8573c 100644 --- a/source/_components/input_datetime.markdown +++ b/source/_components/input_datetime.markdown @@ -65,7 +65,7 @@ input_datetime: A datetime input entity's state exports several attributes that can be useful in automations and templates. | Attribute | Description | -| --------- | ----------- | +| ... | ... | | `has_time` | `true` if this entity has a time. | `has_date` | `true` if this entity has a date. | `year`
`month`
`day` | The year, month and day of the date.
(only available if `has_date: true`) @@ -81,7 +81,7 @@ This component supports the `restore_state` function which restores the state af This component provides a service to modify the state of the `input_datetime`. | Service | Data | Description | -| ------- | ---- | ----------- | +| ... | ... | ... | | `set_datetime` | `time` | This can be used to dynamically set the time. | `set_datetime` | `date` | This can be used to dynamically set the date. From 262100de4558092efb3913301aaeb84f0834b2cb Mon Sep 17 00:00:00 2001 From: Marc Forth Date: Tue, 20 Feb 2018 11:58:24 +0000 Subject: [PATCH 4/8] Update input_datetime.markdown --- source/_components/input_datetime.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/input_datetime.markdown b/source/_components/input_datetime.markdown index 50e20b8573c..36006331619 100644 --- a/source/_components/input_datetime.markdown +++ b/source/_components/input_datetime.markdown @@ -87,7 +87,7 @@ This component provides a service to modify the state of the `input_datetime`. ## {% linkable_title Automation Examples %} -The following example shows the usage of the `input_datetime` as a trigger in an automation (note that you will need a [time sensor](https://home-assistant.io/components/sensor.time_date/) elsewhere in your configuration): +The following example shows the usage of the `input_datetime` as a trigger in an automation (note that you will need a [time sensor](/components/sensor.time_date/) elsewhere in your configuration): {% raw %} ```yaml From c12f2e7e67291e52c01d0668703ad12ee43cee47 Mon Sep 17 00:00:00 2001 From: Marc Forth Date: Tue, 20 Feb 2018 12:01:21 +0000 Subject: [PATCH 5/8] Update input_datetime.markdown --- source/_components/input_datetime.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_components/input_datetime.markdown b/source/_components/input_datetime.markdown index 36006331619..ccae9f30e73 100644 --- a/source/_components/input_datetime.markdown +++ b/source/_components/input_datetime.markdown @@ -65,7 +65,7 @@ input_datetime: A datetime input entity's state exports several attributes that can be useful in automations and templates. | Attribute | Description | -| ... | ... | +| ----- | ----- | | `has_time` | `true` if this entity has a time. | `has_date` | `true` if this entity has a date. | `year`
`month`
`day` | The year, month and day of the date.
(only available if `has_date: true`) @@ -81,7 +81,7 @@ This component supports the `restore_state` function which restores the state af This component provides a service to modify the state of the `input_datetime`. | Service | Data | Description | -| ... | ... | ... | +| ----- | ----- | ----- | | `set_datetime` | `time` | This can be used to dynamically set the time. | `set_datetime` | `date` | This can be used to dynamically set the date. From be3c0f0f54f4323222b79d4a1c45e5d865c42260 Mon Sep 17 00:00:00 2001 From: Marc Forth Date: Tue, 20 Feb 2018 12:08:19 +0000 Subject: [PATCH 6/8] Update input_datetime.markdown --- source/_components/input_datetime.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/source/_components/input_datetime.markdown b/source/_components/input_datetime.markdown index ccae9f30e73..8cab8edf24e 100644 --- a/source/_components/input_datetime.markdown +++ b/source/_components/input_datetime.markdown @@ -95,7 +95,6 @@ The following example shows the usage of the `input_datetime` as a trigger in an # Turns on bedroom light at the time specified. trigger: platform: template - value_template: '{{ states.sensor.time.state == (states.input_datetime.bedroom_alarm_clock_time.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}' action: - service: light.turn_on From 7374aa5aef6668f636191593281a1eadbb75cdcd Mon Sep 17 00:00:00 2001 From: Marc Forth Date: Tue, 20 Feb 2018 13:03:38 +0000 Subject: [PATCH 7/8] Update input_datetime.markdown --- source/_components/input_datetime.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_components/input_datetime.markdown b/source/_components/input_datetime.markdown index 8cab8edf24e..1ed907e1839 100644 --- a/source/_components/input_datetime.markdown +++ b/source/_components/input_datetime.markdown @@ -95,8 +95,8 @@ The following example shows the usage of the `input_datetime` as a trigger in an # Turns on bedroom light at the time specified. trigger: platform: template - value_template: '{{ states.sensor.time.state == (states.input_datetime.bedroom_alarm_clock_time.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}' - action: +    value_template: "{{ states('sensor.time') == (states.input_datetime.bedroom_alarm_clock_time.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}" +  action: - service: light.turn_on entity_id: light.bedroom ``` From 0ad4f914a472cebe25a4dd70d57bad545e4a4630 Mon Sep 17 00:00:00 2001 From: Marc Forth Date: Tue, 20 Feb 2018 13:10:05 +0000 Subject: [PATCH 8/8] Update input_datetime.markdown --- source/_components/input_datetime.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/input_datetime.markdown b/source/_components/input_datetime.markdown index 1ed907e1839..cd425a54737 100644 --- a/source/_components/input_datetime.markdown +++ b/source/_components/input_datetime.markdown @@ -95,7 +95,7 @@ The following example shows the usage of the `input_datetime` as a trigger in an # Turns on bedroom light at the time specified. trigger: platform: template -    value_template: "{{ states('sensor.time') == (states.input_datetime.bedroom_alarm_clock_time.attributes.timestamp | int | timestamp_custom("%H:%M", False)) }}" +    value_template: "{{ states('sensor.time') == (states.input_datetime.bedroom_alarm_clock_time.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"  action: - service: light.turn_on entity_id: light.bedroom