Hello,
I try to read the system temperature of my Raspberry via the systeminfo binding.
I was able to install the binding itself, I also installed the GPIO binding and defined the following item:
Number RaspberryCPUTemp "Temperatur RPi2 [%.1f °C]" { channel="systeminfo:computer:rpi2_openhab:sensors#cpuTemp" }
But the field stays empty on my sitemap.
When I try the change the interval of the channel, I get the following log message:
Is this information is not available on a raspberry - or do I face a permission problem - or what’s wrong?
Currently, I use a script being executed to get the system temperature, but I’d prefer to use the systeminfo binding in order to reduce unnecessary scripts etc.
[Update]: Seems to be a rights problem:
-r--r--r-- 1 root root 0 Okt 4 20:51 stat
The quesiton is: How can I grant the user openhab to read this file?
@ThomDietrich, in the meantime I switched to openHABian (btw. it’s great!), but the problem here is exactly the same:
I cannot read the CPU temperature via sysinfo binding; the temperature stays 0 - and in the logfile I get the follwing hint (even with DEBUG loglevel, I only get this):
13:14:28.705 [ERROR] [platform.linux.LinuxCentralProcessor] - Unable to parse /proc/77/stat
All other values (e.g. available memory etc.) work flawless.
Have you ever managed to get the CPU temperature via sysinfo? I have a different way as workaround, but executing scripts is not as neat as to read it directly from a binding
Thank you!
I don’t think temperature is obtainable through the systeminfo binding for the RPi*. (If that’s correct it might be something worth sending an issue for)
An item that correctly obtains the system temperature in degrees Celsius using exec binding and javascript transformation:
Number RPi_Temp "System Temperature [%.1f °C]" {exec="<[cat /sys/class/thermal/thermal_zone0/temp:60000:JS(milli.js)]"}
Where millli.js in your transform folder contains the following to scale:
Hmmm…when it’s that simple to get the temperature (simple cat), then I don’t understand why it isn’t supported by the sysinfo binding. I’ll wait a while - and if nobody tells me that it’s definetely not possible for a RPi at all, I’ll go for an issue and let’s see, what the developers say about it.
On my RPI I also get the Couldn’t find physical processor count. Assuming 1 error, but I don’t get the second error. (But I also have no values on CPU temp or voltage)
@Benjy
I tried to use your approach using OH2 but there is something wrong with the transformation.
I am receiving:
2017-04-26 07:57:11.090 [ERROR] [ab.binding.exec.internal.ExecBinding] - transformation throws exception [transformation=JS(milli.js), response=54230]
org.openhab.core.transform.TransformationException: An error occured while loading script.
at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:63)[189:org.openhab.core.compat1x:2.0.0]
at org.openhab.binding.exec.internal.ExecBinding.transformResponse(ExecBinding.java:159)[185:org.openhab.binding.exec:1.9.0]
at org.openhab.binding.exec.internal.ExecBinding.execute(ExecBinding.java:128)[185:org.openhab.binding.exec:1.9.0]
at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:157)[189:org.openhab.core.compat1x:2.0.0]
at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:173)[189:org.openhab.core.compat1x:2.0.0]
Thanks for asking.
Meanwhile I could resolve the problem.
I created the milli.js file by copying your previous post.
In this post there was one “l” too much therefore OH did not find the file.
Error message did not help to spot the bug immediately.
Anyway problem solved and thanks for your solution.
Number Temp_RPI "RPi Temp [%.1f °C]" { channel="exec:command:temp_rpi:output" }
The LOG:
2018-03-22 12:34:05.972 [ERROR] [hab.binding.exec.handler.ExecHandler]
An exception occurred while transforming '48312' with
'JS((function(i) {return i / 1000;})(input))' :
'An error occurred while loading script.'
I’ve not found reference for transform JS with exec2
Thank you!
rule "temp Celsius"
when
Item Raspi received update
then
var String temp = Raspi.state.toString
var String temp2 = (temp.substring(0,2)) + "." + (temp.substring(2,3))
Raspi_CPU.postUpdate( temp2)
end