Merge pull request #4112 from home-assistant/mystrom-switch-template

Add template example
This commit is contained in:
DubhAd 2017-12-01 11:39:20 +00:00 committed by GitHub
commit 7a18d87f61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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 %}