[SOLVED] CPU Temperature

Tags: #<Tag:0x00007fc8fb84ce18> #<Tag:0x00007fc8fb84cb20> #<Tag:0x00007fc8fb84c9e0>

Hi, i tried to read the cpu temperature of my Raspberry Pi 3 with raspbian and Openhab 2. I used exec binding, systeminfo binding, i read a lot of issues about this into the community and guide, i tried everything but i can’t read the cpu temperature with openhab because with the cmd i have no problems. For example systeminfo binding print always 0.0°C and i didn’t find any solutions. Exec binding doesn’t print anything. Is there a solution?


1 Like

SysInfo doesn’t work:

Exec should work:

You could also try SNMP:

Start here for debugging Exec binding problems:

It has been ages since I’ve done anything like this but I believe you need to install something in order for the Pi to return all this info.

1 Like

Yes, solved!
I created a thing into the file name cpu_temp.things with the code:

Thing exec:command:apc [command="cat /sys/class/thermal/thermal_zone0/temp", interval=15, timeout=5, autorun=false]

Then i created two items, one linked to the thing (only the second is called into the sitemap file):

String Raspi (All) {channel="exec:command:apc:output"}

Number Raspi_CPU "Temperature CPU [%.1f °C]" <temperature>

finally i created a rules to get the temperature in decimal:

rule "CPU Temp"
        Item Raspi received update
        var String cpupdate = Raspi.state.toString.trim
        var Number cpuTemp = new DecimalType(cpupdate)
        sendCommand(Raspi_CPU, cpuTemp/1000)

and here we are, all is working!



I try this, but I get only - °C and no actual value. Is ther some rights are neccesary?

(I use OH 2.3; exec;RegEx are installed)


Try typing:
cat /sys/class/thermal/thermal_zone0/temp in the command line, what do you get?

I’ve got 44008

I think the Exec will not executed?!

My exec.things

Thing exec:command:apc [command="cat /sys/class/thermal/thermal_zone0/temp", interval=15, timeout=5, autorun=false]

My exec.items

String Raspi (All) {channel="exec:command:apc:output"}
Number Raspi_CPU "Temperature CPU [%.1f °C]" <temperature> (gAu)



1 Like

Is a parametre neccasary to run the exec??? It doesent work!!!

:thinking:In order to get the CPU temperature I use the systeminfo binding.

I will use the exec to read some other values in vers. 1.x it was runnning but with the version 2.3 unfortune not:-(

Thats interesting. I use systeminfo binding too, but CPU temp does not seems to work, unless I`m trying to use incorrect syntax.

Number Sysinfo_Pi_Sensors_CpuTemp  (server) { channel="systeminfo:computer:openHABianPi:sensors#cpuTemp" }

Did you check on PaperUI Things? After selecting " Show More" the list of channels for your Pi should show under “Sensor” the “CPU Temperature” with the correct channel syntax. You could also link your item from there!

I was able to find CPU Temp, not sure how I missed that before. Thanks Jurgen.