Files
.devcontainer
.github
.theia
.vscode
plugins
sass
source
.well-known
_addons
_cookbook
_data
_docs
authentication
automation
action.markdown
condition.markdown
editor.markdown
examples.markdown
templating.markdown
trigger.markdown
troubleshooting.markdown
autostart
backend
configuration
ecosystem
frontend
installation
mqtt
scene
scripts
security
tools
z-wave
asterisk_mbox.markdown
authentication.markdown
automation.markdown
autostart.markdown
backend.markdown
configuration.markdown
ecosystem.markdown
frontend.markdown
glossary.markdown
installation.markdown
mqtt.markdown
quality_scale.markdown
scene.markdown
scripts.markdown
security.markdown
tools.markdown
z-wave.markdown
_faq
_includes
_integrations
_layouts
_lovelace
_posts
addons
android
assets
blog
cloud
code_of_conduct
cookbook
demo
developers
docs
faq
font
getting-started
hassio
help
images
integrations
ios
javascripts
join-chat
latest-release-notes
lovelace
privacy
security
static
stylesheets
tos
CNAME
_headers
_redirects
atom.xml
favicon.png
googlef4f3693c209fe788.html
index.html
robots.txt
service_worker.js
version.json
.editorconfig
.gitattributes
.gitignore
.gitpod.yml
.markdownlint.json
.nvmrc
.powrc
.remarkignore
.remarkrc.js
.ruby-version
.slugignore
CLA.md
CODE_OF_CONDUCT.md
Gemfile
Gemfile.lock
LICENSE.md
README.md
Rakefile
_config.yml
config.rb
config.ru
package-lock.json
package.json
home-assistant.io/source/_docs/automation/examples.markdown
Franck Nijhof 1833c32a2c Cleans up front matter ()
* Sets front matter defaults

* Removes default front matter from section templates/pages

* Removes default front matter from addon pages

* Removes default front matter from integration pages

* Removes default front matter from posts

* Removes default front matter from docs pages

* Removes default front matter from other pages

* Fixes blog category pages
2019-07-11 14:35:08 -07:00

80 lines
2.2 KiB
Markdown

---
title: "Automation Examples"
description: "Some automation examples to get you started."
redirect_from: /getting-started/automation-examples/
---
Just some sample automation rules to get you started.
{% raw %}
```yaml
# Example of entry in configuration.yaml
automation:
# Turns on lights 1 hour before sunset if people are home
# and if people get home between 16:00-23:00
- alias: 'Rule 1 Light on in the evening'
trigger:
# Prefix the first line of each trigger configuration
# with a '-' to enter multiple
- platform: sun
event: sunset
offset: '-01:00:00'
- platform: state
entity_id: group.all_devices
to: 'home'
condition:
# Prefix the first line of each condition configuration
# with a '-'' to enter multiple
- condition: state
entity_id: group.all_devices
state: 'home'
- condition: time
after: '16:00:00'
before: '23:00:00'
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
# Turn off lights when everybody leaves the house
- alias: 'Rule 2 - Away Mode'
trigger:
platform: state
entity_id: group.all_devices
to: 'not_home'
action:
service: light.turn_off
entity_id: group.all_lights
# Notify when Paulus leaves the house in the evening
- alias: 'Leave Home notification'
trigger:
platform: zone
event: leave
zone: zone.home
entity_id: device_tracker.paulus
condition:
condition: time
after: '20:00'
action:
service: notify.notify
data:
message: 'Paulus left the house'
# Send a notification via Pushover with the event of a Xiaomi cube. Custom event from the Xiaomi component.
- alias: 'Xiaomi Cube Action'
hide_entity: false
initial_state: false
trigger:
platform: event
event_type: cube_action
event_data:
entity_id: binary_sensor.cube_158d000103a3de
action:
service_template: notify.pushover
data_template:
title: "Cube event detected"
message: "Cube has triggered this event: {{ trigger.event }}"
```
{% endraw %}