mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-16 05:46:52 +00:00
Add simple example for renaming
This commit is contained in:
parent
c3ea06828f
commit
4ba93ae2f1
@ -50,13 +50,26 @@ This example shows the sun angle in the frontend.
|
|||||||
sensor:
|
sensor:
|
||||||
platform: template
|
platform: template
|
||||||
sensors:
|
sensors:
|
||||||
solar_angle:
|
solar_angle:
|
||||||
value_template: {% raw %}'{{ "%+.1f"|format(states.sun.sun.attributes.elevation) }}'{% endraw %}
|
value_template: {% raw %}'{{ "%+.1f"|format(states.sun.sun.attributes.elevation) }}'{% endraw %}
|
||||||
friendly_name: 'Sun Angle'
|
friendly_name: 'Sun Angle'
|
||||||
unit_of_measurement: '°'
|
unit_of_measurement: '°'
|
||||||
```
|
```
|
||||||
|
|
||||||
### {% linkable_title Multi line example with an if test (and warnings disabled)%}
|
### {% linkable_title Renaming sensor output %}
|
||||||
|
|
||||||
|
If you don't like the wording of a sensor output then the template sensor can help too. Processes monitored by the [System Monitor sensor](/components/sensor.systemmonitor/) show `on` or `off` if they are running or not. This example shows how the output of a monitored `glances` process can be renamed.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
sensor:
|
||||||
|
platform: template
|
||||||
|
sensors:
|
||||||
|
glances:
|
||||||
|
value_template: '{% if is_state("sensor.process_glances", "off") %}not running{% else %}running{% endif %}'
|
||||||
|
friendly_name: 'Glances'
|
||||||
|
```
|
||||||
|
|
||||||
|
### {% linkable_title Multiline example with an if test (and warnings disabled) %}
|
||||||
|
|
||||||
This example shows a multiple line template with and if test. It looks at a sensing switch and shows on/off in the frontend. It disables warnings to avoid log messages where the switch it depends on isn't loaded yet.
|
This example shows a multiple line template with and if test. It looks at a sensing switch and shows on/off in the frontend. It disables warnings to avoid log messages where the switch it depends on isn't loaded yet.
|
||||||
|
|
||||||
@ -64,21 +77,22 @@ This example shows a multiple line template with and if test. It looks at a sens
|
|||||||
sensor:
|
sensor:
|
||||||
platform: template
|
platform: template
|
||||||
sensors:
|
sensors:
|
||||||
kettle:
|
kettle:
|
||||||
friendly_name: 'Kettle'
|
friendly_name: 'Kettle'
|
||||||
{% raw %}value_template: >-
|
{% raw %}value_template: >-
|
||||||
{%- if is_state("switch.kettle", "off") %}
|
{%- if is_state("switch.kettle", "off") %}
|
||||||
off
|
off
|
||||||
{% elif states.switch.kettle.attributes.kwh < 1000 %}
|
{% elif states.switch.kettle.attributes.kwh < 1000 %}
|
||||||
standby
|
standby
|
||||||
{% elif is_state("switch.kettle", "on") %}
|
{% elif is_state("switch.kettle", "on") %}
|
||||||
on
|
on
|
||||||
{% else %}
|
{% else %}
|
||||||
failed
|
failed
|
||||||
{%- endif %}{% endraw %}
|
{%- endif %}{% endraw %}
|
||||||
|
|
||||||
warnings: Off
|
warnings: Off
|
||||||
```
|
```
|
||||||
|
|
||||||
(please note the blank line to close the multi-line template)
|
(please note the blank line to close the multi-line template)
|
||||||
|
|
||||||
### {% linkable_title Change the unit of measurment %}
|
### {% linkable_title Change the unit of measurment %}
|
||||||
@ -90,11 +104,12 @@ sensor:
|
|||||||
platform: template
|
platform: template
|
||||||
sensors:
|
sensors:
|
||||||
transmission_down_speed_kbps:
|
transmission_down_speed_kbps:
|
||||||
value_template: {% raw %}'{{ states.sensor.transmission_down_speed.state | multiply(1024) }}'{% endraw %}
|
value_template: {% raw %}'{{ states.sensor.transmission_down_speed.state | multiply(1024) }}'{% endraw %}
|
||||||
friendly_name: 'Transmission Down Speed'
|
friendly_name: 'Transmission Down Speed'
|
||||||
unit_of_measurement: 'kB/s'
|
unit_of_measurement: 'kB/s'
|
||||||
transmission_up_speed_kbps:
|
transmission_up_speed_kbps:
|
||||||
value_template: {% raw %}'{{ states.sensor.transmission_up_speed.state | multiply(1024) }}'{% endraw %}
|
value_template: {% raw %}'{{ states.sensor.transmission_up_speed.state | multiply(1024) }}'{% endraw %}
|
||||||
friendly_name: 'Transmission Up Speed'
|
friendly_name: 'Transmission Up Speed'
|
||||||
unit_of_measurement: 'kB/s'
|
unit_of_measurement: 'kB/s'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user