Merge branch 'current' into next

This commit is contained in:
Franck Nijhof 2021-02-10 08:48:31 +01:00
commit 36f502ae92
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
44 changed files with 396 additions and 165 deletions

View File

@ -15,6 +15,8 @@ input_boolean:
#### 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.
@ -67,26 +69,26 @@ automation:
- condition: numeric_state
entity_id: light.livingroom_ec
# if light is off, force a 0, otherwise use the brightness value
value_template: {% raw %}'{% if is_state('light.livingroom_ec', 'on') %}{{ state_attr('light.livingroom_ec', 'brightness') }}{% else %}0{% endif %}'{% endraw %}
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: {% raw %}'{% if is_state('light.kitchen_bar', 'on') %}{{ state_attr('light.kitchen_bar', 'brightness') }}{% else %}0{% endif %}'{% endraw %}
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: {% raw %}'{% if is_state('light.kitchen_ceiling', 'on') %}{{ state_attr('light.kitchen_ceiling', 'brightness') }}{% else %}0{% endif %}'{% endraw %}
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
entity_id: scene.morning_first_motion
```
{% endraw %}
#### The Scene
Here is the Scene that is called via the Automations above.

View File

@ -4,7 +4,7 @@ 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
#### Turn on the living room lights 45 minutes before sunset if anyone is at home
```yaml
automation:
@ -21,7 +21,7 @@ automation:
entity_id: group.living_room_lights
```
#### Natural wake up light
#### Natural wake up light
_Note, Philips Hue and LIFX are currently the only light platforms that support transitions._
@ -68,12 +68,14 @@ automation:
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: "{% raw %}{{ state_attr('sun.sun', 'elevation') }}{% endraw %}"
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
below: 3.5
action:
service: scene.turn_on
@ -83,7 +85,7 @@ Solar elevation automations can cope with offsets from sunset / sunrise as the s
trigger:
platform: numeric_state
entity_id: sun.sun
value_template: "{% raw %}{{ state_attr('sun.sun', 'elevation') }}{% endraw %}"
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
below: 1.5
action:
service: scene.turn_on
@ -93,10 +95,11 @@ Solar elevation automations can cope with offsets from sunset / sunrise as the s
trigger:
platform: numeric_state
entity_id: sun.sun
value_template: "{% raw %}{{ state_attr('sun.sun', 'elevation') }}{% endraw %}"
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
below: -2.5
action:
service: switch.turn_off
entity_id: switch.blind
```
{% endraw %}

View File

@ -11,6 +11,8 @@ The following outlines examples of the switch, services, and scripts required to
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
@ -22,9 +24,11 @@ switch:
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: '{% raw %}{{ value == "1" }}{% endraw %}'
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
@ -75,4 +79,3 @@ automation:
action:
service: script.foscam_off
```

View File

@ -10,16 +10,20 @@ As of June 2018, Google has changed the API limits for static maps. You now need
It also leverages the `limit_refetch_to_url_change` option to ensure that we do not make a lot of requests to the Google Maps API.
{% raw %}
```yaml
# Example configuration.yaml entry.
# Shows device_tracker.demo_paulus on a map.
camera:
name: Paulus
platform: generic
still_image_url: {% raw %}https://maps.googleapis.com/maps/api/staticmap?center={{ state_attr('device_tracker.demo_paulus', 'latitude') }},{{ state_attr('device_tracker.demo_paulus', 'longitude') }}&zoom=13&size=500x500&maptype=roadmap&markers=color:blue%7Clabel:P%7C{{ state_attr('device_tracker.demo_paulus', 'latitude') }},{{ state_attr('device_tracker.demo_paulus', 'longitude') }}{% endraw %}&key=YOUR_API_KEY
still_image_url: https://maps.googleapis.com/maps/api/staticmap?center={{ state_attr('device_tracker.demo_paulus', 'latitude') }},{{ state_attr('device_tracker.demo_paulus', 'longitude') }}&zoom=13&size=500x500&maptype=roadmap&markers=color:blue%7Clabel:P%7C{{ state_attr('device_tracker.demo_paulus', 'latitude') }},{{ state_attr('device_tracker.demo_paulus', 'longitude') }}&key=YOUR_API_KEY
limit_refetch_to_url_change: true
```
{% endraw %}
<p class='img'>
<img src='/images/integrations/camera/generic-google-maps.png' alt='Screenshot showing Google Maps integration in Home Assistant front end.'>
</p>

View File

@ -29,6 +29,8 @@ automation:
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
@ -47,6 +49,7 @@ automation:
data:
title: "New Home Assistant Release"
target: "YOUR_TARGET_HERE" #See Pushbullet integration for usage
message: "Home Assistant {% raw %} {{ state_attr('binary_sensor.updater', 'newest_version') }} {% endraw %} is now available."
message: "Home Assistant {{ state_attr('binary_sensor.updater', 'newest_version') }} is now available."
```
{% endraw %}

View File

@ -6,8 +6,9 @@ ha_category: Automation Examples
The following example sends a notification via pushbullet if a sensor is over a critical value:
```yaml
{% raw %}
```yaml
notify me:
platform: pushbullet
api_key: "API_KEY_HERE"
@ -23,11 +24,15 @@ automation:
service: notify.mypushbullet
data:
title: "Furnace fan is running"
message: "Fan running because current is {% raw %}{{ states('sensor.furnace') }}{% endraw %} amps"
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:
@ -38,5 +43,7 @@ If you also want a notification when it drops back down below that limit, you co
service: notify.mypushbullet
data:
title: "Furnace fan is stopped"
message: "Fan stopped because current is {% raw %}{{ states('sensor.furnace') }}{% endraw %} amps"
message: "Fan stopped because current is {{ states('sensor.furnace') }} amps"
```
{% endraw %}

View File

@ -71,6 +71,8 @@ automation:
```
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:
@ -106,22 +108,22 @@ automation:
action:
service: media_player.turn_off
data:
entity_id: >{% raw %}
{% if is_state("input_select.radio_player", "Mansarda") %}{% endraw %}
media_player.bed_2{% raw %}
{%-elif is_state("input_select.radio_player", "Doccia") %}{% endraw %}
media_player.bed_3{% raw %}
{%-elif is_state("input_select.radio_player", "Bed") %}{% endraw %}
media_player.bed{% raw %}
{%-elif is_state("input_select.radio_player", "Bath") %}{% endraw %}
media_player.bath{% raw %}
{%-elif is_state("input_select.radio_player", "Salotto") %}{% endraw %}
media_player.salotto{% raw %}
{%-elif is_state("input_select.radio_player", "Salotto Video") %}{% endraw %}
media_player.salotto_video{% raw %}
{% else %}{% endraw %}
none{% raw %}
{% endif %}{% endraw %}
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:
@ -130,35 +132,37 @@ automation:
action:
- service: media_player.play_media
data:
entity_id: >{% raw %}
{% if is_state("input_select.radio_player", "Mansarda") %}{% endraw %}
media_player.bed_2{% raw %}
{%-elif is_state("input_select.radio_player", "Doccia") %}{% endraw %}
media_player.bed_3{% raw %}
{%-elif is_state("input_select.radio_player", "Bed") %}{% endraw %}
media_player.bed{% raw %}
{%-elif is_state("input_select.radio_player", "Bath") %}{% endraw %}
media_player.bath{% raw %}
{%-elif is_state("input_select.radio_player", "Salotto") %}{% endraw %}
media_player.salotto{% raw %}
{%-elif is_state("input_select.radio_player", "Salotto Video") %}{% endraw %}
media_player.salotto_video{% raw %}
{% else %}{% endraw %}
none{% raw %}
{% endif %}{% endraw %}
media_content_id: >{% raw %}
{% if is_state("input_select.radio_station", "Z88.3") %}{% endraw %}
http://ice.zradio.org/z/high.mp3{% raw %}
{%-elif is_state("input_select.radio_station", "Virgin") %}{% endraw %}
http://icecast.unitedradio.it/Virgin.mp3{% raw %}
{%-elif is_state("input_select.radio_station", "RMC") %}{% endraw %}
http://icecast.unitedradio.it/RMC.mp3{% raw %}
{%-elif is_state("input_select.radio_station", "rmcHQ") %}{% endraw %}
http://icecast.unitedradio.it/rmcHQ.mp3{% raw %}
{%-elif is_state("input_select.radio_station", "105") %}{% endraw %}
http://icecast.unitedradio.it/Radio105.mp3{% raw %}
{% else %}{% endraw %}
none{% raw %}
{% endif %}{% endraw %}
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 %}
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 %}

