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
@ -63,6 +63,7 @@ automation:
- condition: state - condition: state
entity_id: sensor.office_illuminance entity_id: sensor.office_illuminance
below: 10 below: 10
- service: scene.turn_on - service: scene.turn_on
entity_id: scene.office_at_evening target:
entity_id: scene.office_at_evening
``` ```

View File

@ -21,13 +21,17 @@ 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
entity_id: scene.DespiertaDespacho target:
entity_id: scene.DespiertaDespacho
``` ```
{% endraw %} {% endraw %}
@ -46,7 +50,8 @@ 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
entity_id: scene.DespiertaDespacho target:
entity_id: scene.DespiertaDespacho
``` ```
{% endraw %} {% endraw %}

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,7 +6,8 @@ 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,7 +54,8 @@ 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
entity_id: group.living_room target:
entity_id: group.living_room
# Turn off lights when everybody leaves the house # Turn off lights when everybody leaves the house
- alias: "Rule 2 - Away Mode" - alias: "Rule 2 - Away Mode"
@ -63,7 +65,8 @@ automation my_lights:
to: "not_home" to: "not_home"
action: action:
service: light.turn_off service: light.turn_off
entity_id: all target:
entity_id: all
# Notify when Paulus leaves the house in the evening # Notify when Paulus leaves the house in the evening
- alias: "Leave Home notification" - alias: "Leave Home notification"
@ -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 %}
@ -124,18 +128,18 @@ If you want to migrate your manual automations to use the editor, you'll have to
- id: my_unique_id # <-- Required for editor to work, for automations created with the editor the id will be automatically generated. - id: my_unique_id # <-- Required for editor to work, for automations created with the editor the id will be automatically generated.
alias: Hello world alias: Hello world
trigger: trigger:
- platform: state - platform: state
entity_id: sun.sun entity_id: sun.sun
from: below_horizon from: below_horizon
to: above_horizon to: above_horizon
condition: condition:
- condition: numeric_state - condition: numeric_state
entity_id: sensor.temperature entity_id: sensor.temperature
above: 17 above: 17
below: 25 below: 25
value_template: "{{ float(state.state) + 2 }}" value_template: "{{ float(state.state) + 2 }}"
action: action:
- service: light.turn_on - service: light.turn_on
``` ```
{% endraw %} {% endraw %}