mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 17:27:19 +00:00
Replace Cookbook with Examples (#17396)
This commit is contained in:
parent
4597cfc011
commit
2a083a8633
15
Rakefile
15
Rakefile
@ -33,6 +33,8 @@ task :generate do
|
||||
abort("Generating CSS failed") unless success
|
||||
success = system "rake analytics_data"
|
||||
abort("Generating analytics data failed") unless success
|
||||
success = system "rake blueprint_exchange_data"
|
||||
abort("Generating blueprint exchange data failed") unless success
|
||||
success = system "jekyll build"
|
||||
abort("Generating site failed") unless success
|
||||
if ENV["CONTEXT"] != 'production'
|
||||
@ -68,7 +70,8 @@ task :preview, :listen do |t, args|
|
||||
puts "Starting to watch source with Jekyll and Compass."
|
||||
puts "Now listening on http://localhost:#{server_port}"
|
||||
system "compass compile --css-dir #{source_dir}/stylesheets" unless File.exist?("#{source_dir}/stylesheets/screen.css")
|
||||
success = system "rake analytics_data"
|
||||
system "rake analytics_data"
|
||||
system "rake blueprint_exchange_data"
|
||||
jekyllPid = Process.spawn({"OCTOPRESS_ENV"=>"preview"}, "jekyll build -t --watch --incremental")
|
||||
compassPid = Process.spawn("compass watch")
|
||||
rackupPid = Process.spawn("rackup --port #{server_port} --host #{listen_addr}")
|
||||
@ -184,7 +187,17 @@ task :analytics_data do
|
||||
File.open("#{source_dir}/_data/analytics_data.json", "w") do |file|
|
||||
file.write(JSON.generate(remote_data[last_entry]))
|
||||
end
|
||||
end
|
||||
|
||||
desc "Download data from the blueprint exchange @ community.home-assistant.io"
|
||||
task :blueprint_exchange_data do
|
||||
uri = URI('https://community.home-assistant.io/c/blueprints-exchange/53/l/top/all.json')
|
||||
|
||||
remote_data = JSON.parse(Net::HTTP.get(uri))
|
||||
|
||||
File.open("#{source_dir}/_data/blueprint_exchange_data.json", "w") do |file|
|
||||
file.write(JSON.generate(remote_data['topic_list']['topics']))
|
||||
end
|
||||
end
|
||||
|
||||
def get_stdin(message)
|
||||
|
@ -66,7 +66,7 @@ titlecase: true # Converts page and post titles to titlecase
|
||||
collections:
|
||||
integrations:
|
||||
output: true
|
||||
cookbook:
|
||||
examples:
|
||||
output: true
|
||||
docs:
|
||||
output: true
|
||||
|
@ -20,6 +20,6 @@
|
||||
"scripts": {
|
||||
"markdown:lint": "remark --quiet --frail .",
|
||||
"textlint:all": "textlint source",
|
||||
"textlint": "textlint source/_cookbook source/_docs source/_faq source/_integrations source/_lovelace source/cloud source/getting-started source/hassio source/lovelace"
|
||||
"textlint": "textlint source/_examples source/_docs source/_faq source/_integrations source/_lovelace source/cloud source/getting-started source/hassio source/lovelace"
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
---
|
||||
title: "Switch Philips Hue with enocean"
|
||||
description: "Automation to switch a Philips Hue lamp with an enocean switch."
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
Assume that you have an enocean wall switch and some Philips Hue lamps. The enocean wall switch will fire the event button_pressed and pass along several parameters which is used to turn on/off the lamps.
|
||||
|
||||
event_data:
|
||||
|
||||
* which
|
||||
* pushed
|
||||
* onoff
|
||||
* id
|
||||
* devname
|
||||
|
||||
```yaml
|
||||
enocean:
|
||||
device: /dev/ttyUSB0
|
||||
|
||||
binary_sensor:
|
||||
- platform: enocean
|
||||
id: [0x00,0x01,0x02,0x03]
|
||||
name: living_room_switch
|
||||
|
||||
automation:
|
||||
- alias: "Turn on living room light"
|
||||
trigger:
|
||||
platform: event
|
||||
event_type: button_pressed
|
||||
event_data:
|
||||
onoff: 1
|
||||
devname: living_room_switch
|
||||
action:
|
||||
service: light.turn_on
|
||||
target:
|
||||
entity_id: light.hue_color_lamp_3
|
||||
|
||||
- alias: "Turn off living room light"
|
||||
trigger:
|
||||
platform: event
|
||||
event_type: button_pressed
|
||||
event_data:
|
||||
onoff: 0
|
||||
devname: living_room_switch
|
||||
action:
|
||||
service: light.turn_off
|
||||
target:
|
||||
entity_id: light.hue_color_lamp_3
|
||||
```
|
@ -1,121 +0,0 @@
|
||||
---
|
||||
title: "Examples using first light"
|
||||
description: "Automation examples that trigger lights in the morning."
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
#### Create an input_boolean
|
||||
|
||||
```yaml
|
||||
input_boolean:
|
||||
trigger_first_morning:
|
||||
name: Waiting for first morning motion
|
||||
icon: mdi:kettle
|
||||
```
|
||||
|
||||
#### The Main Automation
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
## These first two control t input_boolean that allows the "first morning action" to occur
|
||||
## If the action is triggered, it will also disable this boolean. This assumes you have the sun platform enabled.
|
||||
|
||||
automation:
|
||||
#turns it on at 5am
|
||||
- alias: "Enable First Morning Trigger"
|
||||
trigger:
|
||||
- platform: time
|
||||
at: "05:00:00"
|
||||
action:
|
||||
service: homeassistant.turn_on
|
||||
target:
|
||||
entity_id: input_boolean.trigger_first_morning
|
||||
|
||||
# turns it off an hour after sunrise
|
||||
- alias: "Disable First Morning Trigger"
|
||||
trigger:
|
||||
- platform: sun
|
||||
event: sunrise
|
||||
offset: "01:00:00"
|
||||
action:
|
||||
service: homeassistant.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.trigger_first_morning
|
||||
|
||||
|
||||
|
||||
# This is the main automation. It triggers when my motion sensor is triggered
|
||||
# (in this case, a motion sensor from a security system attached to my Vera)
|
||||
- alias: "First Morning Motion"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: binary_sensor.livingroom_motion
|
||||
to: "on"
|
||||
# only complete the automation if we're still waiting for the first motion
|
||||
condition:
|
||||
condition: state
|
||||
entity_id: input_boolean.trigger_first_morning
|
||||
state: "on"
|
||||
|
||||
action:
|
||||
# turn off the "waiting" boolean regardless of whether lights will turn on
|
||||
# so that this happens only once
|
||||
- service: homeassistant.turn_off
|
||||
target:
|
||||
entity_id: input_boolean.trigger_first_morning
|
||||
|
||||
# But only turn on lights if the living room and kitchen lights are off or dimmed
|
||||
# If a condition tests false, the automation will end
|
||||
- condition: and
|
||||
conditions:
|
||||
- condition: numeric_state
|
||||
entity_id: light.livingroom_ec
|
||||
# if light is off, force a 0, otherwise use the brightness value
|
||||
value_template: '{% if is_state('light.livingroom_ec', 'on') %}{{ state_attr('light.livingroom_ec', 'brightness') }}{% else %}0{% endif %}'
|
||||
# brightness below 50% (255 = 100%)
|
||||
below: 128
|
||||
- condition: numeric_state
|
||||
entity_id: light.kitchen_bar
|
||||
value_template: '{% if is_state('light.kitchen_bar', 'on') %}{{ state_attr('light.kitchen_bar', 'brightness') }}{% else %}0{% endif %}'
|
||||
below: 128
|
||||
- condition: numeric_state
|
||||
entity_id: light.kitchen_ceiling
|
||||
value_template: '{% if is_state('light.kitchen_ceiling', 'on') %}{{ state_attr('light.kitchen_ceiling', 'brightness') }}{% else %}0{% endif %}'
|
||||
below: 128
|
||||
|
||||
# Trigger a scene
|
||||
# You could add as many services or scenes as you'd like
|
||||
- service: scene.turn_on
|
||||
target:
|
||||
entity_id: scene.morning_first_motion
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
#### The Scene
|
||||
|
||||
Here is the Scene that is called via the Automations above.
|
||||
|
||||
```yaml
|
||||
# here's the scene that gets called. Lights in
|
||||
# my living room and kitchen turn on.
|
||||
scene:
|
||||
- name: Morning First Motion
|
||||
entities:
|
||||
light.kitchen_ceiling:
|
||||
state: on
|
||||
brightness: 127
|
||||
light.kitchen_bar:
|
||||
state: on
|
||||
brightness: 178
|
||||
light.kitchen_above_cabinet:
|
||||
state: on
|
||||
brightness: 178
|
||||
light.livingroom_ec:
|
||||
state: on
|
||||
brightness: 153
|
||||
light.livingroom_track:
|
||||
state: on
|
||||
brightness: 153
|
||||
```
|
@ -1,113 +0,0 @@
|
||||
---
|
||||
title: "Examples for flashing lights"
|
||||
description: "Automation examples for flashing lights in case of an alarm."
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
#### Flashing lights triggered by an alarm
|
||||
|
||||
For flashing regular lights in case an alarm is triggered.
|
||||
|
||||
```yaml
|
||||
# AlmAct1 - switch to activate the alarm in Room1
|
||||
# AlmSnd1 - switch for a buzzer
|
||||
|
||||
automation:
|
||||
- alias: "Alarm_PIR_Room1"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: binary_sensor.PIR1
|
||||
to: "on"
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: switch.AlmAct1
|
||||
state: "on"
|
||||
- condition: state
|
||||
entity_id: script.alarm_room1
|
||||
state: "off"
|
||||
action:
|
||||
# start alarm on movement if alarm activated
|
||||
# and the alarm is not triggered
|
||||
service: script.turn_on
|
||||
target:
|
||||
entity_id: script.alarm_room1
|
||||
|
||||
- alias: "flash_room1_start"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: switch.AlmSnd1
|
||||
to: "on"
|
||||
action:
|
||||
service: script.turn_on
|
||||
target:
|
||||
entity_id: script.flash_room1
|
||||
|
||||
- alias: "flash_room1_stop"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: switch.REL1
|
||||
to: "off"
|
||||
condition:
|
||||
condition: state
|
||||
entity_id: switch.AlmSnd1
|
||||
state: "off"
|
||||
action:
|
||||
service: script.turn_off
|
||||
target:
|
||||
entity_id: script.flash_room1
|
||||
|
||||
script:
|
||||
alarm_room1:
|
||||
alias: "Alarm room1"
|
||||
sequence:
|
||||
- alias: "Alarm Room1 Start"
|
||||
service: homeassistant.turn_on
|
||||
target:
|
||||
entity_id: switch.AlmSnd1
|
||||
- alias: "Set Ack Room1"
|
||||
service: homeassistant.turn_on
|
||||
target:
|
||||
entity_id: input_boolean.ack1
|
||||
- alias: "email_Room1"
|
||||
service: notify.email
|
||||
data:
|
||||
message: "Movement alarm in Room1"
|
||||
- delay:
|
||||
# time interval for alarm sound and light flashing
|
||||
seconds: 60
|
||||
- alias: "Alarm Room1 Stop"
|
||||
service: homeassistant.turn_off
|
||||
target:
|
||||
entity_id: switch.AlmSnd1
|
||||
|
||||
flash_room1:
|
||||
alias: "Flash Room1 On"
|
||||
sequence:
|
||||
- alias: "Light Room1 On"
|
||||
service: homeassistant.turn_on
|
||||
target:
|
||||
entity_id: switch.REL1
|
||||
- delay:
|
||||
# time for flash light on
|
||||
seconds: 1
|
||||
- alias: "Light Room1 Off"
|
||||
service: homeassistant.turn_off
|
||||
target:
|
||||
entity_id: switch.REL1
|
||||
- alias: "loop_room1"
|
||||
service: script.turn_on
|
||||
target:
|
||||
entity_id: script.flash_loop
|
||||
|
||||
flash_loop:
|
||||
alias: "Flash loop"
|
||||
sequence:
|
||||
- delay:
|
||||
# time for flash light off
|
||||
seconds: 1
|
||||
- alias: "loop_room1"
|
||||
service: script.turn_on
|
||||
target:
|
||||
entity_id: script.flash_room1
|
||||
```
|
||||
|
@ -1,48 +0,0 @@
|
||||
---
|
||||
title: "Automation for rainy days"
|
||||
description: "Basic example how to use weather conditions to set states"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
This requires a [Dark Sky](/integrations/darksky) sensor with the condition `precip_intensity` that tells if it's raining or not. You could also experiment with other attributes such as `cloud_cover`.
|
||||
|
||||
Turn on a light in the living room when it starts raining, someone is home, and it's afternoon or later.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
- alias: "Rainy Day"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: sensor.precip_intensity
|
||||
to: "rain"
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: all
|
||||
state: "home"
|
||||
- condition: time
|
||||
after: "14:00"
|
||||
before: "23:00"
|
||||
action:
|
||||
service: light.turn_on
|
||||
target:
|
||||
entity_id: light.couch_lamp
|
||||
```
|
||||
|
||||
And then of course turn off the lamp when it stops raining but only if it's within an hour before sunset.
|
||||
|
||||
```yaml
|
||||
- alias: "Rain is over"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: sensor.precip_intensity
|
||||
to: "None"
|
||||
condition:
|
||||
- condition: sun
|
||||
after: "sunset"
|
||||
after_offset: "-01:00:00"
|
||||
action:
|
||||
service: light.turn_off
|
||||
target:
|
||||
entity_id: light.couch_lamp
|
||||
```
|
||||
|
@ -1,110 +0,0 @@
|
||||
---
|
||||
title: "Examples using the sun"
|
||||
description: "Automation examples that use the sun."
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
#### Turn on the living room lights 45 minutes before sunset if anyone is at home
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
offset: "-00:45:00"
|
||||
condition:
|
||||
condition: state
|
||||
entity_id: all
|
||||
state: home
|
||||
action:
|
||||
service: light.turn_on
|
||||
target:
|
||||
entity_id: group.living_room_lights
|
||||
```
|
||||
|
||||
#### Natural wake up light
|
||||
|
||||
_Note, Philips Hue and LIFX are currently the only light platforms that support transitions._
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: time
|
||||
at: "07:15:00"
|
||||
action:
|
||||
service: light.turn_on
|
||||
target:
|
||||
entity_id: light.bedroom
|
||||
data:
|
||||
# 900 seconds = 15 minutes
|
||||
transition: 900
|
||||
```
|
||||
|
||||
#### Send sun rise/sun set notifications
|
||||
|
||||
Send notifications through [PushBullet](/integrations/pushbullet) when the sun state is changed.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
- alias: "Send notification when sun rises"
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunrise
|
||||
offset: "+00:00:00"
|
||||
action:
|
||||
service: notify.pushbullet
|
||||
data:
|
||||
message: "The sun is up."
|
||||
- alias: "Send notification when sun sets"
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
offset: "+00:00:00"
|
||||
action:
|
||||
service: notify.pushbullet
|
||||
data:
|
||||
message: "The sun is down."
|
||||
```
|
||||
|
||||
#### Automations for lights and blinds based on solar elevation
|
||||
|
||||
Solar elevation automations can cope with offsets from sunset / sunrise as the seasons change better than using a time based offsets.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
- alias: "Turn a few lights on when the sun gets dim"
|
||||
trigger:
|
||||
platform: numeric_state
|
||||
entity_id: sun.sun
|
||||
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
|
||||
below: 3.5
|
||||
action:
|
||||
service: scene.turn_on
|
||||
target:
|
||||
entity_id: scene.background_lights
|
||||
|
||||
- alias: "Turn more lights on as the sun gets dimmer"
|
||||
trigger:
|
||||
platform: numeric_state
|
||||
entity_id: sun.sun
|
||||
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
|
||||
below: 1.5
|
||||
action:
|
||||
service: scene.turn_on
|
||||
target:
|
||||
entity_id: scene.more_lights
|
||||
|
||||
- alias: "Close blind at dusk"
|
||||
trigger:
|
||||
platform: numeric_state
|
||||
entity_id: sun.sun
|
||||
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
|
||||
below: -2.5
|
||||
action:
|
||||
service: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.blind
|
||||
```
|
||||
|
||||
{% endraw %}
|
@ -1,32 +0,0 @@
|
||||
---
|
||||
title: "Examples sending notification depending of the presence"
|
||||
description: "Examples sending notification depending of the presence"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
This will send a message when someone in your known devices list connects to your local network. In other words, when someone arrives home. It will only work if you are using the [Nmap](/integrations/nmap_tracker) device tracker or a similar integration.
|
||||
|
||||
This example uses [Telegram](/integrations/telegram) to send the notification.
|
||||
|
||||
```yaml
|
||||
notify:
|
||||
- name: Telegram
|
||||
platform: telegram
|
||||
api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
chat_id: xxxxxxxxx
|
||||
```
|
||||
|
||||
Add the automation rule. Change `device_name_here` to match the device you want to track.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: device_tracker.device_name_here
|
||||
from: "not_home"
|
||||
to: "home"
|
||||
action:
|
||||
service: notify.Telegram
|
||||
data:
|
||||
message: "Person is now home"
|
||||
```
|
@ -1,36 +0,0 @@
|
||||
---
|
||||
title: "Using time interval and input boolean"
|
||||
description: "Automation to get a random color every 2 minutes that can be turned on/off."
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
#### Change Hue light on interval to random color based on state of an input boolean
|
||||
|
||||
_Note, Philips Hue is currently the only light platform that support the random effect._
|
||||
|
||||
```yaml
|
||||
input_boolean:
|
||||
loop_livingcolors:
|
||||
name: Loop LivingColors
|
||||
initial: off
|
||||
icon: mdi:spotlight
|
||||
|
||||
automation:
|
||||
# Changes Hue light every two minutes to random color if input boolean is set to on
|
||||
- alias: "Set LivingColors to random color"
|
||||
trigger:
|
||||
platform: time_pattern
|
||||
minutes: "/2"
|
||||
condition:
|
||||
condition: state
|
||||
entity_id: input_boolean.loop_livingcolors
|
||||
state: "on"
|
||||
action:
|
||||
service: light.turn_on
|
||||
target:
|
||||
entity_id: light.woonkamer_livingcolors
|
||||
data:
|
||||
effect: random
|
||||
transition: 5
|
||||
brightness: 255
|
||||
```
|
@ -1,151 +0,0 @@
|
||||
---
|
||||
title: "Dim (and brighten) lights via a remote"
|
||||
description: "The scripts and automations to allow you to use a remote to dim and brighten a light"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
This requires both a dimmable light, and a Z-Wave remote control that sends one scene when a button is held, and another when released. This ensures that the scripts (which follow) are stopped, avoiding the risks of a script that never ends.
|
||||
|
||||
In the following automations, replace `zwave.YOUR_REMOTE` with the actual entity ID of your controller, and `light.YOUR_LIGHT` with the actual entity ID of your light.
|
||||
|
||||
For the controller this was written for scene ID 13 was sent when the up button was held, and 15 when released. Similarly, scene 14 when the down button was held, and 16 when released. You'll need to use the scene IDs that are sent by your remote if different.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
|
||||
- alias: "Make the lights go bright"
|
||||
initial_state: "on"
|
||||
trigger:
|
||||
- platform: event
|
||||
event_type: zwave.scene_activated
|
||||
event_data:
|
||||
scene_id: 13
|
||||
entity_id: zwave.YOUR_REMOTE
|
||||
action:
|
||||
- service: script.turn_on
|
||||
target:
|
||||
entity_id: script.ramp_light
|
||||
data:
|
||||
variables:
|
||||
direction: up
|
||||
light: light.YOUR_LIGHT
|
||||
|
||||
- alias: "Make the lights go dim"
|
||||
initial_state: "on"
|
||||
trigger:
|
||||
- platform: event
|
||||
event_type: zwave.scene_activated
|
||||
event_data:
|
||||
scene_id: 14
|
||||
entity_id: zwave.YOUR_REMOTE
|
||||
action:
|
||||
- service: script.turn_on
|
||||
target:
|
||||
entity_id: script.ramp_light
|
||||
data:
|
||||
variables:
|
||||
direction: down
|
||||
light: light.YOUR_LIGHT
|
||||
|
||||
- alias: "Stop the light just there"
|
||||
initial_state: "on"
|
||||
trigger:
|
||||
- platform: event
|
||||
event_type: zwave.scene_activated
|
||||
event_data:
|
||||
scene_id: 15
|
||||
entity_id: zwave.YOUR_REMOTE
|
||||
- platform: event
|
||||
event_type: zwave.scene_activated
|
||||
event_data:
|
||||
scene_id: 16
|
||||
entity_id: zwave.YOUR_REMOTE
|
||||
action:
|
||||
- service: script.turn_off
|
||||
target:
|
||||
entity_id: script.ramp_light
|
||||
```
|
||||
|
||||
There are two variables that control the speed of the change for the script below. The first is the step -- small steps create a smooth transition. The second is the delay -- larger delays will create a slower transition.
|
||||
Please note that some lights do not update their new brightness attribute very quickly, so make sure to use a large enough delay for your particular light.
|
||||
|
||||
There are two other variables that control the minimum and maximum brightness levels at which to stop the script.
|
||||
|
||||
To allow flexibility all four variables are controlled by [Input Number](/integrations/input_number/) entities so that it's easy to tune (or manage through an automation).
|
||||
|
||||
```yaml
|
||||
input_number:
|
||||
light_step:
|
||||
name: "Step the lights this much"
|
||||
initial: 20
|
||||
min: 1
|
||||
max: 64
|
||||
step: 1
|
||||
|
||||
light_minimum:
|
||||
name: "No dimmer than this"
|
||||
initial: 5
|
||||
min: 1
|
||||
max: 255
|
||||
step: 1
|
||||
|
||||
light_maximum:
|
||||
name: "No brighter than this"
|
||||
initial: 255
|
||||
min: 50
|
||||
max: 255
|
||||
step: 1
|
||||
|
||||
light_delay_ms:
|
||||
name: "Step the lights this often (ms)"
|
||||
initial: 500
|
||||
min: 100
|
||||
max: 5000
|
||||
step: 100
|
||||
```
|
||||
|
||||
Now the script.
|
||||
|
||||
{% raw %}
|
||||
```yaml
|
||||
script:
|
||||
ramp_light:
|
||||
alias: "Ramp Light Brightness"
|
||||
description: Ramp light brightness up or down
|
||||
fields:
|
||||
direction:
|
||||
description: "Direction to change brightness: up or down"
|
||||
example: up
|
||||
light:
|
||||
description: Light entity_id
|
||||
example: light.family_room_lamp
|
||||
mode: restart
|
||||
sequence:
|
||||
- repeat:
|
||||
while:
|
||||
- condition: template
|
||||
value_template: >
|
||||
{% set br = state_attr(light, 'brightness')|int(0) %}
|
||||
{% set mn = states('input_number.light_minimum')|int %}
|
||||
{% set mx = states('input_number.light_maximum')|int %}
|
||||
{{ direction == 'up' and br < mx or
|
||||
direction == 'down' and br > mn }}
|
||||
sequence:
|
||||
- service: light.turn_on
|
||||
target:
|
||||
entity_id: "{{ light }}"
|
||||
data:
|
||||
brightness: >
|
||||
{% set br = state_attr(light, 'brightness')|int(0) %}
|
||||
{% set mn = states('input_number.light_minimum')|int %}
|
||||
{% set mx = states('input_number.light_maximum')|int %}
|
||||
{% set st = states('input_number.light_step')|int %}
|
||||
{% if direction == 'up' %}
|
||||
{{ [br + st, mx]|min }}
|
||||
{% else %}
|
||||
{{ [br - st, mn]|max }}
|
||||
{% endif %}
|
||||
- delay:
|
||||
milliseconds: "{{ states('input_number.light_delay_ms')|int }}"
|
||||
```
|
||||
{% endraw %}
|
@ -1,74 +0,0 @@
|
||||
---
|
||||
title: "Dim lights when playing media"
|
||||
description: "Dim lights up or down when playing media"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
Like it how the lights dim up/down at the movies? Do it at home as well!
|
||||
|
||||
This example uses the [media player](/integrations/media_player/), [lights](/integrations/light/) (transitions) and the [sun](/integrations/sun/) integration. We'll use actions to detect media player state changes and [scenes](/integrations/scene/) to control multiple lights and transition between scenes.
|
||||
|
||||
#### Scenes
|
||||
One scene for normal light, one for when movies are on. A 2 second transition gives a nice 'feel' to the switch.
|
||||
|
||||
```yaml
|
||||
scene:
|
||||
- name: Livingroom normal
|
||||
entities:
|
||||
light.light1:
|
||||
state: on
|
||||
transition: 2
|
||||
brightness_pct: 60
|
||||
light.light2:
|
||||
state: on
|
||||
transition: 2
|
||||
brightness_pct: 85
|
||||
- name: Livingroom dim
|
||||
entities:
|
||||
light.light1:
|
||||
state: on
|
||||
transition: 2
|
||||
brightness_pct: 30
|
||||
light.light2:
|
||||
state: on
|
||||
transition: 2
|
||||
brightness_pct: 55
|
||||
```
|
||||
|
||||
|
||||
#### Automation
|
||||
The paused/stopped state is best matched using "from: 'playing'". Adding in the sun condition as we only want this when it's dark.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
- alias: "Media player paused/stopped"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: media_player.htpc
|
||||
from: "playing"
|
||||
to: "idle"
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: sun.sun
|
||||
state: "below_horizon"
|
||||
action:
|
||||
service: scene.turn_on
|
||||
target:
|
||||
entity_id: scene.livingroom_normal
|
||||
|
||||
- alias: "Media player playing"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: media_player.htpc
|
||||
to: "playing"
|
||||
from: "idle"
|
||||
condition:
|
||||
- condition: state
|
||||
entity_id: sun.sun
|
||||
state: "below_horizon"
|
||||
action:
|
||||
service: scene.turn_on
|
||||
target:
|
||||
entity_id: scene.livingroom_dim
|
||||
```
|
||||
|
@ -1,81 +0,0 @@
|
||||
---
|
||||
title: "Foscam Recording during Away Mode Only using Pan/Tilt/Zoom Control and Motion Detection"
|
||||
description: "Example of how to set Foscam to only have Motion Detection Recording while no one is home. When users are home the Foscam will indicate it is not recording by pointing down and away from users"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
This requires a [Foscam IP Camera](/integrations/foscam) camera with PTZ (Pan, Tilt, Zoom) and CGI functionality ([Source](https://www.foscam.es/descarga/Foscam-IPCamera-CGI-User-Guide-AllPlatforms-2015.11.06.pdf))
|
||||
|
||||
Foscam Cameras can be controlled by Home Assistant through a number of CGI commands.
|
||||
The following outlines examples of the switch, services, and scripts required to move between 2 preset destinations while controlling motion detection, but many other options of movement are provided in the Foscam CGI User Guide linked above.
|
||||
|
||||
The `switch.foscam_motion` will control whether the motion detection is on or off. This switch supports `statecmd`, which checks the current state of motion detection.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
# Replace admin and password with an "Admin" privileged Foscam user
|
||||
# Replace ipaddress with the local IP address of your Foscam
|
||||
switch:
|
||||
platform: command_line
|
||||
switches:
|
||||
#Switch for Foscam Motion Detection
|
||||
foscam_motion:
|
||||
command_on: "curl -k --tls-max 1.2 "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&usr=admin&pwd=password""
|
||||
command_off: 'curl -k --tls-max 1.2 "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=0&usr=admin&pwd=password"'
|
||||
command_state: 'curl -k --silent --tls-max 1.2 "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=admin&pwd=password" | grep "isEnable" | cut -b 15'
|
||||
value_template: '{{ value == "1" }}'
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
The service `shell_command.foscam_turn_off` sets the camera to point down and away to indicate it is not recording, and `shell_command.foscam_turn_on` sets the camera to point where I'd like to record. Each of these services require preset points to be added to your camera. See source above for additional information.
|
||||
|
||||
```yaml
|
||||
shell_command:
|
||||
#Created a preset point in Foscam Web Interface named Off which essentially points the camera down and away
|
||||
foscam_turn_off: 'curl -k --tls-max 1.2 "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Off&usr=admin&pwd=password"'
|
||||
#Created a preset point in Foscam Web Interface named Main which points in the direction I would like to record
|
||||
foscam_turn_on: 'curl -k --tls-max 1.2 "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Main&usr=admin&pwd=password"'
|
||||
```
|
||||
|
||||
The `script.foscam_off` and `script.foscam_on` can be used to set the motion detection appropriately, and then move the camera. These scripts can be called as part of an automation with `device_tracker` triggers to set `home` and `not_home` modes for your Foscam and disable motion detection recording while `home`.
|
||||
|
||||
```yaml
|
||||
script:
|
||||
foscam_off:
|
||||
sequence:
|
||||
- service: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.foscam_motion
|
||||
- service: shell_command.foscam_turn_off
|
||||
foscam_on:
|
||||
sequence:
|
||||
- service: switch.turn_off
|
||||
target:
|
||||
entity_id: switch.foscam_motion
|
||||
- service: shell_command.foscam_turn_on
|
||||
- service: switch.turn_on
|
||||
target:
|
||||
entity_id: switch.foscam_motion
|
||||
```
|
||||
|
||||
To automate Foscam being set to "on" (facing the correct way with motion sensor on), I used the following simple automation:
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
- alias: "Set Foscam to Away Mode when I leave home"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: group.family
|
||||
from: "home"
|
||||
action:
|
||||
service: script.foscam_on
|
||||
- alias: "Set Foscam to Home Mode when I arrive Home"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: group.family
|
||||
to: "home"
|
||||
action:
|
||||
service: script.foscam_off
|
||||
```
|
@ -1,55 +0,0 @@
|
||||
---
|
||||
title: "Send notification if new Home Assistant release"
|
||||
description: "Basic example of how to send a notification if a new Home Assistant release is available"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
The following example sends a notification via XMPP if a new Home Assistant release is available:
|
||||
|
||||
```yaml
|
||||
notify:
|
||||
- platform: xmpp
|
||||
name: jabber
|
||||
sender: sender@jabber.org
|
||||
password: !secret xmpp_password
|
||||
recipient: recipient@jabber.org
|
||||
|
||||
automation:
|
||||
- alias: "Update notification"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: binary_sensor.updater
|
||||
from: "off"
|
||||
to: "on"
|
||||
action:
|
||||
- service: notify.jabber
|
||||
data:
|
||||
message: "There is a new Home Assistant release available."
|
||||
```
|
||||
|
||||
You can use [templates](/topics/templating/) to include the release number of Home Assistant if you prefer. The following example sends a notification via [Pushbullet](/integrations/pushbullet) with the Home Assistant version in the message.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
notify:
|
||||
- platform: pushbullet
|
||||
api_key: "YOUR_KEY_HERE"
|
||||
name: pushbullet
|
||||
|
||||
automation:
|
||||
- alias: "Update notification"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: binary_sensor.updater
|
||||
from: "off"
|
||||
to: "on"
|
||||
action:
|
||||
- service: notify.pushbullet
|
||||
data:
|
||||
title: "New Home Assistant Release"
|
||||
target: "YOUR_TARGET_HERE" #See Pushbullet integration for usage
|
||||
message: "Home Assistant {{ state_attr('binary_sensor.updater', 'newest_version') }} is now available."
|
||||
```
|
||||
|
||||
{% endraw %}
|
@ -1,49 +0,0 @@
|
||||
---
|
||||
title: "Send notification based on sensor"
|
||||
description: "Basic example of how to send a templated notification if a sensor is over a given threshold"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
The following example sends a notification via pushbullet if a sensor is over a critical value:
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
notify me:
|
||||
platform: pushbullet
|
||||
api_key: "API_KEY_HERE"
|
||||
name: mypushbullet
|
||||
|
||||
automation:
|
||||
- alias: "FanOn"
|
||||
trigger:
|
||||
platform: numeric_state
|
||||
entity_id: sensor.furnace
|
||||
above: 2
|
||||
action:
|
||||
service: notify.mypushbullet
|
||||
data:
|
||||
title: "Furnace fan is running"
|
||||
message: "Fan running because current is {{ states('sensor.furnace') }} amps"
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
If you also want a notification when it drops back down below that limit, you could add this as well:
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
- alias: "FanOff"
|
||||
trigger:
|
||||
platform: numeric_state
|
||||
entity_id: sensor.furnace
|
||||
below: 2
|
||||
action:
|
||||
service: notify.mypushbullet
|
||||
data:
|
||||
title: "Furnace fan is stopped"
|
||||
message: "Fan stopped because current is {{ states('sensor.furnace') }} amps"
|
||||
```
|
||||
|
||||
{% endraw %}
|
@ -1,171 +0,0 @@
|
||||
---
|
||||
title: "Perform actions based on input select"
|
||||
description: "Example playing media to Chromecast based on input select element"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
This example uses an [`input_select`](/integrations/input_select/) element to pick which mp3 file to play on a [Chromecast](/integrations/cast/).
|
||||
|
||||
```yaml
|
||||
# Define our dropdown list
|
||||
input_select:
|
||||
lullaby:
|
||||
name: Lullaby
|
||||
options:
|
||||
- Rain
|
||||
- Babbling Brook
|
||||
- None
|
||||
initial: None
|
||||
icon: mdi:weather-rainy
|
||||
|
||||
# Define our media player
|
||||
media_player:
|
||||
- platform: cast
|
||||
host: chromecast-nursery
|
||||
name: Nursery
|
||||
|
||||
automation:
|
||||
# If you select "Rain", play the "rain.mp3" file
|
||||
- alias: "Play Rain Lullaby"
|
||||
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: input_select.lullaby
|
||||
to: "Rain"
|
||||
|
||||
action:
|
||||
service: media_player.play_media
|
||||
target:
|
||||
entity_id: media_player.nursery
|
||||
data:
|
||||
media_content_id: http://fileserver/rain.mp3
|
||||
media_content_type: music
|
||||
|
||||
|
||||
# If you select "Babbling Brook", play the "babbling_brook.mp3" file
|
||||
- alias: "Play Babbling Brook Lullaby"
|
||||
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: input_select.lullaby
|
||||
to: "Babbling Brook"
|
||||
|
||||
action:
|
||||
service: media_player.play_media
|
||||
target:
|
||||
entity_id: media_player.nursery
|
||||
data:
|
||||
media_content_id: http://fileserver/babbling_brook.mp3
|
||||
media_content_type: music
|
||||
|
||||
# If you select "None, turn the Chromecast off
|
||||
- alias: "Stop the Lullaby"
|
||||
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: input_select.lullaby
|
||||
to: "None"
|
||||
|
||||
action:
|
||||
service: media_player.turn_off
|
||||
target:
|
||||
entity_id: media_player.nursery
|
||||
```
|
||||
A little bit more complex example that uses [`input_select`](/integrations/input_select/) and template to decide what to play, and which [Chromecast](/integrations/cast/) to play on.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
input_select:
|
||||
radio_station:
|
||||
name: Radio Station
|
||||
options:
|
||||
- Z88.3
|
||||
- Virgin
|
||||
- RMC
|
||||
- rmcHQ
|
||||
- 105
|
||||
- None
|
||||
initial: None
|
||||
icon: mdi:radio
|
||||
radio_player:
|
||||
name: Radio Player
|
||||
options:
|
||||
- Mansarda
|
||||
- Doccia
|
||||
- Bed
|
||||
- Bath
|
||||
- Salotto
|
||||
- Salotto Video
|
||||
- None
|
||||
initial: None
|
||||
icon: mdi:airplay
|
||||
|
||||
automation:
|
||||
- alias: "Stop Streaming Radio"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: input_select.radio_station
|
||||
to: "None"
|
||||
action:
|
||||
service: media_player.turn_off
|
||||
target:
|
||||
entity_id: >
|
||||
{% if is_state("input_select.radio_player", "Mansarda") %}
|
||||
media_player.bed_2
|
||||
{%-elif is_state("input_select.radio_player", "Doccia") %}
|
||||
media_player.bed_3
|
||||
{%-elif is_state("input_select.radio_player", "Bed") %}
|
||||
media_player.bed
|
||||
{%-elif is_state("input_select.radio_player", "Bath") %}
|
||||
media_player.bath
|
||||
{%-elif is_state("input_select.radio_player", "Salotto") %}
|
||||
media_player.salotto
|
||||
{%-elif is_state("input_select.radio_player", "Salotto Video") %}
|
||||
media_player.salotto_video
|
||||
{% else %}
|
||||
none
|
||||
{% endif %}
|
||||
|
||||
- alias: "Stream Radio - Template"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: input_select.radio_station
|
||||
action:
|
||||
- service: media_player.play_media
|
||||
target:
|
||||
entity_id: >
|
||||
{% if is_state("input_select.radio_player", "Mansarda") %}
|
||||
media_player.bed_2
|
||||
{%-elif is_state("input_select.radio_player", "Doccia") %}
|
||||
media_player.bed_3
|
||||
{%-elif is_state("input_select.radio_player", "Bed") %}
|
||||
media_player.bed
|
||||
{%-elif is_state("input_select.radio_player", "Bath") %}
|
||||
media_player.bath
|
||||
{%-elif is_state("input_select.radio_player", "Salotto") %}
|
||||
media_player.salotto
|
||||
{%-elif is_state("input_select.radio_player", "Salotto Video") %}
|
||||
media_player.salotto_video
|
||||
{% else %}
|
||||
none
|
||||
{% endif %}
|
||||
data:
|
||||
media_content_id: >
|
||||
{% if is_state("input_select.radio_station", "Z88.3") %}
|
||||
http://ice.zradio.org/z/high.mp3
|
||||
{%-elif is_state("input_select.radio_station", "Virgin") %}
|
||||
http://icecast.unitedradio.it/Virgin.mp3
|
||||
{%-elif is_state("input_select.radio_station", "RMC") %}
|
||||
http://icecast.unitedradio.it/RMC.mp3
|
||||
{%-elif is_state("input_select.radio_station", "rmcHQ") %}
|
||||
http://icecast.unitedradio.it/rmcHQ.mp3
|
||||
{%-elif is_state("input_select.radio_station", "105") %}
|
||||
http://icecast.unitedradio.it/Radio105.mp3
|
||||
{% else %}
|
||||
none
|
||||
{% endif %}
|
||||
media_content_type: "music"
|
||||
```
|
||||
|
||||
{% endraw %}
|
@ -1,99 +0,0 @@
|
||||
---
|
||||
title: "Restart Home Assistant if Wemo Switch is not detected"
|
||||
description: "Restart Home Assistant if Wemo Switch is not detected."
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
### Restart Home Assistant
|
||||
|
||||
This configuration example is restarting Home Assistant if a [WeMo](/integrations/wemo) switch is not detected. An additional MQTT switch is present for stopping Home Assistant and can be triggered by [IFTTT](/integrations/ifttt/). The running batch script will automatically restart Home Assistant if the process isn't found anymore.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
mqtt:
|
||||
broker: 127.0.0.1
|
||||
port: 1883
|
||||
client_id: home-assistant-1
|
||||
keepalive: 60
|
||||
|
||||
device_tracker:
|
||||
- platform: nmap_tracker
|
||||
hosts: 192.168.0.1-255
|
||||
home_interval: 1
|
||||
interval_seconds: 30
|
||||
consider_home: 900
|
||||
|
||||
ifttt:
|
||||
key: ***
|
||||
|
||||
notify:
|
||||
- platform: pushbullet
|
||||
api_key: ***
|
||||
name: pushbullet
|
||||
|
||||
wemo:
|
||||
discovery: true
|
||||
|
||||
switch:
|
||||
- platform: mqtt
|
||||
state_topic: "home/killhass"
|
||||
command_topic: "home/killhass"
|
||||
name: "KillHass"
|
||||
qos: 0
|
||||
payload_on: "ON"
|
||||
payload_of: "OFF"
|
||||
optimistic: false
|
||||
|
||||
script:
|
||||
restarthawemo:
|
||||
alias: "Restart HA if WeMo isn't found after 15 minutes"
|
||||
sequence:
|
||||
- delay:
|
||||
minutes: 15
|
||||
- service: notify.pushbullet
|
||||
data:
|
||||
message: "WeMo not found, restarting HA"
|
||||
- service: switch.turn_on
|
||||
target:
|
||||
entity_id: switch.killhass
|
||||
|
||||
automation:
|
||||
- alias: "Restart HA if WeMo switch isn't found after 15 minutes"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: device_tracker.wemo
|
||||
from: "not_home"
|
||||
to: "home"
|
||||
condition:
|
||||
- condition: template
|
||||
value_template: '{% if states.switch.wemo %}false{% else %}true{% endif %}'
|
||||
- condition: state
|
||||
entity_id: script.restarthawemo
|
||||
state: "off"
|
||||
action:
|
||||
service: homeassistant.turn_on
|
||||
target:
|
||||
entity_id: script.restarthawemo
|
||||
- alias: "Stop HA"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: switch.KillHass
|
||||
to: "on"
|
||||
action:
|
||||
service: homeassistant.stop
|
||||
- alias: "Stop restarting HA is WeMo is found"
|
||||
trigger:
|
||||
platform: template
|
||||
value_template: '{% if states.switch.wemo %}true{% else %}false{% endif %}'
|
||||
condition:
|
||||
condition: state
|
||||
entity_id: script.restarthawemo
|
||||
state: "on"
|
||||
action:
|
||||
service: homeassistant.turn_off
|
||||
target:
|
||||
entity_id: script.restarthawemo
|
||||
```
|
||||
|
||||
{% endraw %}
|
@ -1,32 +0,0 @@
|
||||
---
|
||||
title: "Send a reminder"
|
||||
description: "Send a reminder"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
Always forget to eat lunch? Let Home Assistant send you a reminder.
|
||||
|
||||
Add a [notify platform](/integrations/notify/) of your choice.
|
||||
|
||||
```yaml
|
||||
notify:
|
||||
- platform: xmpp
|
||||
name: jabber
|
||||
sender: YOUR_JID
|
||||
password: YOUR_JABBER_ACCOUNT_PASSWORD
|
||||
recipient: YOUR_RECIPIENT
|
||||
```
|
||||
|
||||
and automation part to your `configuration.yaml` file.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
- alias: "Send message at a given time"
|
||||
trigger:
|
||||
platform: time
|
||||
at: "12:15:00"
|
||||
action:
|
||||
service: notify.jabber
|
||||
data:
|
||||
message: "Time for lunch"
|
||||
```
|
@ -1,68 +0,0 @@
|
||||
---
|
||||
title: "Sonos say script to speak with text-to-speech"
|
||||
description: "Sonos say script to use text-to-speech with Sonos"
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
#### Sonos say script to speak with text-to-speech
|
||||
|
||||
This script allows you to use [TTS](/integrations/#text-to-speech) on Sonos.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
script:
|
||||
sonos_say:
|
||||
alias: "Sonos TTS script"
|
||||
sequence:
|
||||
- service: sonos.snapshot
|
||||
target:
|
||||
entity_id: "{{ sonos_entity }}"
|
||||
- service: sonos.unjoin
|
||||
target:
|
||||
entity_id: "{{ sonos_entity }}"
|
||||
- service: media_player.volume_set
|
||||
data:
|
||||
entity_id: "{{ sonos_entity }}"
|
||||
volume_level: "{{ volume }}"
|
||||
- service: tts.voicerss_say
|
||||
data:
|
||||
entity_id: "{{ sonos_entity }}"
|
||||
message: "{{ message }}"
|
||||
- delay: "{{ delay }}"
|
||||
- service: sonos.restore
|
||||
target:
|
||||
entity_id: "{{ sonos_entity }}"
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
We call this now with:
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
- alias: "test"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: input_boolean.mytest
|
||||
action:
|
||||
- service: script.sonos_say
|
||||
data:
|
||||
sonos_entity: media_player.office
|
||||
volume: 0.5
|
||||
message: "Your husband coming home!"
|
||||
delay: "00:00:05"
|
||||
```
|
||||
|
||||
Note that this example uses the `voicerss` text-to-speech platform. There are many platforms that can be used. The one installed by default with Home Assistant is Google TTS. This appears in your `configuration.yaml` file as:
|
||||
|
||||
```yaml
|
||||
tts:
|
||||
- platform: google_translate
|
||||
```
|
||||
|
||||
If you want to use this TTS engine, change the line in the example provided to:
|
||||
|
||||
```txt
|
||||
- service: tts.google_translate_say
|
||||
```
|
@ -1,96 +0,0 @@
|
||||
---
|
||||
title: "Track your phone battery level"
|
||||
description: "Basic example how to track the battery level of your mobile devices."
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
## Android and iOS Devices
|
||||
|
||||
The [Home Assistant Companion Apps](https://companion.home-assistant.io/) for iOS and Android pass the current battery level to Home Assistant with every location update. The default name of the sensor used is `sensor.battery_level`.
|
||||
|
||||
### iOS Devices
|
||||
|
||||
If you have a device running iOS (iPhone, iPad, etc), The [iCloud](/integrations/icloud) integration is gathering various details about your device including the battery level. To display it in the Frontend use a [template sensor](/integrations/template). You can also use the `battery` [sensor device class](/integrations/sensor/#device-class) to dynamically change the icon with the battery level.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
sensor:
|
||||
- platform: template
|
||||
sensors:
|
||||
battery_iphone:
|
||||
friendly_name: iPhone Battery
|
||||
unit_of_measurement: "%"
|
||||
value_template: >-
|
||||
{%- if state_attr('device_tracker.iphone', 'battery') %}
|
||||
{{ state_attr('device_tracker.iphone', 'battery')|round }}
|
||||
{% else %}
|
||||
{{ states('sensor.battery_iphone') }}
|
||||
{%- endif %}
|
||||
device_class: battery
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
### Android Devices
|
||||
|
||||
On your Android device, once the official [Home Assistant Companion app](https://companion.home-assistant.io/) is installed and connected to your Home Assistance instance, you will be able to display the battery level in the frontend by adding a [template sensor](/integrations/template) to your configuration YAML file. You can also use the battery [sensor device class](/integrations/sensor/#device-class) to dynamically change the icon with the battery level.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
sensor:
|
||||
- platform: template
|
||||
sensors:
|
||||
battery_phone:
|
||||
friendly_name: AndroidPhone Battery
|
||||
unit_of_measurement: "%"
|
||||
value_template: >-
|
||||
{%- if state_attr('device_tracker.xxxxx', 'battery_level') %}
|
||||
{{ state_attr('device_tracker.xxxxx', 'battery_level')|round }}
|
||||
{% else %}
|
||||
{{ states('device_tracker.xxxxx') }}
|
||||
{%- endif %}
|
||||
device_class: battery
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
Replace 'device_tracker.xxxxx' with your phone name as shown under Configuration/Devices Device Info/Entities, for example: 'device_tracker.mi_a1'
|
||||
|
||||
#### MQTT
|
||||
|
||||
If you have configured Owntracks to send reports via MQTT you can use the received data via a MQTT sensor.
|
||||
Replace username with your MQTT username (for the embedded MQTT it's simply homeassistant), and deviceid with the set Device ID in Owntracks.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
sensor:
|
||||
- platform: mqtt
|
||||
state_topic: "owntracks/username/deviceid"
|
||||
name: "Battery Tablet"
|
||||
unit_of_measurement: "%"
|
||||
value_template: "{{ value_json.batt }}"
|
||||
device_class: battery
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
#### HTTP
|
||||
|
||||
If you have configured Owntracks to send reports to your Home Assistant instance via HTTP you can use a template sensor.
|
||||
Replace `deviceid` with the set Device ID in Owntracks.
|
||||
|
||||
{% raw %}
|
||||
|
||||
```yaml
|
||||
sensor:
|
||||
- platform: template
|
||||
sensors:
|
||||
your_battery_sensor_name:
|
||||
value_template: "{{ state_attr('device_tracker.deviceid', 'battery_level') }}"
|
||||
unit_of_measurement: "%"
|
||||
```
|
||||
|
||||
{% endraw %}
|
@ -1,106 +0,0 @@
|
||||
---
|
||||
title: "Turn on lights for 10 minutes after motion detected"
|
||||
description: "Turn on lights for 10 minutes when motion detected."
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
#### Turn on lights with a resettable off timer
|
||||
|
||||
This recipe will turn on a light when there is motion and turn off the light when ten minutes has passed without any motion events.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
- alias: "Turn on kitchen light when there is movement"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: sensor.motion_sensor
|
||||
to: "on"
|
||||
action:
|
||||
service: light.turn_on
|
||||
target:
|
||||
entity_id: light.kitchen_light
|
||||
|
||||
- alias: "Turn off kitchen light 10 minutes after last movement"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: sensor.motion_sensor
|
||||
to: "off"
|
||||
for:
|
||||
minutes: 10
|
||||
action:
|
||||
service: light.turn_off
|
||||
target:
|
||||
entity_id: light.kitchen_light
|
||||
```
|
||||
|
||||
Or in the case of multiple sensors/triggers:
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
- alias: "Turn on hallway lights when the doorbell rings, the front door opens or if there is movement"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: sensor.motion_sensor, binary_sensor.front_door, binary_sensor.doorbell
|
||||
to: "on"
|
||||
action:
|
||||
- service: light.turn_on
|
||||
target:
|
||||
entity_id:
|
||||
- light.hallway_0
|
||||
- light.hallway_1
|
||||
- service: timer.start
|
||||
target:
|
||||
entity_id: timer.hallway
|
||||
|
||||
- alias: "Turn off hallway lights 10 minutes after trigger"
|
||||
trigger:
|
||||
platform: event
|
||||
event_type: timer.finished
|
||||
event_data:
|
||||
entity_id: timer.hallway
|
||||
action:
|
||||
service: light.turn_off
|
||||
target:
|
||||
entity_id:
|
||||
- light.hallway_0
|
||||
- light.hallway_1
|
||||
|
||||
timer:
|
||||
hallway:
|
||||
duration: "00:10:00"
|
||||
```
|
||||
|
||||
You can also restrict lights from turning on based on time of day and implement transitions for fading lights on and off.
|
||||
|
||||
```yaml
|
||||
- alias: "Motion Sensor Lights On"
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: binary_sensor.ecolink_pir_motion_sensor_sensor
|
||||
to: "on"
|
||||
condition:
|
||||
condition: time
|
||||
after: "07:30"
|
||||
before: "23:30"
|
||||
action:
|
||||
service: homeassistant.turn_on
|
||||
target:
|
||||
entity_id: group.office_lights
|
||||
data:
|
||||
transition: 15
|
||||
|
||||
|
||||
- alias: "Motion Sensor Lights Off"
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: binary_sensor.ecolink_pir_motion_sensor_sensor
|
||||
to: "off"
|
||||
for:
|
||||
minutes: 15
|
||||
action:
|
||||
- service: homeassistant.turn_off
|
||||
target:
|
||||
entity_id: group.office_lights
|
||||
data:
|
||||
transition: 160
|
||||
```
|
1
source/_data/blueprint_exchange_data.json
Normal file
1
source/_data/blueprint_exchange_data.json
Normal file
File diff suppressed because one or more lines are too long
@ -10,8 +10,6 @@
|
||||
description: "Integrations (see below) used to be known as components."
|
||||
- topic: Condition
|
||||
description: "[Conditions](/docs/scripts/conditions/) are an optional part of an automation that will prevent an action from firing if they are not met."
|
||||
- topic: Cookbook
|
||||
description: "The [Cookbook](/cookbook/) contains a set of configuration examples of Home Assistant from the community."
|
||||
- topic: Cover
|
||||
description: "[Covers](/integrations/cover) are devices such as blinds, garage doors, etc that can be opened and closed and optionally set to a specific position."
|
||||
- topic: Customize
|
||||
|
@ -20,7 +20,7 @@ If you want to use a different folder for configuration, use the configuration c
|
||||
|
||||
Inside your configuration folder is the file `configuration.yaml`. This is the main file that contains integrations to be loaded along with their configurations. Throughout the documentation you will find snippets that you can add to your configuration file to enable specific functionality.
|
||||
|
||||
If you run into trouble while configuring Home Assistant, refer the [configuration troubleshooting page](/getting-started/troubleshooting-configuration/) and at the [`configuration.yaml` examples](/cookbook/#example-configurationyaml).
|
||||
If you run into trouble while configuring Home Assistant, refer the [configuration troubleshooting page](/getting-started/troubleshooting-configuration/) and at the [`configuration.yaml` examples](/examples/#example-configurationyaml).
|
||||
|
||||
<div class='note tip'>
|
||||
|
||||
|
@ -5,7 +5,7 @@ description: "Splitting the configuration.yaml into several files."
|
||||
|
||||
So you've been using Home Assistant for a while now and your `configuration.yaml` file brings people to tears or you simply want to start off with the distributed approach, here's how to split the `configuration.yaml` into more manageable (read: humanly readable) pieces.
|
||||
|
||||
First off, several community members have sanitized (read: without API keys/passwords etc) versions of their configurations available for viewing, you can see a list of them [here](/cookbook/#example-configurationyaml).
|
||||
First off, several community members have sanitized (read: without API keys/passwords etc) versions of their configurations available for viewing, you can see a list of them [here](/examples/#example-configurationyaml).
|
||||
|
||||
As commenting code doesn't always happen, please read on for the details.
|
||||
|
||||
|
@ -9,7 +9,7 @@ The frontend of Home Assistant is built with [Polymer](https://www.polymer-proje
|
||||
<img src='/images/screenshots/ui2015.png' />
|
||||
</p>
|
||||
|
||||
The [User Interface section](/cookbook/#user-interface) can give you some starting points to expand the frontend.
|
||||
The [User Interface section](/examples/#user-interface) can give you some starting points to expand the frontend.
|
||||
|
||||
If you want to work on the frontend, please refer to the [Frontend Development documentation](/developers/frontend/).
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
<section class="aside-module grid__item one-whole lap-one-half">
|
||||
{% assign cookbook = site.cookbook | sort_natural: 'title' %}
|
||||
|
||||
<div class="section">
|
||||
<a href="/cookbook">Back to the cookbook</a>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h1 class="title delta">{{page.ha_category}}</h1>
|
||||
<ul class="divided">
|
||||
{% for recipe in cookbook %} {% if recipe.ha_category == page.ha_category
|
||||
%}
|
||||
<li>
|
||||
{% if recipe.url == page.url %} {{recipe.title}} {% elsif
|
||||
recipe.ha_external_link %}
|
||||
<a href="{{recipe.ha_external_link}}"
|
||||
>{{recipe.title}} <i class="icon-external-link"></i
|
||||
></a>
|
||||
{% else %}
|
||||
<a href="{{recipe.url}}">{{recipe.title}}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %} {% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
@ -9,4 +9,4 @@
|
||||
<li>receive a message when the lights turn on while you are not at home?</li>
|
||||
</ul>
|
||||
<p><a href='/getting-started/automation/'>We've got you covered.</a></p>
|
||||
<p><a href='/cookbook/'>View examples by the community.</a></p>
|
||||
<p><a href='/examples/'>View examples by the community.</a></p>
|
||||
|
@ -44,7 +44,7 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="/integrations/">Integrations</a></li>
|
||||
<li><a href="/cookbook/">Examples</a></li>
|
||||
<li><a href="/examples/">Examples</a></li>
|
||||
<li><a href="/blog/">Blog</a></li>
|
||||
<li><a href="/help/">Need help?</a></li>
|
||||
<li>
|
||||
|
@ -7,8 +7,6 @@
|
||||
{% include asides/installation_navigation.html %}
|
||||
{% elsif root == 'common-tasks' %}
|
||||
{% include asides/common_tasks_navigation.html %}
|
||||
{% elsif root == 'cookbook' %}
|
||||
{% include asides/cookbook_navigation.html %}
|
||||
{% elsif root == 'lovelace' %}
|
||||
{% include asides/lovelace_navigation.html %}
|
||||
{% elsif root == 'developers' or root == 'help' %}
|
||||
|
@ -160,4 +160,4 @@ elements:
|
||||
|
||||
### Extra CGI Commands
|
||||
|
||||
Foscam Webcams which support CGI Commands can be controlled by Home Assistant ([Source](https://www.iltucci.com/blog/wp-content/uploads/2018/12/Foscam-IPCamera-CGI-User-Guide-V1.0.4.pdf)). For an example of how this can be done, see the [Foscam IP Camera Pan, Tilt, Zoom Control](/cookbook/foscam_away_mode_PTZ/) Cookbook entry.
|
||||
Foscam Webcams which support CGI Commands can be controlled by Home Assistant ([Source](https://www.iltucci.com/blog/wp-content/uploads/2018/12/Foscam-IPCamera-CGI-User-Guide-V1.0.4.pdf)).
|
||||
|
@ -78,7 +78,7 @@ rtsp_transport:
|
||||
{% endconfiguration %}
|
||||
|
||||
<p class='img'>
|
||||
<a href='/cookbook/google_maps_card/'>
|
||||
<a href='/examples/google_maps_card/'>
|
||||
<img src='/images/integrations/camera/generic-google-maps.png' alt='Screenshot showing Google Maps integration in Home Assistant front end.'>
|
||||
Example showing the Generic camera platform pointing at a dynamic Google Map image.
|
||||
</a>
|
||||
|
@ -9,7 +9,7 @@ categories: Community Video
|
||||
og_image: /images/blog/2016-02-community-highlights/part-of-the-thing.png
|
||||
---
|
||||
|
||||
Home Assistant land has been busy and a lot of people have been creating awesome stuff. We've added [a cookbook section](/cookbook/) to the website full of examples how you can automate different things. Make sure you take a look and share your own recipes too!
|
||||
Home Assistant land has been busy and a lot of people have been creating awesome stuff. We've added [a cookbook section](/examples/) to the website full of examples how you can automate different things. Make sure you take a look and share your own recipes too!
|
||||
|
||||
### Home automation demo by Part of the Thing
|
||||
|
||||
|
@ -30,7 +30,7 @@ Hmmm, ...OK, that's a start. How to get the year? {% raw %}`{{ now() }}`{% endra
|
||||
|
||||
For the year it would be: {% raw %}`{{ now().year }}`{% endraw %}. I guess that there are rare use cases for `now().resolution`, `now().min` and `now().max` too.
|
||||
|
||||
[Hacktoberfest](/blog/2017/09/29/hacktoberfest/) is still running. Working on the documentation is pretty easy. If you know a nice [trick](/cookbook/), want to help improving the page of a platform or just fix typo then please do. Our [Website/Documentation section](/developers/documentation/) contains some requirements which are defined in the [Documentation Standards](/developers/documentation/standards/) and the "[Create a page](/developers/documentation/create_page/)" documentation for other useful details.
|
||||
[Hacktoberfest](/blog/2017/09/29/hacktoberfest/) is still running. Working on the documentation is pretty easy. If you know a nice [trick](/examples/), want to help improving the page of a platform or just fix typo then please do. Our [Website/Documentation section](/developers/documentation/) contains some requirements which are defined in the [Documentation Standards](/developers/documentation/standards/) and the "[Create a page](/developers/documentation/create_page/)" documentation for other useful details.
|
||||
|
||||
Thanks to [Egor Tsinko](https://github.com/etsinko) for bringing this issue to our attention.
|
||||
|
||||
|
@ -2119,6 +2119,12 @@
|
||||
/hassio/installation /installation
|
||||
/hassio/installing_third_party_addons /common-tasks/os#installing-third-party-add-ons
|
||||
/integrations/faadelays /integrations/faa_delays
|
||||
/cookbook/notify.mqtt /examples#notifications
|
||||
/cookbook/#example-configurationyaml /examples/#example-configurationyaml
|
||||
/cookbook/#user-interface /examples/#user-interface
|
||||
/cookbook/#infrastructure /examples/#infrastructure
|
||||
/cookbook/#automation-examples /examples
|
||||
/cookbook /examples
|
||||
|
||||
# Migrated Community Guides
|
||||
/cookbook/apache_configuration https://community.home-assistant.io/t/reverse-proxy-with-apache/196942
|
||||
|
@ -1,8 +1,7 @@
|
||||
---
|
||||
title: "Cookbook"
|
||||
title: "Examples"
|
||||
description: "Community maintained list of different ways to use Home Assistant."
|
||||
sidebar: false
|
||||
regenerate: true
|
||||
feedback: false
|
||||
---
|
||||
|
||||
@ -20,20 +19,27 @@ A great place to find popular configurations is on this
|
||||
[automations]: /getting-started/automation/
|
||||
[github-search]: https://github.com/search?q=topic%3Ahome-assistant-config&type=Repositories
|
||||
|
||||
{% assign cookbook = site.cookbook | sort: 'title' %}
|
||||
{% assign categories = cookbook | map: 'ha_category' | uniq | sort %}
|
||||
## Popular Blueprints
|
||||
|
||||
This is a list of the most popular [blueprints](/integrations/blueprint) in the [Blueprint Exchange category on the forums](https://community.home-assistant.io/c/blueprints-exchange/53/l/top/all).
|
||||
|
||||
{% for post in site.data.blueprint_exchange_data limit:25 %}
|
||||
|
||||
- [{{post.title}}](https://community.home-assistant.io/t/{{post.id}})
|
||||
|
||||
{%- for tag in post.tags %}
|
||||
[`{{tag}}`](https://community.home-assistant.io/tag/{{tag}})
|
||||
{%- endfor -%}
|
||||
{% endfor %}
|
||||
|
||||
{% assign examples = site.examples | sort: 'title' %}
|
||||
{% assign categories = examples | map: 'ha_category' | uniq | sort %}
|
||||
|
||||
{% for category in categories %}
|
||||
|
||||
## {{ category }}
|
||||
|
||||
{% if category == 'Automation Examples' %}
|
||||
|
||||
{% elsif category == 'Full configuration.yaml examples' %}
|
||||
Some users keep a public scrubbed copy of their `configuration.yaml` to learn from.
|
||||
{% elsif category == '' %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% for recipe in cookbook %}
|
||||
{% for recipe in examples %}
|
||||
{% if recipe.ha_category == category %}
|
||||
{% if recipe.ha_external_link %}
|
||||
* [{{recipe.title}} <i class="icon-external-link"></i>]({{recipe.ha_external_link}})
|
Loading…
x
Reference in New Issue
Block a user