[SOLVED] CPU Temperature

execbinding
exec
systeminfo
Tags: #<Tag:0x00007f1e66abf0c8> #<Tag:0x00007f1e66abc760> #<Tag:0x00007f1e66acfc98>
(Edoardo) #1

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?

Thanks!

0 Likes

Systeminfo binding, RasPi 3 - no CPU temp, no voltage and some other questions
(Angelos) #2

SysInfo doesn’t work:

Exec should work:

You could also try SNMP:

0 Likes

(Rich Koshak) #3

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

Openhab2 RPI System Temperature and DS18B20 OneWire Chart with persistence
(Edoardo) #4

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"
when
        Item Raspi received update
then
        var String cpupdate = Raspi.state.toString.trim
        var Number cpuTemp = new DecimalType(cpupdate)
        sendCommand(Raspi_CPU, cpuTemp/1000)
end

and here we are, all is working!

5 Likes

(Jens) #5

Hi,

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)

Jens

0 Likes

(Vincent Regaud) #6

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

0 Likes

(Jens) #7

I’ve got 44008


grafik
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)

openhab.log


events.log

0 Likes

(Jens) #8

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

0 Likes

(Jürgen Baginski) #9

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

0 Likes

(Jens) #10

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:-(

0 Likes

(Andy) #11

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" }
0 Likes

(Jürgen Baginski) #12

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!

0 Likes

(Andy) #13

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

0 Likes