Update YAML standards for automation pages (#16488)

This commit is contained in:
Franck Nijhof 2021-02-10 13:56:13 +01:00 committed by GitHub
parent af597b955b
commit db2a9a4a5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 24 deletions

View File

@ -53,7 +53,7 @@ automation:
action: action:
- service: notify.notify - service: notify.notify
data: data:
message: Testing conditional actions message: "Testing conditional actions"
- condition: or - condition: or
conditions: conditions:
- condition: numeric_state - condition: numeric_state
@ -64,5 +64,6 @@ automation:
entity_id: sensor.office_illuminance entity_id: sensor.office_illuminance
below: 10 below: 10
- service: scene.turn_on - service: scene.turn_on
target:
entity_id: scene.office_at_evening entity_id: scene.office_at_evening
``` ```

View File

@ -21,12 +21,16 @@ automation:
condition: condition:
condition: or condition: or
conditions: conditions:
- condition: template - condition: numeric_state
value_template: "{{ state_attr('sun.sun', 'elevation') < 4 }}" entity_id: sun.sun
- condition: template attribute: elevation
value_template: "{{ states('sensor.sensorluz_7_0') < 10 }}" below: 4
- condition: numeric_state
entity_id: sensor.sensorluz_7_0
below: 10
action: action:
- service: scene.turn_on - service: scene.turn_on
target:
entity_id: scene.DespiertaDespacho entity_id: scene.DespiertaDespacho
``` ```
@ -46,6 +50,7 @@ automation:
condition: "{{ state_attr('sun.sun', 'elevation') < 4 }}" condition: "{{ state_attr('sun.sun', 'elevation') < 4 }}"
action: action:
- service: scene.turn_on - service: scene.turn_on
target:
entity_id: scene.DespiertaDespacho entity_id: scene.DespiertaDespacho
``` ```

View File

@ -30,4 +30,3 @@ message: Sensor value greater than 10
``` ```
Don't forget to save your new automation rule. For your saved automation rule to come into effect, you will need to go to the **Configuration** page and click on **Reload Automation**. Don't forget to save your new automation rule. For your saved automation rule to come into effect, you will need to go to the **Configuration** page and click on **Reload Automation**.

View File

@ -10,11 +10,13 @@ Automations support [templating](/docs/configuration/templating/) in the same wa
Be aware that if you reference a `trigger` state object in templates of an automation' `action` or `condition` sections, 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 check that the templates work as expected by pasting them in Developer Tools > Template together with your trigger's definition like: Be aware that if you reference a `trigger` state object in templates of an automation' `action` or `condition` sections, 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 check that the templates work as expected by pasting them in Developer Tools > Template together with your trigger's definition like:
{%raw%} {%raw%}
```yaml ```yaml
{% set trigger={'to_state':{'state': 'heat'}} %} {% set trigger={'to_state':{'state': 'heat'}} %}
{% set option = trigger.to_state.state %} {% set option = trigger.to_state.state %}
{{ 'on' if option == 'heat' else 'off' }} {{ 'on' if option == 'heat' else 'off' }}
``` ```
{%endraw%} {%endraw%}
</div> </div>
@ -119,6 +121,7 @@ The following tables show the available trigger data per platform.
## Examples ## Examples
{% raw %} {% raw %}
```yaml ```yaml
# Example configuration.yaml entries # Example configuration.yaml entries
automation: automation:
@ -155,10 +158,11 @@ automation 3:
for: "00:10:00" for: "00:10:00"
action: action:
- service: light.turn_off - service: light.turn_off
data: target:
# Turn off whichever entity triggered the automation. # Turn off whichever entity triggered the automation.
entity_id: "{{ trigger.entity_id }}" entity_id: "{{ trigger.entity_id }}"
``` ```
{% endraw %} {% endraw %}
[state object]: /docs/configuration/state_object/ [state object]: /docs/configuration/state_object/

View File

@ -6,6 +6,7 @@ description: "How to create automations based off blueprints."
Automation blueprints are pre-made automations that you can easily add to your Home Assistant instance. Each blueprint can be added as many times as you want. Automation blueprints are pre-made automations that you can easily add to your Home Assistant instance. Each blueprint can be added as many times as you want.
Quick links: Quick links:
- [Blueprints in the Home Assistant forums][blueprint-forums] - [Blueprints in the Home Assistant forums][blueprint-forums]
## Blueprint Automations ## Blueprint Automations

View File

@ -26,6 +26,7 @@ You can add as many labeled `automation` blocks as you want.
Example of a YAML based automation that you can add to `configuration.yaml`. Example of a YAML based automation that you can add to `configuration.yaml`.
{% raw %} {% raw %}
```yaml ```yaml
# Example of entry in configuration.yaml # Example of entry in configuration.yaml
automation my_lights: automation my_lights:
@ -53,6 +54,7 @@ automation my_lights:
action: action:
# With a single service call, we don't need a '-' before service - though you can if you want to # With a single service call, we don't need a '-' before service - though you can if you want to
service: homeassistant.turn_on service: homeassistant.turn_on
target:
entity_id: group.living_room entity_id: group.living_room
# Turn off lights when everybody leaves the house # Turn off lights when everybody leaves the house
@ -63,6 +65,7 @@ automation my_lights:
to: "not_home" to: "not_home"
action: action:
service: light.turn_off service: light.turn_off
target:
entity_id: all entity_id: all
# Notify when Paulus leaves the house in the evening # Notify when Paulus leaves the house in the evening
@ -94,6 +97,7 @@ automation my_lights:
title: "Cube event detected" title: "Cube event detected"
message: "Cube has triggered this event: {{ trigger.event }}" message: "Cube has triggered this event: {{ trigger.event }}"
``` ```
{% endraw %} {% endraw %}