This is what I have in configuration.yaml
Sensor:
- platform: systemmonitor
resources:
- type: memory_use
- type: memory_use_percent
- type: memory_free
- type: load_1m
- type: load_5m
- type: load_15m
- type: last_boot
- platform: template
sensors:
cpu_usage:
friendly_name: "CPU Usage"
unit_of_measurement: '%'
value_template: "{{ states('sensor.load_1m') * 100 }}"
In lovelace, I have this card with the following codes:
entity: sensor.cpu_usage
name: CPU Usage
type: sensor
unit: '%'
It is giving me an “Unknown” value. Choosing the load_1m on its own without going thru the template I am getting the correct value, just not in the percentage value that I wanted.
Any ideas what I am doing wrong here?
Thanks much
Try it with
value_template: "{{ states('sensor.load_1m') | int * 100 }}"
The sensor returns the number as string.
I don’t think you want to multiply these values by 100 to get a percentage, its just not how they work. They can definitely go over a value of 1. See below for some basic info on what the values are reporting.
https://www.tecmint.com/understand-linux-load-averages-and-monitor-performance/
I think the value you are looking for is processor_use:
2 Likes
Aaaahhhh that’s why it shows an error there. Thanks for the tip. The value now return a value.
Thanks for that too. I looked up the link you indicated and yes it is not the right way to multiply this to get a percentage given the value may exceed 1.
I have now used the sensor processor_use as suggested. Works great for now.
Thanks again!
Does anybody else have some strange peaks in their Processor Usage Graph?
![grafik](//community-assets.home-assistant.io/original/3X/4/7/474992ce93fb40981b51a9310f8bc512bb8a68ee.png)
But it seems to me it’s not the real value, because for the same minute there is another value which fits the average:
![grafik](//community-assets.home-assistant.io/original/3X/4/2/42fea232cc9322ab5080bb85360ca14a47ad9807.png)
The check interval is one minute if not set to a different check interval I guess?
PS: I also have this behaviour in a custom_component and have addressed it there. But this is a direct integration, so maybe it has the same cause.