From 4ed78dab24cb8238e3e8c9a20a4759e01fbdaf2a Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 4 Apr 2021 04:01:43 -0700 Subject: [PATCH] Update docs for trigger-based template sensors. (#17243) --- source/_integrations/template.markdown | 51 +++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/source/_integrations/template.markdown b/source/_integrations/template.markdown index 369304943da..ec205c8bcb9 100644 --- a/source/_integrations/template.markdown +++ b/source/_integrations/template.markdown @@ -25,7 +25,7 @@ ha_platforms: The `template` integration allows creating entities which derive their values from other entities. This is done by defining [templates](/docs/configuration/templating/) for each property of an entity, like the name or the state. Entities are updated automatically whenever a value that a template relies on changes. -For sensors it's also possible to derive the state from [automation triggers](#configuration-for-trigger-based-template-sensors). +For template sensors it's also possible to derive the state from [automation triggers](#configuration-for-trigger-based-template-sensors). Available template platforms: @@ -152,6 +152,8 @@ curl --header "Content-Type: application/json" \ http://homeassistant.local:8123/api/webhook/my-super-secret-webhook-id ``` +

Configuration under the template: key uses a different format compared to the platform configuration.

+ {% configuration %} trigger: description: The trigger configuration for this entity. [See trigger documentation](/docs/automation/trigger) @@ -162,9 +164,54 @@ unique_id: required: false type: string sensor: - description: Map of your sensors to create from the trigger data. For available keys, see [configuration variables](#configuration-variables) above. + description: List of sensors to create from the trigger data. required: true type: map + keys: + state: + description: Defines a template to get the state of the sensor. + required: true + type: template + name: + description: Defines a template to get the name of the sensor. + required: false + type: template + unique_id: + description: An ID that uniquely identifies this sensor. Will be combined with the unique ID of the configuration block if available. + required: false + type: string + unit_of_measurement: + description: "Defines the units of measurement of the sensor, if any. This will also influence the graphical presentation in the history visualization as a continuous value. Sensors with missing `unit_of_measurement` are showing as discrete values." + required: false + type: string + default: None + icon: + description: Defines a template for the icon of the sensor. + required: false + type: template + picture: + description: Defines a template for the entity picture of the sensor. + required: false + type: template + attributes: + description: Defines templates for attributes of the sensor. + required: false + type: map + keys: + "attribute: template": + description: The attribute and corresponding template. + required: true + type: template + availability: + 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 not configured, the component will always be `available`. + required: false + type: template + default: true + device_class: + description: Sets the class of the device, changing the device state and icon that is displayed on the UI (see below). It does not set the `unit_of_measurement`. + required: false + type: device_class + default: None {% endconfiguration %}

It's currently only possible to define trigger-based entities via the top-level configuration. These entities are not yet included when reloading template entities.