From ae98bbf42e09e9f1ef93fa0eaa22d1e41afebe00 Mon Sep 17 00:00:00 2001
From: DetroitEE <33440271+DetroitEE@users.noreply.github.com>
Date: Mon, 30 Jul 2018 09:08:35 -0400
Subject: [PATCH 01/17] Update media_player.webostv.markdown
---
source/_components/media_player.webostv.markdown | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source/_components/media_player.webostv.markdown b/source/_components/media_player.webostv.markdown
index 3775ae8260ca..102852ead3ee 100644
--- a/source/_components/media_player.webostv.markdown
+++ b/source/_components/media_player.webostv.markdown
@@ -75,7 +75,7 @@ media_player:
Home Assistant is able to turn on a LG webOS Smart TV if you specify an action, like HDMI-CEC or WakeOnLan.
Common for webOS 3.0 and higher would be to use WakeOnLan feature.
-To use this feature your TV should be connected to your network via Ethernet rather than Wireless and you should enable *LG Connect Apps* feature in *Network* settings of the TV [instructions](http://www.lg.com/uk/support/product-help/CT00008334-1437131798537-others) (or *Mobile App* in *General* settings for older models) (*may vary by version).
+To use this feature your TV should be connected to your network via Ethernet rather than Wireless and you should enable *LG Connect Apps* feature in *Network* settings of the TV [instructions](http://www.lg.com/uk/support/product-help/CT00008334-1437131798537-others) (or *Mobile App* in *General* settings for older models) (*may vary by version). On newer models (2017+), WakeOnLan may need to be enabled in the TV settings by going to Settings > General > Mobile TV On > Turn On Via WiFi [instructions](https://support.quanticapps.com/hc/en-us/articles/115005985729-How-to-turn-on-my-LG-Smart-TV-using-the-App-WebOS-).
```yaml
# Example configuration.yaml entry
From 8717eb9f8fac923c3a9c9a4bc733d87f1ca29660 Mon Sep 17 00:00:00 2001
From: DubhAd
Date: Sat, 11 Aug 2018 13:16:52 +0100
Subject: [PATCH 02/17] Minor changes (#5990)
Taking out the "new and experimental" note - we're a dozen releases on, it's hardly new and seems to be (from a feature sense) stable.
Re-written para 2 to reflect that HA needs shut down, and that 0.75 introduced the "future" UI. Re-written the supported components list because it's horribly out of date, and without trawling the code it's impossible to know what's supported.
---
.../_docs/configuration/entity-registry.markdown | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/source/_docs/configuration/entity-registry.markdown b/source/_docs/configuration/entity-registry.markdown
index b6183f7b76b9..2f29afc306cc 100644
--- a/source/_docs/configuration/entity-registry.markdown
+++ b/source/_docs/configuration/entity-registry.markdown
@@ -9,17 +9,14 @@ sharing: true
footer: true
---
-
-This is a new and experimental feature of Home Assistant.
-
-
Starting with version 0.63, Home Assistant keeps a registry of known entities.
The entity registry makes sure that entities get unique identifiers and allow
customizing the identifiers and names of these entities.
-As this is still a very new part of Home Assistant, changes will require a
-restart of Home Assistant to take effect. A config user interface will be added
-in a future version.
+Changes require that Home Assistant is shut down when you edit the file, otherwise
+Home Assistant may over-write your changes, and a restart of Home Assistant is
+required for your changes to take effect. Version 0.75 introduced a configuration
+user interface.
An entity needs to have a unique ID to be registered in the entity registry.
@@ -55,5 +52,6 @@ value to each entry.
{% linkable_title Supported Components %}
-At the moment, only the following components are supported: Z-Wave, Hue, Nest, LIFX, Sonos, Apple TV, Weather Underground
+Only components that provide a unique ID for entities will are supported.
+
Note that for Weather Underground, second and subsequent Personal Weather Station ID (pws_id) will have their monitored conditions suffixed with an index number.
From 3a0a54cf14afc18ea4a57919f29560a5a18f3f84 Mon Sep 17 00:00:00 2001
From: Fabian Affolter
Date: Sat, 11 Aug 2018 14:20:33 +0200
Subject: [PATCH 03/17] Remove line braks
---
.../configuration/entity-registry.markdown | 23 ++++++-------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/source/_docs/configuration/entity-registry.markdown b/source/_docs/configuration/entity-registry.markdown
index 2f29afc306cc..b699bb979eb4 100644
--- a/source/_docs/configuration/entity-registry.markdown
+++ b/source/_docs/configuration/entity-registry.markdown
@@ -9,24 +9,18 @@ sharing: true
footer: true
---
-Starting with version 0.63, Home Assistant keeps a registry of known entities.
-The entity registry makes sure that entities get unique identifiers and allow
-customizing the identifiers and names of these entities.
+Starting with version 0.63, Home Assistant keeps a registry of known entities. The entity registry makes sure that entities get unique identifiers and allow customizing the identifiers and names of these entities.
-Changes require that Home Assistant is shut down when you edit the file, otherwise
-Home Assistant may over-write your changes, and a restart of Home Assistant is
-required for your changes to take effect. Version 0.75 introduced a configuration
-user interface.
+Changes require that Home Assistant is shut down when you edit the file, otherwise Home Assistant may over-write your changes, and a restart of Home Assistant is required for your changes to take effect. Version 0.75 introduced a configuration user interface.
An entity needs to have a unique ID to be registered in the entity registry.
Not all integrations currently provide a unique id for their entities.
-The entity registry is stored in `/entity_registry.yaml`. As a user,
-you are unable to add entries, only update them. Here is an example file:
+The entity registry is stored in `/entity_registry.yaml`. As a user, you are unable to add entries, only update them. Here is an example file:
-```
+```yaml
climate.downstairs_virtual:
platform: nest
unique_id: EPoMyWkpNyoYu3pGlmGxabcdefghijkl
@@ -37,16 +31,13 @@ light.study_ceiling:
disabled_by: user
```
-As a user, you can change the `entity_id` and add the `name` and `disabled_by`
-value to each entry.
- - Changing the _first line_ of each entry will change the `entity_id` of the entity throughout Home Assistant.
+As a user, you can change the `entity_id` and add the `name` and `disabled_by`value to each entry.
+ - Changing the _first line_ of each entry will change the `entity_id` of the entity throughout Home Assistant.
- The value of `name` will override the _friendly name_ of the entity as given by the integration.
_Added in Home Assistant 0.64._
- - The key `disabled_by` can either be `hass` or `user`. This functionality
- is even more experimental than the whole entity registry itself and might
- cause integrations to fail and might be removed in the future.
+ - The key `disabled_by` can either be `hass` or `user`. This functionality is even more experimental than the whole entity registry itself and might cause integrations to fail and might be removed in the future.
_Added in Home Assistant 0.64._
From fac925790825d89b454aa713340981e9f0a0ba6b Mon Sep 17 00:00:00 2001
From: Fabian Affolter
Date: Sat, 11 Aug 2018 14:28:32 +0200
Subject: [PATCH 04/17] Update style
---
.../_docs/configuration/templating.markdown | 83 +++++++++++--------
1 file changed, 50 insertions(+), 33 deletions(-)
diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown
index eea6b7c46df7..f627d2ea834a 100644
--- a/source/_docs/configuration/templating.markdown
+++ b/source/_docs/configuration/templating.markdown
@@ -17,16 +17,9 @@ This is an advanced feature of Home Assistant. You'll need a basic understanding
Templating is a powerful feature in Home Assistant that allows the user control over information that is going into and out of the system. It is used for:
-- Formatting outgoing messages in, for example, the [notify] and [alexa] components.
-- Process incoming data from sources that provide raw data, like [MQTT], [REST sensor], or the [command line sensor].
-- [Automation Templating].
-
-[notify]: /components/notify/
-[alexa]: /components/alexa/
-[MQTT]: /components/mqtt/
-[REST sensor]: /components/sensor.rest/
-[command line sensor]: /components/sensor.command_line/
-[Automation Templating]: /docs/automation/templating/
+- Formatting outgoing messages in, for example, the [notify](/components/notify/) platforms and [alexa](/components/alexa/) component.
+- Process incoming data from sources that provide raw data, like [MQTT](/components/mqtt/), [`rest` sensor](/components/sensor.rest/) or the [`command_line` sensor](/components/sensor.command_line/).
+- [Automation Templating](/docs/automation/templating/).
## {% linkable_title Building templates %}
@@ -38,6 +31,7 @@ The frontend has a template editor developer tool to help develop and debug temp
Templates can get big pretty fast. To keep a clear overview, consider using YAML multiline strings to define your templates:
+{% raw %}
```yaml
script:
msg_who_is_home:
@@ -45,12 +39,13 @@ script:
- service: notify.notify
data_template:
message: >
- {% raw %}{% if is_state('device_tracker.paulus', 'home') %}
+ {% if is_state('device_tracker.paulus', 'home') %}
Ha, Paulus is home!
{% else %}
Paulus is at {{ states('device_tracker.paulus') }}.
- {% endif %}{% endraw %}
+ {% endif %}
```
+{% endraw %}
[Jinja2](http://jinja.pocoo.org/) supports a wide variety of operations:
@@ -117,43 +112,51 @@ In templates, besides the normal [state object methods and properties](/topics/s
## {% linkable_title Examples %}
### {% linkable_title States %}
+
The next two statements result in same value if state exists. The second one will result in an error if state does not exist.
+{% raw %}
```text
-{% raw %}{{ states('device_tracker.paulus') }}
-{{ states.device_tracker.paulus.state }}{% endraw %}
+{{ states('device_tracker.paulus') }}
+{{ states.device_tracker.paulus.state }}
```
+{% endraw %}
### {% linkable_title Attributes %}
Print an attribute if state is defined. Both will return the same thing but the last one you can specify entity_id from a variable.
+{% raw %}
```text
-{% raw %}{% if states.device_tracker.paulus %}
+{% if states.device_tracker.paulus %}
{{ states.device_tracker.paulus.attributes.battery }}
{% else %}
??
-{% endif %}{% endraw %}
+{% endif %}
```
+{% endraw %}
With strings
+{% raw %}
```text
-{% raw %}{% set tracker_name = "paulus"%}
+{% set tracker_name = "paulus"%}
{% if states("device_tracker." + tracker_name) != "unknown" %}
{{ state_attr("device_tracker." + tracker_name, "battery")}}
{% else %}
??
-{% endif %}{% endraw %}
+{% endif %}
```
+{% endraw %}
### {% linkable_title Sensor states %}
Print out a list of all the sensor states.
+{% raw %}
```text
-{% raw %}{% for state in states.sensor %}
+{% for state in states.sensor %}
{{ state.entity_id }}={{ state.state }},
{% endfor %}
@@ -173,48 +176,58 @@ Print out a list of all the sensor states.
{{ as_timestamp(states.binary_sensor.garage_door.last_changed) }}
-{{ as_timestamp(now()) - as_timestamp(states.binary_sensor.garage_door.last_changed) }}{% endraw %}
+{{ as_timestamp(now()) - as_timestamp(states.binary_sensor.garage_door.last_changed) }}
```
+{% endraw %}
### {% linkable_title Distance examples %}
If only 1 location is passed in, Home Assistant will measure the distance from home.
+{% raw %}
```text
-{% raw %}Using Lat Lng coordinates: {{ distance(123.45, 123.45) }}
+Using Lat Lng coordinates: {{ distance(123.45, 123.45) }}
Using State: {{ distance(states.device_tracker.paulus) }}
These can also be combined in any combination:
{{ distance(123.45, 123.45, 'device_tracker.paulus') }}
-{{ distance('device_tracker.anne_therese', 'device_tracker.paulus') }}{% endraw %}
+{{ distance('device_tracker.anne_therese', 'device_tracker.paulus') }}
```
+{% endraw %}
### {% linkable_title Closest examples %}
Find entities closest to the Home Assistant location:
+{% raw %}
```text
-{% raw %}Query all entities: {{ closest(states) }}
+Query all entities: {{ closest(states) }}
Query all entities of a specific domain: {{ closest('states.device_tracker') }}
Query all entities in group.children: {{ closest('group.children') }}
-Query all entities in group.children: {{ closest(states.group.children) }}{% endraw %}
+Query all entities in group.children: {{ closest(states.group.children) }}
```
+{% endraw %}
Find entities closest to a coordinate or another entity. All previous arguments still apply for 2nd argument.
+{% raw %}
```text
-{% raw %}Closest to a coordinate: {{ closest(23.456, 23.456, 'group.children') }}
+Closest to a coordinate: {{ closest(23.456, 23.456, 'group.children') }}
Closest to an entity: {{ closest('zone.school', 'group.children') }}
-Closest to an entity: {{ closest(states.zone.school, 'group.children') }}{% endraw %}
+Closest to an entity: {{ closest(states.zone.school, 'group.children') }}
```
+{% endraw %}
### {% linkable_title Combined %}
+
Since closest returns a state, we can combine it with distance too.
+{% raw %}
```text
-{% raw %}{{ closest(states).name }} is {{ distance(closest(states)) }} kilometers away.{% endraw %}
+{{ closest(states).name }} is {{ distance(closest(states)) }} kilometers away.
```
+{% endraw %}
## {% linkable_title Processing incoming data %}
@@ -238,11 +251,13 @@ This means that if the incoming values looks like the sample below:
The template for `on` would be:
+{% raw %}
```yaml
-'{% raw %}{{value_json.on}}{% endraw %}'
+'{{value_json.on}}'
```
+{% endraw %}
-Nested JSON in a response is supported as well
+Nested JSON in a response is supported as well:
```json
{
@@ -259,10 +274,11 @@ Nested JSON in a response is supported as well
Just use the "Square bracket notation" to get the value.
+{% raw %}
```yaml
-'{% raw %}{{ value_json["values"]["temp"] }}{% endraw %}'
+'{{ value_json["values"]["temp"] }}'
```
-
+{% endraw %}
The following overview contains a couple of options to get the needed values:
@@ -294,8 +310,8 @@ The following overview contains a couple of options to get the needed values:
To evaluate a response, go to the
template developer tools, create your output into "Template", and check the result.
-```yaml
{% raw %}
+```yaml
{% set value_json=
{"name":"Outside",
"device":"weather-ha",
@@ -304,5 +320,6 @@ To evaluate a response, go to the
+Rendering templates with time (`now()`) is dangerous as trigger templates only update based on entity state changes.
+
+
### {% linkable_title Time trigger %}
Time can be triggered in many ways. The most common is to specify `at` and trigger at a specific point in time each day. Alternatively, you can also match if the hour, minute or second of the current time has a specific value. You can prefix the value with a `/` to match whenever the value is divisible by that number. You cannot use `at` together with hour, minute or second.
From ea30a52a7881dd5f83fcee700ff06085634943a1 Mon Sep 17 00:00:00 2001
From: DubhAd
Date: Sat, 11 Aug 2018 21:34:02 +0100
Subject: [PATCH 08/17] Making the warning clearer, and linkable (#5994)
Making the warning clearer (I'll add something similar to the template trigger docs), and putting a title in so that we can link to it.
---
source/_docs/configuration/templating.markdown | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown
index f627d2ea834a..69ad76211bf2 100644
--- a/source/_docs/configuration/templating.markdown
+++ b/source/_docs/configuration/templating.markdown
@@ -99,8 +99,10 @@ Home Assistant adds extensions to allow templates to access all of the current s
If your template uses an `entity_id` that begins with a number (example: `states.device_tracker.2008_gmc`) you must use a bracket syntax to avoid errors caused by rendering the `entity_id` improperly. In the example given, the correct syntax for the device tracker would be: `states.device_tracker['2008_gmc']`
+## {% linkable_title Templates using `now()` %}
+
-Rendering templates with time is dangerous as updates only trigger templates in sensors based on entity state changes.
+Rendering templates with time (`now()`) is dangerous as updates only trigger templates in sensors based on entity state changes.
## {% linkable_title Home Assistant template extensions %}
From 7ef5c43c373e09f6e9647839fd0114d050b74692 Mon Sep 17 00:00:00 2001
From: endor-force <1937941+endor-force@users.noreply.github.com>
Date: Sun, 12 Aug 2018 12:21:28 +0200
Subject: [PATCH 09/17] Update for precipitation instructions
Added precipitation type as possible object in sensor component.
---
.../sensor.trafikverket_weatherstation.markdown | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/source/_components/sensor.trafikverket_weatherstation.markdown b/source/_components/sensor.trafikverket_weatherstation.markdown
index 272c4e09941b..5ef302c60c79 100644
--- a/source/_components/sensor.trafikverket_weatherstation.markdown
+++ b/source/_components/sensor.trafikverket_weatherstation.markdown
@@ -12,11 +12,12 @@ ha_category: Sensor
ha_release: 0.66.0
---
-Showing weather information for air and road temperature provided by [Trafikverket](https://www.trafikverket.se/) in Sweden.
+Showing weather information for air and road temperature as well as precipitation provided by [Trafikverket](https://www.trafikverket.se/) in Sweden.
+Precipitation is returned as a string of text in Swedish.
Potential use cases:
- Get weather data in general
-- You live near a weather station and want to know the current temperature at home
+- You live near a weather station and want to know the current temperature or precipitation at home
- Setup automations for your car heating system. If the road is frozen along the way to work, you might want the car heating system to start earlier.
##### {% linkable_title Configuration %}
@@ -46,7 +47,7 @@ station:
required: true
type: string
type:
- description: Defines which temperature you want (`air` or `road`).
+ description: Defines which data you want (`air`, `road` or `precipitation`).
required: true
type: string
scan_interval:
@@ -83,4 +84,10 @@ sensor:
station: Lanna
type: air
scan_interval: 600
+ - platform: trafikverket_weatherstation
+ name: Trafikverket Precipitation WeatherStation Nöbbele
+ api_key: eXXcbXXXacXXXXc39XX3aXXX4aXX46XX
+ station: Nöbbele
+ type: precipitation
+ scan_interval: 600
```
From f99099988087de76b3535a1ac318814b7f9923d2 Mon Sep 17 00:00:00 2001
From: DubhAd
Date: Sat, 11 Aug 2018 13:16:52 +0100
Subject: [PATCH 10/17] Minor changes (#5990)
Taking out the "new and experimental" note - we're a dozen releases on, it's hardly new and seems to be (from a feature sense) stable.
Re-written para 2 to reflect that HA needs shut down, and that 0.75 introduced the "future" UI. Re-written the supported components list because it's horribly out of date, and without trawling the code it's impossible to know what's supported.
---
.../_docs/configuration/entity-registry.markdown | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/source/_docs/configuration/entity-registry.markdown b/source/_docs/configuration/entity-registry.markdown
index b6183f7b76b9..2f29afc306cc 100644
--- a/source/_docs/configuration/entity-registry.markdown
+++ b/source/_docs/configuration/entity-registry.markdown
@@ -9,17 +9,14 @@ sharing: true
footer: true
---
-
-This is a new and experimental feature of Home Assistant.
-
-
Starting with version 0.63, Home Assistant keeps a registry of known entities.
The entity registry makes sure that entities get unique identifiers and allow
customizing the identifiers and names of these entities.
-As this is still a very new part of Home Assistant, changes will require a
-restart of Home Assistant to take effect. A config user interface will be added
-in a future version.
+Changes require that Home Assistant is shut down when you edit the file, otherwise
+Home Assistant may over-write your changes, and a restart of Home Assistant is
+required for your changes to take effect. Version 0.75 introduced a configuration
+user interface.
An entity needs to have a unique ID to be registered in the entity registry.
@@ -55,5 +52,6 @@ value to each entry.
{% linkable_title Supported Components %}
-At the moment, only the following components are supported: Z-Wave, Hue, Nest, LIFX, Sonos, Apple TV, Weather Underground
+Only components that provide a unique ID for entities will are supported.
+
Note that for Weather Underground, second and subsequent Personal Weather Station ID (pws_id) will have their monitored conditions suffixed with an index number.
From 8ce25b90eb07ff1ce2317a60fe3a5d7accc4dde0 Mon Sep 17 00:00:00 2001
From: Fabian Affolter
Date: Sat, 11 Aug 2018 14:20:33 +0200
Subject: [PATCH 11/17] Remove line braks
---
.../configuration/entity-registry.markdown | 23 ++++++-------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/source/_docs/configuration/entity-registry.markdown b/source/_docs/configuration/entity-registry.markdown
index 2f29afc306cc..b699bb979eb4 100644
--- a/source/_docs/configuration/entity-registry.markdown
+++ b/source/_docs/configuration/entity-registry.markdown
@@ -9,24 +9,18 @@ sharing: true
footer: true
---
-Starting with version 0.63, Home Assistant keeps a registry of known entities.
-The entity registry makes sure that entities get unique identifiers and allow
-customizing the identifiers and names of these entities.
+Starting with version 0.63, Home Assistant keeps a registry of known entities. The entity registry makes sure that entities get unique identifiers and allow customizing the identifiers and names of these entities.
-Changes require that Home Assistant is shut down when you edit the file, otherwise
-Home Assistant may over-write your changes, and a restart of Home Assistant is
-required for your changes to take effect. Version 0.75 introduced a configuration
-user interface.
+Changes require that Home Assistant is shut down when you edit the file, otherwise Home Assistant may over-write your changes, and a restart of Home Assistant is required for your changes to take effect. Version 0.75 introduced a configuration user interface.
An entity needs to have a unique ID to be registered in the entity registry.
Not all integrations currently provide a unique id for their entities.
-The entity registry is stored in `/entity_registry.yaml`. As a user,
-you are unable to add entries, only update them. Here is an example file:
+The entity registry is stored in `/entity_registry.yaml`. As a user, you are unable to add entries, only update them. Here is an example file:
-```
+```yaml
climate.downstairs_virtual:
platform: nest
unique_id: EPoMyWkpNyoYu3pGlmGxabcdefghijkl
@@ -37,16 +31,13 @@ light.study_ceiling:
disabled_by: user
```
-As a user, you can change the `entity_id` and add the `name` and `disabled_by`
-value to each entry.
- - Changing the _first line_ of each entry will change the `entity_id` of the entity throughout Home Assistant.
+As a user, you can change the `entity_id` and add the `name` and `disabled_by`value to each entry.
+ - Changing the _first line_ of each entry will change the `entity_id` of the entity throughout Home Assistant.
- The value of `name` will override the _friendly name_ of the entity as given by the integration.
_Added in Home Assistant 0.64._
- - The key `disabled_by` can either be `hass` or `user`. This functionality
- is even more experimental than the whole entity registry itself and might
- cause integrations to fail and might be removed in the future.
+ - The key `disabled_by` can either be `hass` or `user`. This functionality is even more experimental than the whole entity registry itself and might cause integrations to fail and might be removed in the future.
_Added in Home Assistant 0.64._
From 67f65ce6cea568ae8e61f55e83796b884c871eb2 Mon Sep 17 00:00:00 2001
From: Fabian Affolter
Date: Sat, 11 Aug 2018 14:28:32 +0200
Subject: [PATCH 12/17] Update style
---
.../_docs/configuration/templating.markdown | 83 +++++++++++--------
1 file changed, 50 insertions(+), 33 deletions(-)
diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown
index eea6b7c46df7..f627d2ea834a 100644
--- a/source/_docs/configuration/templating.markdown
+++ b/source/_docs/configuration/templating.markdown
@@ -17,16 +17,9 @@ This is an advanced feature of Home Assistant. You'll need a basic understanding
Templating is a powerful feature in Home Assistant that allows the user control over information that is going into and out of the system. It is used for:
-- Formatting outgoing messages in, for example, the [notify] and [alexa] components.
-- Process incoming data from sources that provide raw data, like [MQTT], [REST sensor], or the [command line sensor].
-- [Automation Templating].
-
-[notify]: /components/notify/
-[alexa]: /components/alexa/
-[MQTT]: /components/mqtt/
-[REST sensor]: /components/sensor.rest/
-[command line sensor]: /components/sensor.command_line/
-[Automation Templating]: /docs/automation/templating/
+- Formatting outgoing messages in, for example, the [notify](/components/notify/) platforms and [alexa](/components/alexa/) component.
+- Process incoming data from sources that provide raw data, like [MQTT](/components/mqtt/), [`rest` sensor](/components/sensor.rest/) or the [`command_line` sensor](/components/sensor.command_line/).
+- [Automation Templating](/docs/automation/templating/).
## {% linkable_title Building templates %}
@@ -38,6 +31,7 @@ The frontend has a template editor developer tool to help develop and debug temp
Templates can get big pretty fast. To keep a clear overview, consider using YAML multiline strings to define your templates:
+{% raw %}
```yaml
script:
msg_who_is_home:
@@ -45,12 +39,13 @@ script:
- service: notify.notify
data_template:
message: >
- {% raw %}{% if is_state('device_tracker.paulus', 'home') %}
+ {% if is_state('device_tracker.paulus', 'home') %}
Ha, Paulus is home!
{% else %}
Paulus is at {{ states('device_tracker.paulus') }}.
- {% endif %}{% endraw %}
+ {% endif %}
```
+{% endraw %}
[Jinja2](http://jinja.pocoo.org/) supports a wide variety of operations:
@@ -117,43 +112,51 @@ In templates, besides the normal [state object methods and properties](/topics/s
## {% linkable_title Examples %}
### {% linkable_title States %}
+
The next two statements result in same value if state exists. The second one will result in an error if state does not exist.
+{% raw %}
```text
-{% raw %}{{ states('device_tracker.paulus') }}
-{{ states.device_tracker.paulus.state }}{% endraw %}
+{{ states('device_tracker.paulus') }}
+{{ states.device_tracker.paulus.state }}
```
+{% endraw %}
### {% linkable_title Attributes %}
Print an attribute if state is defined. Both will return the same thing but the last one you can specify entity_id from a variable.
+{% raw %}
```text
-{% raw %}{% if states.device_tracker.paulus %}
+{% if states.device_tracker.paulus %}
{{ states.device_tracker.paulus.attributes.battery }}
{% else %}
??
-{% endif %}{% endraw %}
+{% endif %}
```
+{% endraw %}
With strings
+{% raw %}
```text
-{% raw %}{% set tracker_name = "paulus"%}
+{% set tracker_name = "paulus"%}
{% if states("device_tracker." + tracker_name) != "unknown" %}
{{ state_attr("device_tracker." + tracker_name, "battery")}}
{% else %}
??
-{% endif %}{% endraw %}
+{% endif %}
```
+{% endraw %}
### {% linkable_title Sensor states %}
Print out a list of all the sensor states.
+{% raw %}
```text
-{% raw %}{% for state in states.sensor %}
+{% for state in states.sensor %}
{{ state.entity_id }}={{ state.state }},
{% endfor %}
@@ -173,48 +176,58 @@ Print out a list of all the sensor states.
{{ as_timestamp(states.binary_sensor.garage_door.last_changed) }}
-{{ as_timestamp(now()) - as_timestamp(states.binary_sensor.garage_door.last_changed) }}{% endraw %}
+{{ as_timestamp(now()) - as_timestamp(states.binary_sensor.garage_door.last_changed) }}
```
+{% endraw %}
### {% linkable_title Distance examples %}
If only 1 location is passed in, Home Assistant will measure the distance from home.
+{% raw %}
```text
-{% raw %}Using Lat Lng coordinates: {{ distance(123.45, 123.45) }}
+Using Lat Lng coordinates: {{ distance(123.45, 123.45) }}
Using State: {{ distance(states.device_tracker.paulus) }}
These can also be combined in any combination:
{{ distance(123.45, 123.45, 'device_tracker.paulus') }}
-{{ distance('device_tracker.anne_therese', 'device_tracker.paulus') }}{% endraw %}
+{{ distance('device_tracker.anne_therese', 'device_tracker.paulus') }}
```
+{% endraw %}
### {% linkable_title Closest examples %}
Find entities closest to the Home Assistant location:
+{% raw %}
```text
-{% raw %}Query all entities: {{ closest(states) }}
+Query all entities: {{ closest(states) }}
Query all entities of a specific domain: {{ closest('states.device_tracker') }}
Query all entities in group.children: {{ closest('group.children') }}
-Query all entities in group.children: {{ closest(states.group.children) }}{% endraw %}
+Query all entities in group.children: {{ closest(states.group.children) }}
```
+{% endraw %}
Find entities closest to a coordinate or another entity. All previous arguments still apply for 2nd argument.
+{% raw %}
```text
-{% raw %}Closest to a coordinate: {{ closest(23.456, 23.456, 'group.children') }}
+Closest to a coordinate: {{ closest(23.456, 23.456, 'group.children') }}
Closest to an entity: {{ closest('zone.school', 'group.children') }}
-Closest to an entity: {{ closest(states.zone.school, 'group.children') }}{% endraw %}
+Closest to an entity: {{ closest(states.zone.school, 'group.children') }}
```
+{% endraw %}
### {% linkable_title Combined %}
+
Since closest returns a state, we can combine it with distance too.
+{% raw %}
```text
-{% raw %}{{ closest(states).name }} is {{ distance(closest(states)) }} kilometers away.{% endraw %}
+{{ closest(states).name }} is {{ distance(closest(states)) }} kilometers away.
```
+{% endraw %}
## {% linkable_title Processing incoming data %}
@@ -238,11 +251,13 @@ This means that if the incoming values looks like the sample below:
The template for `on` would be:
+{% raw %}
```yaml
-'{% raw %}{{value_json.on}}{% endraw %}'
+'{{value_json.on}}'
```
+{% endraw %}
-Nested JSON in a response is supported as well
+Nested JSON in a response is supported as well:
```json
{
@@ -259,10 +274,11 @@ Nested JSON in a response is supported as well
Just use the "Square bracket notation" to get the value.
+{% raw %}
```yaml
-'{% raw %}{{ value_json["values"]["temp"] }}{% endraw %}'
+'{{ value_json["values"]["temp"] }}'
```
-
+{% endraw %}
The following overview contains a couple of options to get the needed values:
@@ -294,8 +310,8 @@ The following overview contains a couple of options to get the needed values:
To evaluate a response, go to the
template developer tools, create your output into "Template", and check the result.
-```yaml
{% raw %}
+```yaml
{% set value_json=
{"name":"Outside",
"device":"weather-ha",
@@ -304,5 +320,6 @@ To evaluate a response, go to the
+Rendering templates with time (`now()`) is dangerous as trigger templates only update based on entity state changes.
+
+
### {% linkable_title Time trigger %}
Time can be triggered in many ways. The most common is to specify `at` and trigger at a specific point in time each day. Alternatively, you can also match if the hour, minute or second of the current time has a specific value. You can prefix the value with a `/` to match whenever the value is divisible by that number. You cannot use `at` together with hour, minute or second.
From 5638bd21358db705dd8f1427b01fecee1f1b293c Mon Sep 17 00:00:00 2001
From: DubhAd
Date: Sat, 11 Aug 2018 21:34:02 +0100
Subject: [PATCH 16/17] Making the warning clearer, and linkable (#5994)
Making the warning clearer (I'll add something similar to the template trigger docs), and putting a title in so that we can link to it.
---
source/_docs/configuration/templating.markdown | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown
index f627d2ea834a..69ad76211bf2 100644
--- a/source/_docs/configuration/templating.markdown
+++ b/source/_docs/configuration/templating.markdown
@@ -99,8 +99,10 @@ Home Assistant adds extensions to allow templates to access all of the current s
If your template uses an `entity_id` that begins with a number (example: `states.device_tracker.2008_gmc`) you must use a bracket syntax to avoid errors caused by rendering the `entity_id` improperly. In the example given, the correct syntax for the device tracker would be: `states.device_tracker['2008_gmc']`
+## {% linkable_title Templates using `now()` %}
+
-Rendering templates with time is dangerous as updates only trigger templates in sensors based on entity state changes.
+Rendering templates with time (`now()`) is dangerous as updates only trigger templates in sensors based on entity state changes.
## {% linkable_title Home Assistant template extensions %}
From 175d3a27e2482c18ff8597cc802d0390e721b9e6 Mon Sep 17 00:00:00 2001
From: endor-force <1937941+endor-force@users.noreply.github.com>
Date: Sun, 12 Aug 2018 12:21:28 +0200
Subject: [PATCH 17/17] Update for precipitation instructions
Added precipitation type as possible object in sensor component.
---
.../sensor.trafikverket_weatherstation.markdown | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/source/_components/sensor.trafikverket_weatherstation.markdown b/source/_components/sensor.trafikverket_weatherstation.markdown
index 272c4e09941b..5ef302c60c79 100644
--- a/source/_components/sensor.trafikverket_weatherstation.markdown
+++ b/source/_components/sensor.trafikverket_weatherstation.markdown
@@ -12,11 +12,12 @@ ha_category: Sensor
ha_release: 0.66.0
---
-Showing weather information for air and road temperature provided by [Trafikverket](https://www.trafikverket.se/) in Sweden.
+Showing weather information for air and road temperature as well as precipitation provided by [Trafikverket](https://www.trafikverket.se/) in Sweden.
+Precipitation is returned as a string of text in Swedish.
Potential use cases:
- Get weather data in general
-- You live near a weather station and want to know the current temperature at home
+- You live near a weather station and want to know the current temperature or precipitation at home
- Setup automations for your car heating system. If the road is frozen along the way to work, you might want the car heating system to start earlier.
##### {% linkable_title Configuration %}
@@ -46,7 +47,7 @@ station:
required: true
type: string
type:
- description: Defines which temperature you want (`air` or `road`).
+ description: Defines which data you want (`air`, `road` or `precipitation`).
required: true
type: string
scan_interval:
@@ -83,4 +84,10 @@ sensor:
station: Lanna
type: air
scan_interval: 600
+ - platform: trafikverket_weatherstation
+ name: Trafikverket Precipitation WeatherStation Nöbbele
+ api_key: eXXcbXXXacXXXXc39XX3aXXX4aXX46XX
+ station: Nöbbele
+ type: precipitation
+ scan_interval: 600
```