From 5e265d324c5cf4e0aef9a47311ff312523d3949c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 7 Apr 2016 22:41:09 +0200 Subject: [PATCH] Add example for converting units --- source/_components/sensor.template.markdown | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/_components/sensor.template.markdown b/source/_components/sensor.template.markdown index a792cb1cdae..27f78dead23 100644 --- a/source/_components/sensor.template.markdown +++ b/source/_components/sensor.template.markdown @@ -53,7 +53,7 @@ sensor: unit_of_measurement: '°' ``` -### {% linkable_title Multi line example with an if test %} +### {% linkable_title Multi line example with an if test %} This example shows a multiple line template with and is test. It looks at a sensing switch and shows on/off in the frontend. @@ -77,4 +77,20 @@ sensor: ``` (please note the blank line to close the multi-line template) +### {% linkable_title Change the unit of measurment %} +With a template sensor it's easy to convert given values into others if the unit of measurement don't fit your needs. + +```yaml +sensor: + platform: template + sensors: + transmission_down_speed_kbps: + value_template: {% raw %}'{{ states.sensor.transmission_down_speed.state | multiply(1024) }}'{% endraw %} + friendly_name: 'Transmission Down Speed' + unit_of_measurement: 'kB/s' + transmission_up_speed_kbps: + value_template: {% raw %}'{{ states.sensor.transmission_up_speed.state | multiply(1024) }}'{% endraw %} + friendly_name: 'Transmission Up Speed' + unit_of_measurement: 'kB/s' +```