From b00b47c0629e67985e57af0f562d4ea5d99ee257 Mon Sep 17 00:00:00 2001 From: Gil Peeters Date: Sun, 8 Sep 2019 20:50:45 +1000 Subject: [PATCH 1/4] Added 'availability_template' to all Template Cover platform --- source/_components/cover.template.markdown | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/_components/cover.template.markdown b/source/_components/cover.template.markdown index 951e750544ae..aa5943a52324 100644 --- a/source/_components/cover.template.markdown +++ b/source/_components/cover.template.markdown @@ -19,6 +19,7 @@ To enable Template Covers in your installation, add the following to your `configuration.yaml` file: {% raw %} + ```yaml # Example configuration.yaml entry cover: @@ -33,7 +34,12 @@ cover: service: script.close_garage_door stop_cover: service: script.stop_garage_door + availability_template: >- + {%- if not is_state('dependant_device.state', 'unavailable') %} + true + {% endif %} ``` + {% endraw %} {% configuration %} @@ -62,6 +68,11 @@ cover: description: Defines a template to specify which icon to use. 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` device_class: description: Sets the [class of the device](/components/cover/), changing the device state and icon that is displayed on the frontend. required: false @@ -136,6 +147,7 @@ This example converts a garage door with a controllable switch and position sensor into a cover. {% raw %} + ```yaml cover: - platform: template @@ -162,6 +174,7 @@ cover: mdi:garage {% endif %} ``` + {% endraw %} ### Multiple Covers @@ -169,6 +182,7 @@ cover: This example allows you to control two or more covers at once. {% raw %} + ```yaml homeassistant: customize: @@ -249,6 +263,7 @@ automation: entity_id: cover.cover_group position: 25 ``` + {% endraw %} ### Change The Icon @@ -256,6 +271,7 @@ automation: This example shows how to change the icon based on the cover state. {% raw %} + ```yaml cover: - platform: template @@ -282,6 +298,7 @@ cover: mdi:window-closed {% endif %} ``` + {% endraw %} ### Change The Entity Picture @@ -289,6 +306,7 @@ cover: This example shows how to change the entity picture based on the cover state. {% raw %} + ```yaml cover: - platform: template @@ -315,4 +333,5 @@ cover: /local/cover-closed.png {% endif %} ``` + {% endraw %} From 33d5a91241e4913fc32ae89447560bf6b5a98475 Mon Sep 17 00:00:00 2001 From: Gil Peeters Date: Sun, 8 Sep 2019 23:46:20 +1000 Subject: [PATCH 2/4] Fixed Syntax and default --- source/_components/cover.template.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_components/cover.template.markdown b/source/_components/cover.template.markdown index aa5943a52324..dbf0fb1141ee 100644 --- a/source/_components/cover.template.markdown +++ b/source/_components/cover.template.markdown @@ -69,10 +69,10 @@ cover: 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 device_class: description: Sets the [class of the device](/components/cover/), changing the device state and icon that is displayed on the frontend. required: false From c06b38bbd84febb42141da7548bc79b8ba1e8cb9 Mon Sep 17 00:00:00 2001 From: Gil Peeters Date: Wed, 11 Sep 2019 07:04:20 +1000 Subject: [PATCH 3/4] Apply suggestions from code review Co-Authored-By: Franck Nijhof --- source/_components/cover.template.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/cover.template.markdown b/source/_components/cover.template.markdown index dbf0fb1141ee..61cdd4e69a86 100644 --- a/source/_components/cover.template.markdown +++ b/source/_components/cover.template.markdown @@ -69,7 +69,7 @@ cover: 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 From 52082c781faa166ab7132e538d0f60d8286cc41e Mon Sep 17 00:00:00 2001 From: Gil Peeters Date: Wed, 11 Sep 2019 07:05:27 +1000 Subject: [PATCH 4/4] Removed optional values from example configuration --- source/_components/cover.template.markdown | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/_components/cover.template.markdown b/source/_components/cover.template.markdown index 61cdd4e69a86..816d77d6317d 100644 --- a/source/_components/cover.template.markdown +++ b/source/_components/cover.template.markdown @@ -34,10 +34,6 @@ cover: service: script.close_garage_door stop_cover: service: script.stop_garage_door - availability_template: >- - {%- if not is_state('dependant_device.state', 'unavailable') %} - true - {% endif %} ``` {% endraw %}