mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-16 13:56:53 +00:00
Update YAML standards for automation pages (#16488)
This commit is contained in:
parent
af597b955b
commit
db2a9a4a5a
@ -53,7 +53,7 @@ automation:
|
||||
action:
|
||||
- service: notify.notify
|
||||
data:
|
||||
message: Testing conditional actions
|
||||
message: "Testing conditional actions"
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: numeric_state
|
||||
@ -63,6 +63,7 @@ automation:
|
||||
- condition: state
|
||||
entity_id: sensor.office_illuminance
|
||||
below: 10
|
||||
- service: scene.turn_on
|
||||
entity_id: scene.office_at_evening
|
||||
- service: scene.turn_on
|
||||
target:
|
||||
entity_id: scene.office_at_evening
|
||||
```
|
||||
|
@ -21,13 +21,17 @@ automation:
|
||||
condition:
|
||||
condition: or
|
||||
conditions:
|
||||
- condition: template
|
||||
value_template: "{{ state_attr('sun.sun', 'elevation') < 4 }}"
|
||||
- condition: template
|
||||
value_template: "{{ states('sensor.sensorluz_7_0') < 10 }}"
|
||||
- condition: numeric_state
|
||||
entity_id: sun.sun
|
||||
attribute: elevation
|
||||
below: 4
|
||||
- condition: numeric_state
|
||||
entity_id: sensor.sensorluz_7_0
|
||||
below: 10
|
||||
action:
|
||||
- service: scene.turn_on
|
||||
entity_id: scene.DespiertaDespacho
|
||||
target:
|
||||
entity_id: scene.DespiertaDespacho
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
@ -46,7 +50,8 @@ automation:
|
||||
condition: "{{ state_attr('sun.sun', 'elevation') < 4 }}"
|
||||
action:
|
||||
- service: scene.turn_on
|
||||
entity_id: scene.DespiertaDespacho
|
||||
target:
|
||||
entity_id: scene.DespiertaDespacho
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
@ -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**.
|
||||
|
||||
|
@ -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:
|
||||
|
||||
{%raw%}
|
||||
|
||||
```yaml
|
||||
{% set trigger={'to_state':{'state': 'heat'}} %}
|
||||
{% set option = trigger.to_state.state %}
|
||||
{{ 'on' if option == 'heat' else 'off' }}
|
||||
```
|
||||
|
||||
{%endraw%}
|
||||
|
||||
</div>
|
||||
@ -119,6 +121,7 @@ The following tables show the available trigger data per platform.
|
||||
## Examples
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entries
|
||||
automation:
|
||||
@ -155,10 +158,11 @@ automation 3:
|
||||
for: "00:10:00"
|
||||
action:
|
||||
- service: light.turn_off
|
||||
data:
|
||||
target:
|
||||
# Turn off whichever entity triggered the automation.
|
||||
entity_id: "{{ trigger.entity_id }}"
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
[state object]: /docs/configuration/state_object/
|
||||
|
@ -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.
|
||||
|
||||
Quick links:
|
||||
- [Blueprints in the Home Assistant forums][blueprint-forums]
|
||||
|
||||
- [Blueprints in the Home Assistant forums][blueprint-forums]
|
||||
|
||||
## Blueprint Automations
|
||||
|
||||
|
@ -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`.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
# Example of entry in configuration.yaml
|
||||
automation my_lights:
|
||||
@ -53,7 +54,8 @@ automation my_lights:
|
||||
action:
|
||||
# With a single service call, we don't need a '-' before service - though you can if you want to
|
||||
service: homeassistant.turn_on
|
||||
entity_id: group.living_room
|
||||
target:
|
||||
entity_id: group.living_room
|
||||
|
||||
# Turn off lights when everybody leaves the house
|
||||
- alias: "Rule 2 - Away Mode"
|
||||
@ -63,7 +65,8 @@ automation my_lights:
|
||||
to: "not_home"
|
||||
action:
|
||||
service: light.turn_off
|
||||
entity_id: all
|
||||
target:
|
||||
entity_id: all
|
||||
|
||||
# Notify when Paulus leaves the house in the evening
|
||||
- alias: "Leave Home notification"
|
||||
@ -94,6 +97,7 @@ automation my_lights:
|
||||
title: "Cube event detected"
|
||||
message: "Cube has triggered this event: {{ trigger.event }}"
|
||||
```
|
||||
|
||||
{% 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.
|
||||
alias: Hello world
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: sun.sun
|
||||
from: below_horizon
|
||||
to: above_horizon
|
||||
- platform: state
|
||||
entity_id: sun.sun
|
||||
from: below_horizon
|
||||
to: above_horizon
|
||||
condition:
|
||||
- condition: numeric_state
|
||||
entity_id: sensor.temperature
|
||||
above: 17
|
||||
below: 25
|
||||
value_template: "{{ float(state.state) + 2 }}"
|
||||
- condition: numeric_state
|
||||
entity_id: sensor.temperature
|
||||
above: 17
|
||||
below: 25
|
||||
value_template: "{{ float(state.state) + 2 }}"
|
||||
action:
|
||||
- service: light.turn_on
|
||||
- service: light.turn_on
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user