From 785f7869568f65116e94e7cfaee0f096f0e3d873 Mon Sep 17 00:00:00 2001 From: perjury Date: Tue, 28 Jan 2020 14:40:23 +0000 Subject: [PATCH 1/2] Consistency and readability (#11897) * Consistency and readability Change headings to match key names to avoid confusion (e.g heading Path instead of Paths to describe the Path key) Also readability changes to make the documentation clearer. * Update views.markdown * Update views.markdown * Update source/lovelace/views.markdown Co-Authored-By: Franck Nijhof * Update source/lovelace/views.markdown Co-Authored-By: Franck Nijhof Co-authored-by: Franck Nijhof --- source/lovelace/views.markdown | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/source/lovelace/views.markdown b/source/lovelace/views.markdown index aad366c3b48..ff5e4e451c8 100644 --- a/source/lovelace/views.markdown +++ b/source/lovelace/views.markdown @@ -57,7 +57,7 @@ views: default: true {% endconfiguration %} -## Options For Visible +### Options For Visible If you define `visible` as objects instead of a boolean to specify conditions for displaying the view tab: @@ -83,11 +83,11 @@ View config: image: /local/lights.png ``` -## Paths +## Path -You can link to one view from another view by its path. For this use cards that support navigation (`navigation_path`). Do not use special characters in paths. Do not begin a path with a number. This will cause the parser to read your path as a view index. +You can link to one view from a card in another view when using cards that support navigation (`navigation_path`). The string supplied here will be appended to the string `/lovelace/` to create the path to the view. Do not use special characters in paths. Do not begin a path with a number. This will cause the parser to read your path as a view index. -### Example +#### Example View config: @@ -107,11 +107,11 @@ Picture card config: navigation_path: /lovelace/living_room ``` -## Icons +## Icon If you define an icon the title will be used as a tool-tip. -### Example +#### Example ```yaml - title: Garden @@ -122,7 +122,7 @@ If you define an icon the title will be used as a tool-tip. You can specify the visibility of views as a whole or per-user. (Note: This is only for the display of the tabs. The url path is still accessible) -### Example +#### Example ```yaml views: @@ -142,11 +142,11 @@ views: ... ``` -## Panel mode +## Panel -This renders the first card on full width, other cards in this view will not be rendered. Good for cards like `map`, `stack` or `picture-elements`. +Setting panel true sets the view to panel mode. In this mode the first card is rendered full-width, other cards in the view will not be rendered. This mode is good when using cards like `map`, `stack` or `picture-elements`. -### Example +#### Example ```yaml - title: Map @@ -158,18 +158,18 @@ This renders the first card on full width, other cards in this view will not be - zone.home ``` -## Themes +## Theme Set a separate [theme](/integrations/frontend/#themes) for the view and its cards. -### Example +#### Example ```yaml - title: Home theme: happy ``` -### Background +## Background You can style the background of your views with a [theme](/integrations/frontend/#themes). You can use the CSS variable `lovelace-background`. For wallpapers you probably want to use the example below, more options can be found [here](https://developer.mozilla.org/en-US/docs/Web/CSS/background). From 38d0ab195d192ed5eeac35262b3cc8c66d09df6f Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 28 Jan 2020 08:50:43 -0600 Subject: [PATCH 2/2] Add note and tweak examples A common question in the support channels involves the `UndefinedError` returned when an automation that references a trigger state object in the action is manually triggered. Hopefully this note will reduce those questions in the future. I also tweaked the example automations. --- source/_docs/automation/templating.markdown | 22 ++++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/source/_docs/automation/templating.markdown b/source/_docs/automation/templating.markdown index eb68f068c61..9a8d98e56b4 100644 --- a/source/_docs/automation/templating.markdown +++ b/source/_docs/automation/templating.markdown @@ -34,27 +34,19 @@ automation 2: automation 3: trigger: - # Multiple Entities for which you want to perform the same action. + # Multiple entities for which you want to perform the same action. - platform: state entity_id: - light.bedroom_closet - to: 'on' - # Trigger when someone leaves the closet light on for 10 minutes. - for: '00:10:00' - - platform: state - entity_id: - light.kiddos_closet - to: 'on' - for: '00:10:00' - - platform: state - entity_id: - light.linen_closet to: 'on' + # Trigger when someone leaves one of those lights on for 10 minutes. for: '00:10:00' action: - service: light.turn_off data_template: - # Whichever entity triggers the automation we want to turn off THAT entity, not the others. + # Turn off whichever entity triggered the automation. entity_id: "{{ trigger.entity_id }}" ``` {% endraw %} @@ -76,12 +68,18 @@ It is possible to use `data` and `data_template` concurrently but be aware that ## Trigger State Object -Knowing how to access the [state object](/docs/configuration/state_object/) of a trigger entity could be one of the more common questions. Here are a few ways for the [`state`](#state), [`numeric_state`](#numeric_state) and [`template`](#template) triggers: +Knowing how to access the [state object](/docs/configuration/state_object/) of a trigger entity can be useful in automations. Here are a few ways to access the [`state`](#state), [`numeric_state`](#numeric_state) and [`template`](#template) triggers: * `trigger.from_state` will return the **previous** [state object](/docs/configuration/state_object/) of the entity. * `trigger.to_state` will return the **new** [state object](/docs/configuration/state_object/) that triggered trigger. * `states[trigger.to_state.domain][trigger.to_state.object_id]` will return the **current** [state object](/docs/configuration/state_object/) of the entity. +
+ + Be aware that if you reference a trigger state object in an automation action, attempting to test that automation by calling the `automation.trigger` service or by clicking EXECUTE in the More Info box for the automation will not work. This is because the trigger state object doesn't exist in those contexts. One way to test automations like these is to manually change the state of the trigger entity at Developer Tools > States. + +
+ ## Available Trigger Data The following tables show the available trigger data per platform.