View File

@ -8,6 +8,8 @@ ha_category: Automation Examples
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
@ -65,7 +67,7 @@ automation:
to: "home"
condition:
- condition: template
value_template: {% raw %}'{% if states.switch.wemo %}false{% else %}true{% endif %}'{% endraw %}
value_template: '{% if states.switch.wemo %}false{% else %}true{% endif %}'
- condition: state
entity_id: script.restarthawemo
state: "off"
@ -82,7 +84,7 @@ automation:
- alias: "Stop restarting HA is WeMo is found"
trigger:
platform: template
value_template: {% raw %}'{% if states.switch.wemo %}true{% else %}false{% endif %}'{% endraw %}
value_template: '{% if states.switch.wemo %}true{% else %}false{% endif %}'
condition:
condition: state
entity_id: script.restarthawemo
@ -92,3 +94,4 @@ automation:
entity_id: script.restarthawemo
```
{% endraw %}

View File

@ -8,6 +8,8 @@ ha_category: Automation Examples
This script allows you to use [TTS](/integrations/#text-to-speech) on Sonos.
{% raw %}
```yaml
script:
sonos_say:
@ -15,25 +17,28 @@ script:
sequence:
- service: sonos.snapshot
data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
entity_id: "{{ sonos_entity }}"
- service: sonos.unjoin
data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
entity_id: "{{ sonos_entity }}"
- service: media_player.volume_set
data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
volume_level: {% raw %}"{{ volume }}"{% endraw %}
entity_id: "{{ sonos_entity }}"
volume_level: "{{ volume }}"
- service: tts.voicerss_say
data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
message: {% raw %}"{{ message }}"{% endraw %}
- delay: {% raw %}"{{ delay }}"{% endraw %}
entity_id: "{{ sonos_entity }}"
message: "{{ message }}"
- delay: "{{ delay }}"
- service: sonos.restore
data:
entity_id: {% raw %}"{{ sonos_entity }}"{% endraw %}
entity_id: "{{ sonos_entity }}"
```
{% endraw %}
We call this now with:
```yaml
automation:
- alias: "test"
@ -48,6 +53,7 @@ automation:
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
@ -56,6 +62,7 @@ tts:
```
If you want to use this TTS engine, change the line in the example provided to:
```txt
- service: tts.google_translate_say
```

View File

@ -141,6 +141,8 @@ This small example illustrates how the "split" files work. In this case, we star
This (large) sensor configuration gives us another example:
{% raw %}
```yaml
### sensor.yaml
### METEOBRIDGE #############################################
@ -149,7 +151,7 @@ This (large) sensor configuration gives us another example:
host: 192.168.2.82
timeout: 6
payload: "Content-type: text/xml; charset=UTF-8\n\n"
value_template: "{% raw %}{{value.split (' ')[2]}}{% endraw %}"
value_template: "{{value.split (' ')[2]}}"
unit: C
- platform: tcp
name: "Outdoor Humidity (Meteobridge)"
@ -157,7 +159,7 @@ This (large) sensor configuration gives us another example:
port: 5556
timeout: 6
payload: "Content-type: text/xml; charset=UTF-8\n\n"
value_template: "{% raw %}{{value.split (' ')[3]}}{% endraw %}"
value_template: "{{value.split (' ')[3]}}"
unit: Percent
#### STEAM FRIENDS ##################################
@ -179,6 +181,8 @@ This (large) sensor configuration gives us another example:
name: "Ann Arbor"
```
{% endraw %}
You'll notice that this example includes a secondary parameter section (under the steam section) as well as a better example of the way comments can be used to break down files into sections.
That about wraps it up.

View File

@ -62,22 +62,27 @@ A full list of the parameters for a service can be found on the documentation pa
You can use [templating] support to dynamically choose which service to call. For example, you can call a certain service based on if a light is on.
{% raw %}
```yaml
service: >
{% raw %}{% if states('sensor.temperature') | float > 15 %}
{% if states('sensor.temperature') | float > 15 %}
switch.turn_on
{% else %}
switch.turn_off
{% endif %}{% endraw %}
{% endif %}
entity_id: switch.ac
```
{% endraw %}
### Using the Services Developer Tool
You can use the Services Developer Tool to test data to pass in a service call.
For example, you may test turning on or off a 'group' (See [groups] for more info)
To turn a group on or off, pass the following info:
- Domain: `homeassistant`
- Service: `turn_on`
- Service Data: `{ "entity_id": "group.kitchen" }`
@ -86,26 +91,29 @@ To turn a group on or off, pass the following info:
Templates can also be used for the data that you pass to the service call.
{% raw %}
```yaml
service: thermostat.set_temperature
data:
entity_id: >
{% raw %}{% if is_state('device_tracker.paulus', 'home') %}
{% if is_state('device_tracker.paulus', 'home') %}
thermostat.upstairs
{% else %}
thermostat.downstairs
{% endif %}{% endraw %}
temperature: {% raw %}{{ 22 - distance(states.device_tracker.paulus) }}{% endraw %}
{% endif %}
temperature: {{ 22 - distance(states.device_tracker.paulus) }}
```
{% endraw %}
### `homeassistant` services
There are four `homeassistant` services that aren't tied to any single domain, these are:
* `homeassistant.turn_on` - Turns on an entity (that supports being turned on), for example an `automation`, `switch`, etc
* `homeassistant.turn_off` - Turns off an entity (that supports being turned off), for example an `automation`, `switch`, etc
* `homeassistant.toggle` - Turns off an entity that is on, or turns on an entity that is off (that supports being turned on and off)
* `homeassistant.update_entity` - Request the update of an entity, rather than waiting for the next scheduled update, for example [Google travel time] sensor, a [template sensor], or a [light]
- `homeassistant.turn_on` - Turns on an entity (that supports being turned on), for example an `automation`, `switch`, etc
- `homeassistant.turn_off` - Turns off an entity (that supports being turned off), for example an `automation`, `switch`, etc
- `homeassistant.toggle` - Turns off an entity that is on, or turns on an entity that is off (that supports being turned on and off)
- `homeassistant.update_entity` - Request the update of an entity, rather than waiting for the next scheduled update, for example [Google travel time] sensor, a [template sensor], or a [light]
Complete service details and examples can be found on the [Home Assistant integration][homeassistant-integration-services] page.

View File

@ -210,18 +210,22 @@ ActivateSceneIntent activate {Scene}
Then add the intent to your `intent_script` section in your HA configuration file:
{% raw %}
```yaml
intent_script:
ActivateSceneIntent:
action:
service: scene.turn_on
data:
entity_id: scene.{% raw %}{{ Scene | replace(" ", "_") }}{% endraw %}
entity_id: scene.{{ Scene | replace(" ", "_") }}
speech:
type: plain
text: OK
```
{% endraw %}
Here we are using [templates] to take the name we gave to Alexa e.g., `downstairs on` and replace the space with an underscore so it becomes `downstairs_on` as Home Assistant expects.
Now say `Alexa ask Home Assistant to activate <some scene>` and Alexa will activate that scene for you.
@ -258,18 +262,22 @@ RunScriptIntent run {Script}
Then add the intent to your intent_script section in your HA configuration file:
{% raw %}
```yaml
intent_script:
RunScriptIntent:
action:
service: script.turn_on
data:
entity_id: script.{% raw %}{{ Script | replace(" ", "_") }}{% endraw %}
entity_id: script.{{ Script | replace(" ", "_") }}
speech:
type: plain
text: OK
```
{% endraw %}
Now say `Alexa ask Home Assistant to run <some script>` and Alexa will run that script for you.
### Support for Launch Requests

View File

@ -52,13 +52,17 @@ binary_sensor:
or a template based request:
{% raw %}
```yaml
# Example configuration.yaml entry
sensor:
- platform: rest
resource_template: {% raw %} "http://IP_ADDRESS/{{ now().strftime('%Y-%m-%d') }}" {% endraw %}
resource_template: "http://IP_ADDRESS/{{ now().strftime('%Y-%m-%d') }}"
```
{% endraw %}
{% configuration %}
resource:
description: The resource or endpoint that contains the value.
@ -131,6 +135,8 @@ Instead of using an [aREST](/integrations/arest#binary-sensor) binary sensor,
you could retrieve the value of a device supporting
aREST directly with a REST binary sensor.
{% raw %}
```yaml
binary_sensor:
- platform: rest
@ -138,9 +144,11 @@ binary_sensor:
method: GET
name: Light
device_class: light
value_template: {% raw %}'{{ value_json.return_value }}'{% endraw %}
value_template: '{{ value_json.return_value }}'
```
{% endraw %}
### Accessing an HTTP authentication protected endpoint
The REST sensor supports HTTP authentication and customized headers.

View File

@ -138,6 +138,8 @@ The requirement is that you have setup the [`xiaomi aqara` integration](/integra
#### Gas
{% raw %}
```yaml
- alias: Send notification on gas alarm
trigger:
@ -149,9 +151,11 @@ The requirement is that you have setup the [`xiaomi aqara` integration](/integra
- service: notify.html5
data:
title: Gas alarm!
message: "Gas with a density of {% raw %}{{ state_attr('binary_sensor.natgas_sensor_158dxxxxxxxxxx', 'density') }}{% endraw %} detected."
message: "Gas with a density of {{ state_attr('binary_sensor.natgas_sensor_158dxxxxxxxxxx', 'density') }} detected."
```
{% endraw %}
#### Xiaomi Wireless Button
As indicated in the table on top of this page there are 3 versions of the button. For the round shaped button the available events are `single`, `double`, `hold`, `long_click_press` and `long_click_release`. Aqara branded buttons are square shaped. Model WXKG11LM only supports `single`, `double`, `long_click_press`and `hold` events. WXKG12LM supports `single`, `double`, `long_click_press` and `shake` events. For the Aqara versions the delay between two clicks to generate a double click must be larger than with the round button. Clicking too quickly generates a single click event.
@ -263,6 +267,8 @@ Available events are `flip90`, `flip180`, `move`, `tap_twice`, `shake_air`, `swi
The Aqara Wireless Switch is available as single-key and double-key version. Each key behaves like the Wireless Button limited to the click event `single`. The double key version adds a third device called `binary_sensor.wall_switch_both_158xxxxxxxxx12` which reports a click event called `both` if both keys are pressed.
{% raw %}
```yaml
- alias: Decrease brightness of the gateway light
trigger:
@ -275,7 +281,7 @@ The Aqara Wireless Switch is available as single-key and double-key version. Eac
service: light.turn_on
entity_id: light.gateway_light_34xxxxxxxx13
data:
brightness: {% raw %}>-
brightness: >-
{% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') %}
{% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') - 60 >= 10 %}
{{state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') - 60}}
@ -284,7 +290,7 @@ The Aqara Wireless Switch is available as single-key and double-key version. Eac
{% endif %}
{% else %}
10
{% endif %}{% endraw %}
{% endif %}
- alias: Increase brightness of the gateway light
trigger:
@ -297,7 +303,7 @@ The Aqara Wireless Switch is available as single-key and double-key version. Eac
service: light.turn_on
entity_id: light.gateway_light_34xxxxxxxx13
data:
brightness: {% raw %}>-
brightness: >-
{% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') %}
{% if state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') + 60 <= 255 %}
{{state_attr('light.gateway_light_34xxxxxxxx13', 'brightness') + 60}}
@ -306,7 +312,7 @@ The Aqara Wireless Switch is available as single-key and double-key version. Eac
{% endif %}
{% else %}
10
{% endif %}{% endraw %}
{% endif %}
- alias: Turn off the gateway light
trigger:
@ -320,6 +326,8 @@ The Aqara Wireless Switch is available as single-key and double-key version. Eac
entity_id: light.gateway_light_34xxxxxxxx13
```
{% endraw %}
#### Vibration Sensor
This automation toggles the living room lamp on vibration/tilt.

View File

@ -86,6 +86,9 @@ Users of TVs older than 2013 have another option for controlling their TV via Ho
If you have a Raspberry Pi connected to your TV:
{% raw %}
```yaml
switch:
- platform: command_line
@ -94,9 +97,11 @@ switch:
command_on: ssh root@[IP] "echo 'on 0' | cec-client -s"
command_off: ssh root@[IP] "echo 'standby 0' | cec-client -s"
command_state: ssh root@[IP] "echo 'pow 0' | cec-client -s |grep 'power status:'"
value_template: {% raw %}'{{ value == "power status: on" }}{% endraw %}'
value_template: '{{ value == "power status: on" }}'
```
{% endraw %}
Using `cec-client` is a great method to turn your TV off/on, however the trade off is if you're using Kodi, it will no longer be able to control your TV using the TV Remote.
This is because only one process can control the CEC functionality within the Raspberry Pi at a time and running the above commands terminates the functionality inside libCEC within Kodi. Kodi must be restarted for TV remove functionality to work again.

View File

@ -499,13 +499,17 @@ First get or learn all the remotes you want to add to Home Assistant in e-Contro
7. Drag a Template node on the Flow to the right of the RM node and link it to the RM node.
8. Double click the Template node to edit it, select:
{% raw %}
```bash
Property: msg.payload
Format: Mustache template
Template field: enter '{% raw %}{{payload.data}}{% endraw %}'.
Template field: enter '{{payload.data}}'.
Output as: Plain text
```
{% endraw %}
9. Drag a Debug node to the right of the Template node and link them.
10. Show the debug messages, deploy the flow and click on the inject button.
11. A message will show in the debug window:

View File

@ -41,6 +41,8 @@ By default, it will support turning devices on and off. You can say things like
Here is a simple example to be able to ask what the temperature in the living room is.
{% raw %}
```yaml
# Example configuration.yaml entry
conversation:
@ -51,9 +53,11 @@ conversation:
intent_script:
LivingRoomTemperature:
speech:
text: It is currently {% raw %}{{ states.sensor.temperature }}{% endraw %} degrees in the living room.
text: It is currently {{ states.sensor.temperature }} degrees in the living room.
```
{% endraw %}
## Adding advanced custom sentences
Sentences can contain slots (marked with curly braces: `{name}`) and optional words (marked with square brackets: `[the]`). The values of slots will be passed on to the intent and are available inside the templates.

View File

@ -66,7 +66,7 @@ covers:
description: Defines number of seconds for command timeout.
required: false
type: integer
default: 15
default: 15
{% endconfiguration %}
## Examples
@ -75,6 +75,9 @@ In this section you find some real-life examples of how to use this sensor.
### Full configuration
{% raw %}
```yaml
# Example configuration.yaml entry
cover:
@ -85,11 +88,12 @@ cover:
command_close: move_command down garage
command_stop: move_command stop garage
command_state: state_command garage
value_template: {% raw %}>
value_template: >
{% if value == 'open' %}
100
{% elif value == 'closed' %}
0
{% endif %}
{% endraw %}
```
{% endraw %}

View File

@ -141,6 +141,8 @@ sensor:
Use a `value_template` to add 1500 to the feed value for all specified feed IDs in `include_feed_id`.
{% raw %}
```yaml
# Example configuration.yaml entry
sensor:
@ -149,12 +151,14 @@ sensor:
url: https://emoncms.org
scan_interval: 15
id: 1
value_template: {% raw %}"{{ value | float + 1500 }}"{% endraw %}
value_template: "{{ value | float + 1500 }}"
include_only_feed_id:
- 107
- 106
```
{% endraw %}
Display feeds from the same Emoncms instance with 2 groups of feeds, different `scan_interval` and a different `unit_of_measurement`.
```yaml

View File

@ -123,6 +123,8 @@ EnOcean binary sensors have no state, they only generate 'button_pressed' events
Sample automation to switch lights on and off:
{% raw %}
```yaml
# Example automation to turn lights on/off on button release
automation:
@ -134,11 +136,13 @@ automation:
id: [0xYY, 0xYY, 0xYY, 0xYY]
pushed: 0
action:
service: "{% raw %}{% if trigger.event.data.onoff %} light.turn_on {% else %} light.turn_off {%endif %}{% endraw %}"
service: "{% if trigger.event.data.onoff %} light.turn_on {% else %} light.turn_off {%endif %}"
data:
entity_id: "{% raw %}{% if trigger.event.data.which == 1 %} light.hall_left {% else %} light.hall_right {%endif %}{% endraw %}"
entity_id: "{% if trigger.event.data.which == 1 %} light.hall_left {% else %} light.hall_right {%endif %}"
```
{% endraw %}
## Light
An EnOcean light can take many forms. Currently only one type has been tested: Eltako FUD61 dimmer.

View File

@ -65,6 +65,8 @@ automation:
entity_id: script.my_action
```
{% raw %}
```yaml
automation:
- alias: Send notification of RSS feed title when updated
@ -75,10 +77,12 @@ automation:
service: persistent_notification.create
data:
title: "New HA Podcast available"
message: {% raw %}"New Podcast available - {{ as_timestamp(now()) | timestamp_custom('%I:%M:%S %p %d%b%Y', true) }}"{% endraw %}
notification_id: {% raw %}"{{ trigger.event.data.title }}"{% endraw %}
message: "New Podcast available - {{ as_timestamp(now()) | timestamp_custom('%I:%M:%S %p %d%b%Y', true) }}"
notification_id: "{{ trigger.event.data.title }}"
```
{% endraw %}
Any field under the `<entry>` tag in the feed can be used for example `trigger.event.data.content` will get the body of the feed entry.
For more advanced use cases, a custom integration registering to the `feedreader` event type could be used instead:

View File

@ -99,12 +99,16 @@ Assuming that the log file contains multiple values formatted as JSON like shown
This would require the following entry in the `configuration.yaml` file to extract the temperature:
{% raw %}
```yaml
# Example configuration.yaml entry
sensor:
- platform: file
name: Temperature
file_path: /home/user/.homeassistant/sensor.json
value_template: {% raw %}'{{ value_json.temperature }}'{% endraw %}
value_template: '{{ value_json.temperature }}'
unit_of_measurement: "°C"
```
{% endraw %}

View File

@ -91,6 +91,8 @@ Event data:
To help detect and debug flic button clicks, you can use this automation that send a notification on very click type of every button. This example uses the [HTML5 push notification platform](/integrations/html5). Visit the [notification integration page](/integrations/notify/) for more information on setting up notifications.
{% raw %}
```yaml
automation:
- alias: FLIC Html5 notify on every click
@ -101,9 +103,11 @@ automation:
- service: notify.html5
data:
title: "flic click"
message: {% raw %}"flic {{ trigger.event.data.button_name }} was {{ trigger.event.data.click_type }} clicked"{% endraw %}
message: "flic {{ trigger.event.data.button_name }} was {{ trigger.event.data.click_type }} clicked"
```
{% endraw %}
### Ignoring Click Types
For some purposes it might make sense to exclude a specific click type from triggering click events. For example when ignoring double clicks, pressing the button twice fast results in two `single` instead of a `double` click event. This is very useful for applications where you want to click fast.

View File

@ -205,16 +205,21 @@ This does *not* affect the entities in Home Assistant. They all use their own co
Most devices have, besides their state, additional attributes like their battery state or valve position. These can be accessed using templates in automations, or even as their own entities using the [template sensor](/integrations/template) component. Here's an example of a template sensor that exposes the valve position of a thermostat.
{% raw %}
```yaml
sensor:
- platform: template
sensors:
bedroom_valve:
value_template: "{% raw %}{{ state_attr('climate.leq123456', 'level') }}{% endraw %}"
value_template: "{{ state_attr('climate.leq123456', 'level') }}"
entity_id: climate.leq123456
friendly_name: "Bedroom valve"
```
{% endraw %}
### Variables
It is possible to read and set values of system variables you have setup on the CCU/Homegear. The supported types for setting values are float- and bool-variables. With the CCU a user with Admin-access is required.
@ -472,15 +477,19 @@ automation:
3. Set up a template sensor in Home Assistant, which contains the value of the system variable:
{% raw %}
```yaml
- platform: template
sensors:
v_last_reboot:
value_template: "{% raw %}{{ state_attr('homematic.ccu2', 'V_Last_Reboot') or '01.01.1970 00:00:00' }}{% endraw %}"
value_template: "{{ state_attr('homematic.ccu2', 'V_Last_Reboot') or '01.01.1970 00:00:00' }}"
icon_template: "mdi:clock"
entity_id: homematic.ccu2
```
{% endraw %}
4. Set up an automation which calls *homematic.reconnect* whenever the sensor variable changes:
```yaml

View File

@ -93,6 +93,8 @@ Valid sensor_types:
In order to get two sensors reporting CPU fan speed and Ambient Inlet Temperature, as well as a dump of `server_health` on a HP Microserver Gen8, you could use the following in your `configuration.yaml` file
{% raw %}
```yaml
sensor:
- platform: hp_ilo
@ -103,16 +105,17 @@ sensor:
- name: CPU fanspeed
sensor_type: server_health
unit_of_measurement: "%"
value_template: '{% raw %}{{ ilo_data.fans["Fan 1"].speed[0] }}{% endraw %}'
value_template: '{{ ilo_data.fans["Fan 1"].speed[0] }}'
- name: Inlet temperature
sensor_type: server_health
unit_of_measurement: "°C"
value_template: '{% raw %}{{ ilo_data.temperature["01-Inlet Ambient"].currentreading[0] }}{% endraw %}'
value_template: '{{ ilo_data.temperature["01-Inlet Ambient"].currentreading[0] }}'
- name: Server Health
sensor_type: server_health
```
{% endraw %}
<p class='img'>
<img src='/images/screenshots/hp_ilo_sensors.png' />
</p>

View File

@ -508,6 +508,8 @@ The example configuration entry below create two request to your local InfluxDB
- `select last(value) as value from "°C" where "name" = "foo"`
- `select min(tmp) as value from "%" where "entity_id" = ''salon'' and time > now() - 1h`
{% raw %}
```yaml
sensor:
platform: influxdb
@ -518,7 +520,7 @@ username: home-assistant
queries:
- name: last value of foo
unit_of_measurement: °C
value_template: '{% raw %}{{ value | round(1) }}{% endraw %}'
value_template: '{{ value | round(1) }}'
group_function: last
where: '"name" = ''foo'''
measurement: '"°C"'
@ -526,7 +528,7 @@ username: home-assistant
database: db1
- name: Min for last hour
unit_of_measurement: "%"
value_template: '{% raw %}{{ value | round(1) }}{% endraw %}'
value_template: '{{ value | round(1) }}'
group_function: min
where: '"entity_id" = ''salon'' and time > now() - 1h'
measurement: '"%"'
@ -534,8 +536,12 @@ username: home-assistant
database: db2
```
{% endraw %}
### Full configuration for 2.xx installations
{% raw %}
```yaml
sensor:
- platform: influxdb
@ -547,9 +553,9 @@ sensor:
- range_start: "-1d"
name: "How long have I been here"
query: >
filter(fn: (r) => r._domain == "person" and r._entity_id == "me" and r._value != "{% raw %} {{ states('person.me') }} {% endraw %}")
filter(fn: (r) => r._domain == "person" and r._entity_id == "me" and r._value != "{{ states('person.me') }}")
|> map(fn: (r) => ({ _value: r._time }))
value_template: "{% raw %} {{ relative_time(strptime(value, '%Y-%m-%d %H:%M:%S %Z')) }} {% endraw %}"
value_template: "{{ relative_time(strptime(value, '%Y-%m-%d %H:%M:%S %Z')) }}"
- range_start: "-1d"
name: "Cost of my house today across all power sensor"
query: >
@ -558,7 +564,7 @@ sensor:
|> sort(columns: ["_time"], desc: false)
|> integral(unit: 5s, column: "_value")
imports: regexp
value_template: "{% raw %} {{ value|float / 24.0 / 1000.0 * states('sensor.current_cost_per_kwh')|float }} {% endraw %}"
value_template: "{{ value|float / 24.0 / 1000.0 * states('sensor.current_cost_per_kwh')|float }}"
- range_start: "-1d"
bucket: Glances Bucket
name: "Average CPU temp today"
@ -566,6 +572,8 @@ sensor:
group_function: mean
```
{% endraw %}
Note that when working with Flux queries, the resultset is broken into tables, you can see how this works in the Data Explorer of the UI. If you are operating on data created by the InfluxDB history component, this means by default, you will have a table for each entity and each attribute of each entity (other then `unit_of_measurement` and any others you promoted to tags).
This is a lot more tables compared to 1.xx queries, where you essentially had one table per `unit_of_measurement` across all entities. You can still create aggregate metrics across multiple sensors though. As you can see in the example above, a good way to do this is with the [keep](https://v2.docs.influxdata.com/v2.0/reference/flux/stdlib/built-in/transformations/keep/) or [drop](https://v2.docs.influxdata.com/v2.0/reference/flux/stdlib/built-in/transformations/drop/) filters. When you remove key columns Influx merges tables, allowing you to make many tables that share a schema for `_value` into one.

View File

@ -11,18 +11,22 @@ ha_iot_class:
The `intent_script` integration allows users to configure actions and responses to intents. Intents can be fired by any integration that supports it. Examples are [Alexa](/integrations/alexa/) (Amazon Echo), [Dialogflow](/integrations/dialogflow/) (Google Assistant) and [Snips](/integrations/snips/).
{% raw %}
```yaml
# Example configuration.yaml entry
intent_script:
GetTemperature: # Intent type
speech:
text: We have {% raw %}{{ states.sensor.temperature }}{% endraw %} degrees
text: We have {{ states.sensor.temperature }} degrees
action:
service: notify.notify
data:
message: Hello from an intent!
```
{% endraw %}
Inside an intent we can define these variables:
{% configuration %}

View File

@ -936,6 +936,8 @@ In this section you find some real-life examples of how to use this light.
For a simple string payload with the format `state,brightness,r-g-b` (e.g., `on,255,255-255-255`), add the following to your `configuration.yaml` file:
{% raw %}
```yaml
# Example configuration.yaml entry
light:
@ -943,19 +945,23 @@ light:
schema: template
command_topic: "home/rgb1/set"
state_topic: "home/rgb1/status"
command_on_template: "{% raw %}on,{{ brightness|d }},{{ red|d }}-{{ green|d }}-{{ blue|d }}{% endraw %}"
command_on_template: "on,{{ brightness|d }},{{ red|d }}-{{ green|d }}-{{ blue|d }}"
command_off_template: "off"
state_template: "{% raw %}{{ value.split(',')[0] }}{% endraw %}" # must return `on` or `off`
brightness_template: "{% raw %}{{ value.split(',')[1] }}{% endraw %}"
red_template: "{% raw %}{{ value.split(',')[2].split('-')[0] }}{% endraw %}"
green_template: "{% raw %}{{ value.split(',')[2].split('-')[1] }}{% endraw %}"
blue_template: "{% raw %}{{ value.split(',')[2].split('-')[2] }}{% endraw %}"
state_template: "{{ value.split(',')[0] }}" # must return `on` or `off`
brightness_template: "{{ value.split(',')[1] }}"
red_template: "{{ value.split(',')[2].split('-')[0] }}"
green_template: "{{ value.split(',')[2].split('-')[1] }}"
blue_template: "{{ value.split(',')[2].split('-')[2] }}"
```
{% endraw %}
### JSON payload
For a JSON payload with the format `{"state": "on", "brightness": 255, "color": [255, 255, 255], "effect": "rainbow"}`, add the following to your `configuration.yaml` file:
{% raw %}
```yaml
# Example configuration.yaml entry
light:
@ -966,7 +972,7 @@ light:
- colorloop
command_topic: "home/rgb1/set"
state_topic: "home/rgb1/status"
command_on_template: >{% raw %}
command_on_template: >
{"state": "on"
{%- if brightness is defined -%}
, "brightness": {{ brightness }}
@ -977,16 +983,18 @@ light:
{%- if effect is defined -%}
, "effect": "{{ effect }}"
{%- endif -%}
}{% endraw %}
}
command_off_template: '{"state": "off"}'
state_template: '{% raw %}{{ value_json.state }}{% endraw %}'
brightness_template: '{% raw %}{{ value_json.brightness }}{% endraw %}'
red_template: '{% raw %}{{ value_json.color[0] }}{% endraw %}'
green_template: '{% raw %}{{ value_json.color[1] }}{% endraw %}'
blue_template: '{% raw %}{{ value_json.color[2] }}{% endraw %}'
effect_template: '{% raw %}{{ value_json.effect }}{% endraw %}'
state_template: '{{ value_json.state }}'
brightness_template: '{{ value_json.brightness }}'
red_template: '{{ value_json.color[0] }}'
green_template: '{{ value_json.color[1] }}'
blue_template: '{{ value_json.color[2] }}'
effect_template: '{{ value_json.effect }}'
```
{% endraw %}
### Template schema - No brightness or color support
If you don't want brightness, color or effect support, just omit the corresponding configuration sections.

View File

@ -58,17 +58,21 @@ locations:
To explore the data available within the `data` attribute of a sensor use the `dev-template` tool on the Home Assistant frontend. `data` contains a list of monitored sites, where the number of monitored sites are given by the `sites` attribute. If a sensor has four sites, access the fourth site by indexing the list of sites using data[3]. Each site is a dictionary with multiple fields, with entries for the `latitude` and `longitude` of that site, a `pollution_status`, `site_code`, `site_name` and `site_type`. The field `number_of_pollutants` states how many pollutants are monitored (of the possible six) and the field `pollutants` returns a list with data for each pollutant. To access the first pollutant in the list for site zero use `attributes.data[0].pollutants[0]`. Each entry in `pollutants` is a dictionary with fields for the pollutant `code`, `description`, `index`, `quality` and a `summary`. [Template sensors](/integrations/template) can then be added to display these attributes, for example:
{% raw %}
```yaml
# Example template sensors
- platform: template
sensors:
updated:
friendly_name: "Updated"
value_template: {% raw %}'{{state_attr('sensor.merton', 'updated')}}'{% endraw %}
value_template: '{{state_attr('sensor.merton', 'updated')}}'
merton_pm10:
friendly_name: "Merton PM10"
value_template: {% raw %}'{{state_attr('sensor.merton', 'data')[0].pollutants[0].summary}}'{% endraw %}
value_template: '{{state_attr('sensor.merton', 'data')[0].pollutants[0].summary}}'
westminster_s02:
friendly_name: "Westminster S02"
value_template: {% raw %}'{{state_attr('sensor.westminster', 'data')[0].pollutants[3].summary}}'{% endraw %}
value_template: '{{state_attr('sensor.westminster', 'data')[0].pollutants[3].summary}}'
```
{% endraw %}

View File

@ -42,17 +42,25 @@ action:
After you setup a [notifier](/integrations/#notifications) a simple way to test if you have set up your notify platform correctly, is to open **Developer Tools** from the sidebar and then select the **Services** tab. Choose your service from the **Service** dropdown menu, enter the sample below into the **Service Data** field, and press the **CALL SERVICE** button.
{% raw %}
```json
{
"message": "The sun is {% raw %}{% if is_state('sun.sun', 'above_horizon') %}up{% else %}down{% endif %}{% endraw %}!"
"message": "The sun is {% if is_state('sun.sun', 'above_horizon') %}up{% else %}down{% endif %}!"
}
```
{% endraw %}
The automation equivalent would be:
{% raw %}
```yaml
action:
service: notify.notify
data:
message: "The sun is {% raw %}{% if is_state('sun.sun', 'above_horizon') %}up{% else %}down{% endif %}{% endraw %}!"
message: "The sun is {% if is_state('sun.sun', 'above_horizon') %}up{% else %}down{% endif %}!"
```
{% endraw %}

View File

@ -117,6 +117,7 @@ script:
- TX-55EXW604S
- TX-55FX680W
- TX-55FZ802B
- TX-58AX802B
- TX-58DX700B
- TX-65EXW784
- TX-65FX720W

View File

@ -146,42 +146,54 @@ In this section you find some real-life examples of how to use this sensor.
You can find your external IP address using the service [JSON Test](https://www.jsontest.com/) at their [http://ip.jsontest.com/](http://ip.jsontest.com/) URL.
{% raw %}
```yaml
sensor:
- platform: rest
resource: http://ip.jsontest.com
name: External IP
value_template: '{% raw %}{{ value_json.ip }}{% endraw %}'
value_template: '{{ value_json.ip }}'
```
{% endraw %}
### Single value from a local Glances instance
The [glances](/integrations/glances) sensor is doing the exact same thing for all exposed values.
{% raw %}
```yaml
sensor:
- platform: rest
resource: http://IP_ADRRESS:61208/api/2/mem/used
name: Used mem
value_template: '{% raw %}{{ value_json.used| multiply(0.000000954) | round(0) }}{% endraw %}'
value_template: '{{ value_json.used| multiply(0.000000954) | round(0) }}'
unit_of_measurement: MB
```
{% endraw %}
### Value from another Home Assistant instance
The Home Assistant [API](/developers/rest_api/) exposes the data from your attached sensors. If you are running multiple Home Assistant instances which are not [connected](/developers/architecture/#multiple-connected-instances) you can still get information from them.
If the Home Assistant instance in the resource variable is protected by an API password, you can append `?api_password=YOUR_PASSWORD` to the resource URL to authenticate or use `headers:`.
{% raw %}
```yaml
sensor:
- platform: rest
resource: http://IP_ADDRESS:8123/api/states/sensor.weather_temperature
name: Temperature
value_template: {% raw %}'{{ value_json.state }}'{% endraw %}
value_template: '{{ value_json.state }}'
unit_of_measurement: "°C"
```
{% endraw %}
### Accessing an HTTP authentication protected endpoint
The REST sensor supports HTTP authentication and customized headers.
@ -229,6 +241,8 @@ my_sensor_secret_token: Bearer gh_DHQIXKVf6Pr4H8Yqz8uhApk_mnV6Zje6Pr4H8Yqz8A8nCx
This sample is very similar to the [`updater`](/integrations/updater/) integration but the information is received from GitHub.
{% raw %}
```yaml
sensor:
- platform: rest
@ -236,13 +250,15 @@ sensor:
username: YOUR_GITHUB_USERNAME
password: YOUR_GITHUB_ACCESS_TOKEN
authentication: basic
value_template: '{% raw %}{{ value_json.tag_name }}{% endraw %}'
value_template: '{{ value_json.tag_name }}'
headers:
Accept: application/vnd.github.v3+json
Content-Type: application/json
User-Agent: Home Assistant REST sensor
```
{% endraw %}
### Fetch multiple JSON values and present them as attributes
[JSON Test](https://www.jsontest.com/) returns the current time, date and milliseconds since epoch from [http://date.jsontest.com/](http://date.jsontest.com/).

View File

@ -13,6 +13,8 @@ The `rss_feed_template` integration can export any information from Home Assista
For example, on Android, the app "Simple RSS Widget" can be used to display temperatures on the home screen.
{% raw %}
```yaml
# Example configuration.yaml entry
rss_feed_template:
@ -20,12 +22,14 @@ rss_feed_template:
# Example: https://localhost:8123/api/rss_template/garden
garden:
requires_api_password: false
title: "Garden {% raw %}{{ as_timestamp(now())|timestamp_custom('%H:%M', True) }}{% endraw %}"
title: "Garden {{ as_timestamp(now())|timestamp_custom('%H:%M', True) }}"
items:
- title: "Outside temperature"
description: "{% raw %}{% if is_state('sensor.temp_outside','unknown') %}---{% else %}{{states('sensor.temp_outside')}} °C{% endif %}{% endraw %}"
description: "{% if is_state('sensor.temp_outside','unknown') %}---{% else %}{{states('sensor.temp_outside')}} °C{% endif %}"
```
{% endraw %}
{% configuration %}
requires_api_password:
description: If true and an API password is set, the password must be passed via '?api_password=...' parameter.

View File

@ -195,6 +195,8 @@ automation:
Using the variables in the script requires the use of templates:
{% raw %}
```yaml
# Example configuration.yaml entry
script:
@ -213,10 +215,12 @@ script:
state: "on"
- service: notify.pushover
data:
title: "{% raw %}{{ title }}{% endraw %}"
message: "{% raw %}{{ message }}{% endraw %}"
title: "{{ title }}"
message: "{{ message }}"
```
{% endraw %}
### Waiting for Script to Complete
When calling a script "directly" (e.g., `script.NAME`) the calling script will wait for the called script to finish.

View File

@ -46,6 +46,8 @@ The `spc` alarm control panel platform allows you to control your [Vanderbilt SP
The `changed_by` attribute enables one to be able to take different actions depending on who armed/disarmed the alarm in [automation](/getting-started/automation/).
{% raw %}
```yaml
automation:
- alias: Alarm status changed
@ -56,11 +58,13 @@ automation:
- service: notify.notify
data:
message: >
{% raw %}Alarm changed from {{ trigger.from_state.state }}
Alarm changed from {{ trigger.from_state.state }}
to {{ trigger.to_state.state }}
by {{ trigger.to_state.attributes.changed_by }}{% endraw %}
by {{ trigger.to_state.attributes.changed_by }}
```
{% endraw %}
## Binary Sensor
The `spc` platform allows you to get data from your [Vanderbilt SPC](https://www.spcsupportinfo.com/SPCConnectPro/) binary sensors from within Home Assistant.

View File

@ -88,6 +88,8 @@ The example below is doing the same as the
The command line tool [`curl`](https://curl.haxx.se/) is used to toggle a pin
which is controllable through REST.
{% raw %}
```yaml
# Example configuration.yaml entry
switch:
@ -97,10 +99,12 @@ switch:
command_on: "/usr/bin/curl -X GET http://192.168.1.10/digital/4/1"
command_off: "/usr/bin/curl -X GET http://192.168.1.10/digital/4/0"
command_state: "/usr/bin/curl -X GET http://192.168.1.10/digital/4"
value_template: '{% raw %}{{ value == "1" }}{% endraw %}'
value_template: '{{ value == "1" }}'
friendly_name: Kitchen Lightswitch
```
{% endraw %}
Given this example, in the UI one would see the `friendly_name` of
"Kitchen Light". However, the `identifier` is `arest_pin_four`, making the
`entity_id` `switch.arest_pin_four`, which is what one would use in
@ -145,6 +149,8 @@ Commands ([Source](https://www.iltucci.com/blog/wp-content/uploads/2018/12/Fosca
This switch supports statecmd,
which checks the current state of motion detection.
{% raw %}
```yaml
# Example configuration.yaml entry
switch:
@ -154,8 +160,10 @@ switch:
command_on: 'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=1&usr=admin&pwd=password"'
command_off: 'curl -k "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=setMotionDetectConfig&isEnable=0&usr=admin&pwd=password"'
command_state: 'curl -k --silent "https://ipaddress:443/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=admin&pwd=password" | grep -oP "(?<=isEnable>).*?(?=</isEnable>)"'
value_template: {% raw %}'{{ value == "1" }}'{% endraw %}
value_template: '{{ value == "1" }}'
```
{% endraw %}
- Replace admin and password with an "Admin" privileged Foscam user
- Replace ipaddress with the local IP address of your Foscam

View File

@ -81,6 +81,8 @@ $ echo "r WaterPressure" | nc 10.0.0.127 8888
You will notice that the output from the service is not just a single value (it contains ";ok" as well). To grab the value we're interested in, we can use a Jinja2 template. The response received is injected into the template as the `value` variable. To use this value within Home Assistant, use the following configuration:
{% raw %}
```yaml
sensor:
# Example configuration.yaml entry
@ -90,10 +92,12 @@ sensor:
port: 8888
timeout: 5
payload: "r WaterPressure\n"
value_template: "{% raw %}{{ value.split(';')[0] }}{% endraw %}"
value_template: "{{ value.split(';')[0] }}"
unit_of_measurement: Bar
```
{% endraw %}
#### hddtemp
The tool `hddtemp` collects the temperature of your hard disks.
@ -115,6 +119,8 @@ Escape character is '^]'.
The entry for the `configuration.yaml` file for a `hddtemp` sensor could look like the example below.
{% raw %}
```yaml
sensor:
# Example configuration.yaml entry
@ -124,10 +130,13 @@ sensor:
port: 7634
timeout: 5
payload: "\n"
value_template: "{% raw %}{{ value.split('|')[3] }}{% endraw %}"
value_template: "{{ value.split('|')[3] }}"
unit_of_measurement: "°C"
```
{% endraw %}
## Binary Sensor
The TCP Binary Sensor is a type of [TCP Sensor](#sensor) which is either "off" or "on". In order to use this sensor type, in addition to the configuration for the TCP Sensor, you must supply a `value_on` value to represent what is returned when the device is turned on.

View File

@ -158,6 +158,8 @@ model:
`categories` can also be defined as dictionary providing an `area` for each category as seen in the advanced configuration below:
{% raw %}
```yaml
# Example advanced configuration.yaml entry
image_processing:
@ -166,8 +168,8 @@ image_processing:
- entity_id: camera.driveway
- entity_id: camera.backyard
file_out:
- "/tmp/{% raw %}{{ camera_entity.split('.')[1] }}{% endraw %}_latest.jpg"
- "/tmp/{% raw %}{{ camera_entity.split('.')[1] }}_{{ now().strftime('%Y%m%d_%H%M%S') }}{% endraw %}.jpg"
- "/tmp/{{ camera_entity.split('.')[1] }}_latest.jpg"
- "/tmp/{{ camera_entity.split('.')[1] }}_{{ now().strftime('%Y%m%d_%H%M%S') }}.jpg"
model:
graph: /config/tensorflow/models/efficientdet_d0_coco17_tpu-32/
categories:
@ -181,6 +183,8 @@ image_processing:
- truck
```
{% endraw %}
## Optimizing resources
[Image processing components](/integrations/image_processing/) process the image from a camera at a fixed period given by the `scan_interval`. This leads to excessive processing if the image on the camera hasn't changed, as the default `scan_interval` is 10 seconds. You can override this by adding to your configuration `scan_interval: 10000` (setting the interval to 10,000 seconds), and then call the `image_processing.scan` service when you actually want to perform processing.

View File

@ -134,13 +134,17 @@ data:
With a template:
{% raw %}
```yaml
service: tts.google_translate_say
data:
message: "Temperature is {% raw %}{{states('sensor.temperature')}}{% endraw %}."
message: "Temperature is {{states('sensor.temperature')}}."
cache: false
```
{% endraw %}
## Cache
The integration has two caches. Both caches can be controlled with the `cache` option in the platform configuration or the service call `say`. A long time cache will be located on the file system. The in-memory cache for fast responses to media players will be auto-cleaned after a short period.

View File

@ -135,24 +135,28 @@ sensor:
And the template sensor for viewing the next bus attributes.
{% raw %}
```yaml
# Example configuration.yaml entry for a template sensor to access the attributes of the next departing bus.
- platform: template
sensors:
next_bus_route:
friendly_name: "Next bus route"
value_template: {% raw %}"{{state_attr('sensor.next_bus_to_wantage', 'next_buses')[0].route}}"{% endraw %}
value_template: "{{state_attr('sensor.next_bus_to_wantage', 'next_buses')[0].route}}"
next_bus_direction:
friendly_name: "Next bus direction"
value_template: {% raw %}"{{state_attr('sensor.next_bus_to_wantage', 'next_buses')[0].direction}}"{% endraw %}
value_template: "{{state_attr('sensor.next_bus_to_wantage', 'next_buses')[0].direction}}"
next_bus_scheduled:
friendly_name: "Next bus scheduled"
value_template: {% raw %}"{{state_attr('sensor.next_bus_to_wantage', 'next_buses')[0].scheduled}}"{% endraw %}
value_template: "{{state_attr('sensor.next_bus_to_wantage', 'next_buses')[0].scheduled}}"
next_bus_estimated:
friendly_name: "Next bus estimated"
value_template: {% raw %}"{{state_attr('sensor.next_bus_to_wantage', 'next_buses')[0].estimated}}"{% endraw %}
value_template: "{{state_attr('sensor.next_bus_to_wantage', 'next_buses')[0].estimated}}"
```
{% endraw %}
## Managing API requests
If you wish to manage the rate of API requests (e.g., to disable requests when you aren't interested in travel, so that you can request updates more frequently when you do travel) set a really long `scan_interval` in the configuration options, and use the service `homeassistant.update_entity` to request the update of an entity, rather than waiting for the next scheduled update.

View File

@ -164,6 +164,8 @@ Number 4 sends a text-file, retrieved from Github, renamed to `Hass_Cheatsheet.t
Number 5 sends an image retrieved from a URL, and an additional text message with `title` and `message`.
{% raw %}
```yaml
# Example script.yaml entry
5_send_jabber_message_with_image_and_text:
@ -172,13 +174,17 @@ Number 5 sends an image retrieved from a URL, and an additional text message wit
- service: notify.jabber
data:
title: "The Time is now"
message: "{% raw %} {{ {% endraw %}now(){% raw %} }} {% endraw %}, templating works as well..."
message: "{{ now() }}, templating works as well..."
data:
url: "https://github.com/home-assistant/home-assistant.io/raw/next/source/images/favicon-192x192.png"
```
{% endraw %}
Number 6 sends an image from a templated URL.
{% raw %}
```yaml
# Example script.yaml entry
6_send_jabber_message_with_image_from_url_template:
@ -189,9 +195,11 @@ Number 6 sends an image from a templated URL.
title: ""
message: ""
data:
url_template: "https://www.foto-webcam.eu/webcam/dornbirn/{% raw %}{{ now().year }}/{{ '%02d' % now().month }}/{{ '%02d' % now().day }}/{{ '%02d' % now().hour }}{{ (now().minute + 58) % 60 // 10}}{% endraw %}0_hd.jpg"
url_template: "https://www.foto-webcam.eu/webcam/dornbirn/{{ now().year }}/{{ '%02d' % now().month }}/{{ '%02d' % now().day }}/{{ '%02d' % now().hour }}{{ (now().minute + 58) % 60 // 10}}0_hd.jpg"
```
{% endraw %}
The possible source of a file is prioritized and only one will be picked up. `url_template` has the hightest priority; next is `url` then `path_template` and finally if none of them are defined `path` would be used. `path` will be used to eliminate file extension guessing for unknown URL downloads. Only the file extension will be left, as Home Assistant changes the filename to a random string for added privacy.
To find out more about notifications, please see the [getting started with automation page](/getting-started/automation/).

