From fa305ccdfb03b0e2a0df35398f44875b74f194dc Mon Sep 17 00:00:00 2001 From: Gil Peeters Date: Sun, 8 Sep 2019 20:56:34 +1000 Subject: [PATCH 1/4] Added 'availability_template' to Template Vacuum platform --- source/_components/vacuum.template.markdown | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/source/_components/vacuum.template.markdown b/source/_components/vacuum.template.markdown index 0b705d7f27cd..050e3f51dbaa 100644 --- a/source/_components/vacuum.template.markdown +++ b/source/_components/vacuum.template.markdown @@ -15,6 +15,8 @@ return_to_base, clean_spot, locate and set_fan_speed commands of a vacuum. To enable Template Vacuums in your installation, add the following to your `configuration.yaml` file: +{% raw %} + ```yaml # Example configuration.yaml entry vacuum: @@ -22,9 +24,15 @@ vacuum: vacuums: living_room_vacuum: start: - service: script.vacuum_start + service: script.vacuum_start + availability_template: >- + {%- if not is_state('dependant_device.state', 'unavailable') %} + true + {% endif %} ``` +{% endraw %} + {% configuration %} vacuums: description: List of your vacuums. @@ -47,6 +55,11 @@ vacuum: description: Defines a template to get the fan speed of the vacuum. required: false type: template + availability_template: + description: "Defines a template to get the `available` state of the component. If the template returns `true` the device is `available`. If the template returns any other value, the device will be `unavailable`. If `availability_template` is not configured, the component will always be `available`" + required: false + type: template + default: the device is always `available` start: description: Defines an action to run when the vacuum is started. required: true @@ -117,6 +130,7 @@ vacuum: This example shows how to use templates to specify the state of the vacuum. {% raw %} + ```yaml vacuum: - platform: template @@ -144,4 +158,5 @@ vacuum: - Medium - High ``` + {% endraw %} From ab96f4d7c9c544aa493b67b34b81695664a36c3d Mon Sep 17 00:00:00 2001 From: Gil Peeters Date: Sun, 8 Sep 2019 23:48:32 +1000 Subject: [PATCH 2/4] Fixed Syntax and default --- source/_components/vacuum.template.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_components/vacuum.template.markdown b/source/_components/vacuum.template.markdown index 050e3f51dbaa..c1443984dea8 100644 --- a/source/_components/vacuum.template.markdown +++ b/source/_components/vacuum.template.markdown @@ -56,10 +56,10 @@ vacuum: required: false type: template availability_template: - description: "Defines a template to get the `available` state of the component. If the template returns `true` the device is `available`. If the template returns any other value, the device will be `unavailable`. If `availability_template` is not configured, the component will always be `available`" + description: Defines a template to get the `available` state of the component. If the template returns `true` the device is `available`. If the template returns any other value, the device will be `unavailable`. If `availability_template` is not configured, the component will always be `available` required: false type: template - default: the device is always `available` + default: true start: description: Defines an action to run when the vacuum is started. required: true From 2d4665bc96ac843a7048105b2b8735c0138981d2 Mon Sep 17 00:00:00 2001 From: Gil Peeters Date: Wed, 11 Sep 2019 07:32:03 +1000 Subject: [PATCH 3/4] Removed optional parameter from example config --- source/_components/vacuum.template.markdown | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/_components/vacuum.template.markdown b/source/_components/vacuum.template.markdown index c1443984dea8..f1dc9020794d 100644 --- a/source/_components/vacuum.template.markdown +++ b/source/_components/vacuum.template.markdown @@ -25,10 +25,6 @@ vacuum: living_room_vacuum: start: service: script.vacuum_start - availability_template: >- - {%- if not is_state('dependant_device.state', 'unavailable') %} - true - {% endif %} ``` {% endraw %} From fc64510879c81fd4121dc870a4a81cde653acc03 Mon Sep 17 00:00:00 2001 From: Gil Peeters Date: Wed, 11 Sep 2019 07:32:17 +1000 Subject: [PATCH 4/4] Apply suggestions from code review Co-Authored-By: Franck Nijhof --- source/_components/vacuum.template.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/vacuum.template.markdown b/source/_components/vacuum.template.markdown index f1dc9020794d..bb5c7bad34ac 100644 --- a/source/_components/vacuum.template.markdown +++ b/source/_components/vacuum.template.markdown @@ -52,7 +52,7 @@ vacuum: required: false type: template availability_template: - description: Defines a template to get the `available` state of the component. If the template returns `true` the device is `available`. If the template returns any other value, the device will be `unavailable`. If `availability_template` is not configured, the component will always be `available` + description: Defines a template to get the `available` state of the component. If the template returns `true`, the device is `available`. If the template returns any other value, the device will be `unavailable`. If `availability_template` is not configured, the component will always be `available`. required: false type: template default: true