Skip to content

Commit

Permalink
Improve YAML styling for all automation examples (#34932)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Sep 26, 2024
1 parent 596d841 commit f10f777
Show file tree
Hide file tree
Showing 141 changed files with 1,921 additions and 1,967 deletions.
2 changes: 1 addition & 1 deletion source/_docs/automation/condition.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ automation:
- trigger: state
entity_id: sensor.office_motion_sensor
to: "on"
condition: "{{ state_attr('sun.sun', 'elevation') < 4 }}"
conditions: "{{ state_attr('sun.sun', 'elevation') < 4 }}"
actions:
- action: scene.turn_on
target:
Expand Down
8 changes: 4 additions & 4 deletions source/_docs/automation/templating.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ automation 2:
- trigger: mqtt
topic: "/notify/+"
actions:
action: >
notify.{{ trigger.topic.split('/')[-1] }}
data:
message: "{{ trigger.payload }}"
- action: >
notify.{{ trigger.topic.split('/')[-1] }}
data:
message: "{{ trigger.payload }}"
automation 3:
triggers:
Expand Down
8 changes: 4 additions & 4 deletions source/_docs/blueprint/schema.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ actions:
- action: light.turn_on
target: !input light_target
- wait_for_trigger:
trigger: state
entity_id: !input motion_entity
from: "on"
to: "off"
- trigger: state
entity_id: !input motion_entity
from: "on"
to: "off"
- delay: !input no_motion_wait
- action: light.turn_off
target: !input light_target
Expand Down
38 changes: 19 additions & 19 deletions source/_docs/blueprint/tutorial.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ The automation we're going to use in this tutorial controls a light based on a m

```yaml
triggers:
trigger: state
entity_id: binary_sensor.motion_kitchen
- trigger: state
entity_id: binary_sensor.motion_kitchen

actions:
action: >
{% if trigger.to_state.state == "on" %}
light.turn_on
{% else %}
light.turn_off
{% endif %}
target:
entity_id: light.kitchen
- action: >
{% if trigger.to_state.state == "on" %}
light.turn_on
{% else %}
light.turn_off
{% endif %}
target:
entity_id: light.kitchen
```
{% endraw %}
Expand Down Expand Up @@ -92,8 +92,8 @@ Configurable parts in blueprints are called [inputs](/docs/blueprint/schema/#blu

```yaml
triggers:
trigger: state
entity_id: !input motion_sensor
- trigger: state
entity_id: !input motion_sensor
```

For the light, we can offer some more flexibility. We want to allow the user to be able to define any device or area as the target. The `target` property in the action can contain references to areas, devices, and/or entities, so that's what we will use.
Expand All @@ -104,13 +104,13 @@ Inputs are not limited to strings. They can contain complex objects too. So in t

```yaml
actions:
action: >
{% if trigger.to_state.state == "on" %}
light.turn_on
{% else %}
light.turn_off
{% endif %}
target: !input target_light
- action: >
{% if trigger.to_state.state == "on" %}
light.turn_on
{% else %}
light.turn_off
{% endif %}
target: !input target_light
```

{% endraw %}
Expand Down
48 changes: 24 additions & 24 deletions source/_docs/configuration/splitting_configuration.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -268,22 +268,22 @@ These work recursively. As an example using `!include_dir_list automation`, will
automation:
- alias: "Automation 1"
triggers:
trigger: state
entity_id: device_tracker.iphone
to: "home"
- trigger: state
entity_id: device_tracker.iphone
to: "home"
actions:
action: light.turn_on
target:
entity_id: light.entryway
- action: light.turn_on
target:
entity_id: light.entryway
- alias: "Automation 2"
triggers:
trigger: state
entity_id: device_tracker.iphone
from: "home"
- trigger: state
entity_id: device_tracker.iphone
from: "home"
actions:
action: light.turn_off
target:
entity_id: light.entryway
- action: light.turn_off
target:
entity_id: light.entryway
```

can be turned into:
Expand All @@ -299,27 +299,27 @@ automation: !include_dir_list automation/presence/
```yaml
alias: "Automation 1"
triggers:
trigger: state
entity_id: device_tracker.iphone
to: "home"
- trigger: state
entity_id: device_tracker.iphone
to: "home"
actions:
action: light.turn_on
target:
entity_id: light.entryway
- action: light.turn_on
target:
entity_id: light.entryway
```

`automation/presence/automation2.yaml`

```yaml
alias: "Automation 2"
triggers:
trigger: state
entity_id: device_tracker.iphone
from: "home"
- trigger: state
entity_id: device_tracker.iphone
from: "home"
actions:
action: light.turn_off
target:
entity_id: light.entryway
- action: light.turn_off
target:
entity_id: light.entryway
```

It is important to note that each file must contain only **one** entry when using `!include_dir_list`.
Expand Down
60 changes: 30 additions & 30 deletions source/_docs/scene.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ Scenes can be activated using the action `scene.turn_on` (there is no 'scene.tur
# Example automation
automation:
triggers:
trigger: state
entity_id: device_tracker.sweetheart
from: "not_home"
to: "home"
- trigger: state
entity_id: device_tracker.sweetheart
from: "not_home"
to: "home"
actions:
action: scene.turn_on
target:
entity_id: scene.romantic
- action: scene.turn_on
target:
entity_id: scene.romantic
```

## Applying a scene without defining it
Expand All @@ -76,21 +76,21 @@ With the `scene.apply` action you are able to apply a scene without first defini
# Example automation
automation:
triggers:
trigger: state
entity_id: device_tracker.sweetheart
from: "not_home"
to: "home"
- trigger: state
entity_id: device_tracker.sweetheart
from: "not_home"
to: "home"
actions:
action: scene.apply
data:
entities:
light.tv_back_light:
state: "on"
brightness: 100
light.ceiling: off
media_player.sony_bravia_tv:
state: "on"
source: HDMI 1
- action: scene.apply
data:
entities:
light.tv_back_light:
state: "on"
brightness: 100
light.ceiling: off
media_player.sony_bravia_tv:
state: "on"
source: "HDMI 1"
```

## Using scene transitions
Expand All @@ -105,16 +105,16 @@ light will transition to the scene in 2.5 seconds.
# Example automation
automation:
triggers:
trigger: state
entity_id: device_tracker.sweetheart
from: "not_home"
to: "home"
- trigger: state
entity_id: device_tracker.sweetheart
from: "not_home"
to: "home"
actions:
action: scene.turn_on
target:
entity_id: scene.romantic
data:
transition: 2.5
- action: scene.turn_on
target:
entity_id: scene.romantic
data:
transition: 2.5
```

Transitions are currently only support by lights, which in their turn, have
Expand Down
1 change: 0 additions & 1 deletion source/_docs/scripts.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ automation:
- condition: state
entity_id: binary_sensor.something
state: "off"
mode: single
actions:
- alias: "Repeat the sequence UNTIL the conditions are true"
repeat:
Expand Down
Loading

0 comments on commit f10f777

Please sign in to comment.