I am trying to display the temperature of the CPU. I found discussions on this topic. One suggests adding this code to configuration.yaml:
sensor:
- platform: command_line
name: CPU Temperature
command: 'cat /sys/class/thermal/thermal_zone0/temp'
unit_of_measurement: '°C'
value_template: '{{ value | multiply(0.001) }}'
That solution did not work for me because I already have the line
sensor: !include sensor.yaml
in my configuration.yaml. So I went to my sensor.yaml file and added everything but the sensor: line. I adjusted formatting to suppress complaints:
platform: command_line
name: CPU Temperature
command: 'cat /sys/class/thermal/thermal_zone0/temp'
unit_of_measurement: '°C'
value_template: '{{ value | multiply(0.001) }}'```
That code still does not work, but now the complaint is that there is a duplicated mapping key – platform, I believe. There is a platform: template in the same file. I took it out as an experiment. I reloaded scripts. I am expecting something to show up in Overview, but nothing does. Probably, I do not understand how to use this code. Furthermore, I need the other platform: entry. I hope that someone is willing to help an idiot. And while you are at it, can you explain why some lines in yaml files start with "- " and when lines need to be indented and by how much? Thanks.
When I put that code in my sensor.yaml, I get “end of the stream or a document separator is expected”. I tried removing the "- " in front of platform and I moved every other line two spaces to the left. I then got “duplicated mapping key” with an up arrow seemingly pointing to “platform”. I tried putting a "- " in front of the other “platform” line in my sensor.yaml, adjusting the subsequent lines two spaces to the right, and restoring your code to its original form. I got a green light then, so I clicked Save, went to Developer Tools, clicked Check Configuration, and then clicked Scripts. Nothing new appeared in Overview. I then returned to File Editor. All of the changes I had made to sensor.yaml had vanished. I repeated all the steps. Still nothing appeared, but this time when I returned to File Editor the new code was still there. By the way, the other platform code in sensor.yaml is a template for sun azimuth and elevation. Those values do appear in Overview. Maybe your code is working now but I am looking in the wrong place for the values.
I did not try systemmonitor, but the formatting you suggested worked. The mistake in my original attempt was not adding a "- " in front of the first platform (and two spaces in front of the remaining lines in that entry). I gather that "- " must indicate that there are multiple entries for the same key. I also realized that after clicking the save button in file editor I need to wait until I receive the acknowledgement that the contents were saved. Thanks, everyone.