View File

@ -59,10 +59,14 @@ Alrighty, it's time for Home Assistant 0.10. A lot amazing things have changed a
This release introduces templates. This will allow you to parse data before it gets processed or create messages for notifications on the fly based on data within Home Assistant. The notification component and the new Alexa/Amazon Echo component are both using the new template functionality to render responses. A template editor has been added to the developer tool section in the app so you can get instant feedback if your templates are working or not.
{% raw %}
```text
The temperature at home is {% raw %}{{ states('sensor.temperature') }}{% endraw %}.
The temperature at home is {{ states('sensor.temperature') }}.
```
{% endraw %}
More information and examples can be found in the [template documentation][Template].
### Breaking changes

View File

@ -77,15 +77,17 @@ automation:
Or warn you if you leave your keys behind
{% raw %}
```yaml
automation:
- alias: 'Forgotten keys'
trigger:
platform: template
value_template: '{% raw %}{{ states.device_tracker.greg_gregphone.state != states.device_tracker.beacon_keys.state}}{% endraw %}'
value_template: '{{ states.device_tracker.greg_gregphone.state != states.device_tracker.beacon_keys.state}}'
condition:
condition: template
value_template: '{% raw %}{{ states.device_tracker.greg_gregphone.state != "home" }}{% endraw %}'
value_template: '{{ states.device_tracker.greg_gregphone.state != "home" }}'
action:
service: script.turn_on
entity_id: script.send_key_alert
@ -93,7 +95,7 @@ automation:
- alias: 'Forgotten keys - cancel'
trigger:
platform: template
value_template: '{% raw %}{{ states.device_tracker.greg_gregphone.state == states.device_tracker.beacon_keys.state }}{% endraw %}'
value_template: '{{ states.device_tracker.greg_gregphone.state == states.device_tracker.beacon_keys.state }}'
condition:
- condition: state
entity_id: script.send_key_alert
@ -103,6 +105,8 @@ automation:
entity_id: script.send_key_alert
```
{% endraw %}
```yaml
script:
send_key_alert:

View File

@ -42,6 +42,8 @@ There was a lot of work done on our implementation which are working with RESTfu
The [REST sensor][rest-sensor] supports now HTTP authentication (basic and digest) and custom headers. This will allow you to access resources which are protected. This sample sensor will access GitHub and retrieve the latest release number while by-passing the rate limit for non-authenticated requests.
{% raw %}
```yaml
sensor
- platform: rest
@ -49,13 +51,15 @@ sensor
username: YOUR_GITHUB_USERNAME
password: YOUR_GITHUB_ACCESS_TOKEN
authentication: basic
value_template: "{% raw %}{{ value_json.tag_name }}{% endraw %}"
value_template: "{{ value_json.tag_name }}"
headers:
Accept: application/vnd.github.v3+json
Content-Type: application/json
User-Agent: Home Assistant REST sensor
```
{% endraw %}
### Misc
- GitHub released with a recent update a review feature. This will give you more control over your comments while you review an open Pull Request.