Add template example

This commit is contained in:
Fabian Affolter 2017-12-01 09:10:56 +01:00
parent d16d4b6d15
commit a86926a98a
No known key found for this signature in database
GPG Key ID: DDF3D6F44AAB1336

View File

@ -53,3 +53,20 @@ or change its state:
$ curl -G -X GET http://IP_ADDRESS/relay -d 'state=1'
```
### {% linkable_title Get the current power consumption %}
The switch is measuring the current power consumption. To expose this as a sensor use a [`template` sensor](/components/sensor.template/).
{% raw %}
```yaml
# Example configuration.yaml entry
sensor:
- platform: template
sensors:
power:
friendly_name: "Current Power"
unit_of_measurement: "W"
value_template: "{{ states.switch.office.attributes.current_power_w }}"
```
{% endraw %}