Sensor for read CPU freq

I have an installation of Home Assistant on a Raspberry pi 4, Supervised, the old HASSIO.
I’m running Hassio 2021.1.0, Supervisor 2020.12.7, Home assistant OS 5.9.
Since i have overclocked my RB4, i would like create a sensor to read the CPU frequence and create a graph on lovelace.
First attempt was the integration:

sensor:
  - platform: cpuspeed

but only Home Assistant Core is supported.
Then i try with this command:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
If i launch the command via terminal (internal of HASSIO or with putty) i read the cpu freq correctly so i put the command in a sensor like this:

- platform: command_line
  name: CPUfreq
  command: "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
  unit_of_measurement: "MHz"
  value_template: "{{ value | multiply(0.001) }}"
  scan_interval: 5

But the reads are uncorrect: they are always stuck at the top frequenzy (2000 Mhz in my case) and it is not true. If i launch simultaneously by terminal and by the sensor the same command
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
the first measure 6/700 Mhz (the correct value) and the sensor always 2000 Mhz.
Is there a way to read the correct cpu frequency with an Hassio installation and put it in a graph?

Check Out Glances https://github.com/hassio-addons/addon-glances

You can upload the all the system data to Influxdb https://github.com/hassio-addons/addon-influxdb and make a graph with Grafana https://github.com/hassio-addons/addon-grafana

Good idea, i gave it a try but unfortunatly i don’t see, among the stats, nothing about the cpu freq.
About the CPU there are always the % stats

If you are running node red please try this node https://flows.nodered.org/node/node-red-contrib-cpu

Never thought to node-red!
Well, looking for the palette you suggested i found also another.
Given a try first at yours but the values were always stuck at 2000 Mhz, then i tried the second:
https://flows.nodered.org/node/node-red-contrib-os
The value are a bit strange: no more fixed at 2000 but never lower of 1500.
I always used the command via terminal to have a comparaison and i am pretty sure the values of both of the node are wrong.


A screen of the “your” node

A screen of the other one

Have to set the arm_freq_min in the boot menu? If it is set to 1500, the freq wont go down below that. For me the node that I shared works fine and its strange its not working for you.

Where is the boot menu?

Sorry its the boot configuration and not menu. Boot configuration is located in /boot/config.txt. We edit it for overclocking.

Ok.
No, no arm_freq_min in config.txt.
As you can see in the screen before, looking at the terminals, the cpu goes idle frequently at 600/700 Mhz.
But i’m not able to have these readings within HASSIO.
It’s strange that with that node in node-red you achieve right readings and in my case surly not. When i really go to 2000 Mhz, because a reboot, a system update or something similar, the temperature rise immediately around and over i 65° C, while during the normal operations it is at 46/48° C.

Well 65° C is ok even if you are using no active cooling methods even when its not optimal. The thermal throttling occurs after 80° C only. Since you have overclocked the RPI 4, I suggest you keep a arm_freg_min as the drop between the idle frequency and the maximum is very large. In my case I have active cooling and the max temp that i see is around 52° C when tested with stresspi.

The temperature is not a problem, i know even if now, in winter, my office is quite cold and in summer i think the temperature will rises to more critical level. Anyway, for this problem i have a stupid project of water cooling the rsp :joy:
About your tip of writing in config.txt an arm_freq_min: what should be the problems of a large gap between min and max freq?

Have read the issue with a large gap somewhere. Don’t remember now. It was just a tip nothing more.

Hi I know it was over a year ago but I’m looking for a solution without nodeRed.
Is there any solution for this to get the real arm frequency?
vcgencmd doesn’t seem to work with Hass OS.

sudo cat sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

Note, divide by 1000 for MHz
Change cpu0 to 1, 2, or 3 for other cores
If you look in /sys/devices/system/cpu/cpu0 there is quite a bit of info available, hope this is what you are looking for, TLDR above.