Skip to content

Commit f8393f0

Browse files
scopfabaff
authored andcommitted
sensor.command_line: Round example CPU temperature value (home-assistant#5032)
* sensor.command_line: Round example CPU temperature value multiply returns a float, which is inexact and sometimes gets rendered with a lot of decimal places. Round additionally to get cleaner result. * Move raw
1 parent 338eeb2 commit f8393f0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

source/_components/sensor.command_line.markdown

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ sensor:
6161
6262
Thanks to the [`proc`](https://en.wikipedia.org/wiki/Procfs) file system, various details about a system can be retrieved. Here the CPU temperature is of interest. Add something similar to your `configuration.yaml` file:
6363

64+
{% raw %}
6465
```yaml
6566
# Example configuration.yaml entry
6667
sensor:
@@ -69,8 +70,9 @@ sensor:
6970
command: "cat /sys/class/thermal/thermal_zone0/temp"
7071
# If errors occur, remove degree symbol below
7172
unit_of_measurement: "°C"
72-
value_template: '{% raw %}{{ value | multiply(0.001) }}{% endraw %}'
73+
value_template: '{{ value | multiply(0.001) | round(1) }}'
7374
```
75+
{% endraw %}
7476

7577
### {% linkable_title Monitoring failed login attempts on Home Assistant %}
7678

@@ -149,11 +151,13 @@ sensor:
149151

150152
[Templates](/docs/configuration/templating/) are supported in the `command:` configuration variable. This could be used if you want to include the state of a specific sensor as an argument to your external script.
151153

154+
{% raw %}
152155
```yaml
153156
# Example configuration.yaml entry
154157
sensor:
155158
- platform: command_line
156159
name: wind direction
157-
command: 'sh /home/pi/.homeassistant/scripts/wind_direction.sh {% raw %}{{ states.sensor.wind_direction.state }}{% endraw %}'
160+
command: 'sh /home/pi/.homeassistant/scripts/wind_direction.sh {{ states.sensor.wind_direction.state }}'
158161
unit_of_measurement: "Direction"
159162
```
163+
{% endraw %}

0 commit comments

Comments
 (0)