(Link to the original blog post with a proper layout)
It’s a pity that #Proxmox doesn’t report CPU and other temperatures to #homeassistant.
I had several freezes of my old laptop that runs Proxmox due to a stuck CPU fan. I googled a bit and found an elegant solution for temperature reporting: a command_line sensor.
Nevertheless, it took several hours to configure it correctly (I forgot how to deal with ssh keys and similar).
This is the end result:
The procedure:
- I installed the ‘Terminal & SSH’ add-on in to home assistant.
- I created SSH keys, put them into /config/.ssh folder, and copied to my proxmox server. Read these instructions. I’ve put something like this in my HA Terminal addon:
$ mkdir /config/.ssh
$ ssh-keygen # generated ssh keys and when asked, i enter the folder /root/config/.ssh
$ ssh-copy-id -i /root/config/.ssh/id_proxmox root@MY_PROXMOX_IP # copy keys to my prox server
$ ssh root@MY_PROXMOX_IP #try out if I can log on without password prompt, then exit
3. I had to find out where my proxmox stores temperatures. I ssh’ed to my proxmox again, browsed folders and looked into files which one store temps. My AMD laptop stores it in /sys/class/thermal/thermal_zone0/temp.
It could be also …/thermal_zone1, 2, 3 or similar.
4. Then I pulled temperature data via SSH to HA terminal:
$ ssh -i /config/.ssh/id_prox -o StrictHostKeyChecking=no -q root@YOUR_PROXMOX_IP cat /sys/class/thermal/thermal_zone0/temp
The command returned 52000.
Edited my configuration.yaml and added the sensor. This is a working #YAML code (as of Apr. 2024). I used tips from here (deprecated sensor) and here.
##################
# Temperature proxmox
##################
command_line:
– sensor:
name: temperature_cpu
command: “ssh -i /config/.ssh/id_prox -o StrictHostKeyChecking=no -q root@YOUR_PROXMOX_IP cat /sys/class/thermal/thermal_zone0/temp”
value_template: “{{ value | multiply(0.001) | round(1) }}”
unit_of_measurement: “°C”
After 20 restarts of Home Assistant, it finally shows the proxmox CPU temp.
Bonus: here is a picture my homelab proxmox ‘server’ with external fans (because CPU fan is not working).
Bonus #2: A hypothesis: Fediverse is causing global warming! 😉 😉
When I publish a blog post, the WordPress Activitypub plugin delivers the post to the #fediverse. This causes the CPU to heat to 75C+. I know it now, because I can track its temp. in HA.
The hypothesis is confirmed.
Leave a Reply