edos08
(Edoardo)
June 15, 2017, 4:11pm
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!
1 Like
Dim
(Angelos)
June 15, 2017, 4:15pm
2
SysInfo doesn’t work:
cweitkamp:
Hi, Eduardo, I am sorry, but the binding currently doesn’t return values for CPU temperature of Raspberry Pis. This problem is caused by the underlying library used to read those values. There is already a fix in that library available, but not released. So with the next release of the library this issue can be closed. Read issue 1324 for more info.
Exec should work:
You could also try SNMP:
chris:
Take a look here . This shows how to set up an SNMP server on the PI. You can then use the SNMP binding to monitor the temperatures. I do exactly this with my Synology NAS with the following item settings -: Number NAS_Temperature “NAS CPU Temperature [%.1f]” <network> { snmp="<[192.168.2.1:public:.1.3.6.1.4.1.6574.1.2.0:60000]" } Number NAS_SystemFanFail “NAS System Fan [MAP(NASFanState.map):%s]” <network> { snmp="<[192.168.2.1:public:.1.3.6.1.4.1.6574.1.4.1.0:60000]" } Number NAS_CPU…
rlkoshak
(Rich Koshak)
June 15, 2017, 4:16pm
3
Start here for debugging Exec binding problems:
One of the most common problems I help people with on this forum is dealing with the Exec binding. So I’m writing this post so I can reference it later.
Background
When openHAB is installed in the automated way (i.e. via apt-get) an openhab user is created and the service runs under that user. The openhab user has the following attributes:
no shell so one cannot log in or su to this user
limited rights
not a member of sudoers
has a home directory in /var/lib/openhab (or /var/lib/openhab2)
has…
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
edos08
(Edoardo)
June 15, 2017, 8:54pm
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
JGLNN
(Jens)
November 7, 2018, 11:08pm
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
vzorglub
(Vincent Regaud)
November 8, 2018, 9:03am
6
Try typing:
cat /sys/class/thermal/thermal_zone0/temp
in the command line, what do you get?
JGLNN
(Jens)
November 8, 2018, 6:25pm
7
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)
openhab.log
events.log
1 Like
JGLNN
(Jens)
November 13, 2018, 11:08am
8
Is a parametre neccasary to run the exec??? It doesent work!!!
opus
(Jürgen Baginski)
November 13, 2018, 11:12am
9
In order to get the CPU temperature I use the systeminfo binding.
1 Like
JGLNN
(Jens)
November 13, 2018, 11:18am
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:-(
andy31
(Andy)
December 8, 2018, 10:38pm
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" }
opus
(Jürgen Baginski)
December 9, 2018, 8:10am
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!
andy31
(Andy)
December 9, 2018, 9:41am
13
I was able to find CPU Temp, not sure how I missed that before. Thanks Jurgen.