The easiest thing to do would probably be to use the JS transform rather than the REGEX transform. See @watou’s example here.
That being said, your commands may be having issues with binding because sometimes it doesn’t handle spaces properly. In that case replace your spaces with “@@”. For exmaple:
You also many need to escape some of the special characters above (e.g. ', (, ), etc). Shunting the command off to a script would also be a good solution so openHAB just has to call your script.
I think though by far the simplest solution will be the JS transform.
I would like to ask you to be a bit more precise, because I’ve followed your commands, but I have no value shown on my sitemap. Alltrough, I’m a really beginner, so it could be, that I’ve made a mistake…
For example, where should I put the .js file? I’ve made a new JS file in the transforms folder…
It should work. I have not tested it yet myself. However, the exec commands depend on your RPi so those should still work. You can test these from a regular command line first. Both transformations should work as well.
If you need help, please post your confit in the forums and I will see what I can do.
For your information. The new Systeminfo binding also supports CPU temperature. I have only tested this binding with my Mac and not yet with the RPi. But this could be a more sustainable implementation.
I tested the new systeminfo binding, it displays 0° as well. I think is related to the RPi & maybe access rights? I’m using a RPi 3 with Jessie.
Both Linux commands $ cat /sys/class/thermal/thermal_zone0/temp and $ /opt/vc/bin/vcgencmd measure_temp are working and I also added the openhab user to the video group.
And. Have you tried warching the event log? I am aware that the new basic UI has issues with refreshing. Refreshing the browser might help. Or try the classic UI.
Could you please copy your item and sitemap definitions in the thread?
The first thing I noticed was the missing transformation. As far as I
know, you should Always add one; at least a REGEX that matches the
complete contents.
Please try
Number System_Temperature_CPU "Temperature CPU [%.1f C]" <temperature> (System_Temperature_Chart) { exec="<[cat /sys/class/thermal/thermal_zone0/temp:10000:REGEX((.*?))]"
I got it working. I switched on debug log for the exec binding and noticed it does not log anything. I uninstalled the binding, restarted OH and installed the binding again. Fixed.
Hey, rtvb. I see you got that working. I followed your steps but no success on my rpi temperature displaying. Could you give a clue? I did the exect same thing as you mentioned (using the .js file on tranformation). I also tried the first item config you posted (the one with REGEX). I tried the vcgencmd measure_temp command from Raspian. Don t I have to configure a .thing file? Could you help me?
You don’t need a thing if you use the exec1 binding.
Are you sure the vcgencmd command is working on the command line?
If so, and it is not working in openHAB, it might be a permissions issue.
The openHAB user (depending on your installation, but probably is openhab.
That user should be a member of the video group (as per my wiki item).
Can you confirm this?
Tks for the reply. VCGENCMD command is working on command line - when I type vcgencmd measure_temp I get the following return temp=48.3 C. About the permission, when i type getent group video as you suggested I get the following return video:x:44:openhabian.
$ vcgencmd measure_temp
temp=49.4'C
getent group video
video:x:44:openhabian
My sitemap file looks like this:
Frame {
Text item=CPU_Temp
So far, I`ve tried the following item lines under the CPU_Temp.items file:
Number CPU_Temp "Temperature CPU [%.1f °C]" <temperature> (System_Temperature_Chart) { exec="<[cat /sys/class/thermal/thermal_zone0/temp:10000]" }
String CPU_Temp "Temperature CPU [%.1f °C]" <temperature> (System_Temperature_Chart) { exec="<[cat /sys/class/thermal/thermal_zone0/temp:10000]" }
String CPU_Temp "Temperature CPU [%.1f °C]" <temperature> (System_Temperature_Chart) { exec="<[cat vcgencmd measure_temp" }
Number CPU_Temp "Temperature CPU [%.1f °C]" <temperature> (System_Temperature_Chart) { exec="<[cat vcgencmd measure_temp" }
I`d appreciate if you could give me a hand here. Thanks in advance for your help!
Neither of your item definitions has a transformation included. I don’t think you followed my example. Please try to add a transformation for example.
Number CPU_Temp "Temperature CPU [%.1f °C]" <temperature> (System_Temperature_Chart) { exec="<[cat /sys/class/thermal/thermal_zone0/temp:10000:REGEX((.*?))]" }