Exec:command in items not working

  • Platform information:
    • Hardware: Raspberry 4
    • openHAB 2:

Sitemap:
Text item=systemTempPi icon=“temperature”

Items:
String systemTempPi “System Temperatur [%.1f °C]” (ALL) { channel=“exec:command:cpu_temp:output”}

Things:
Thing exec:command:cpu_temp [command="/etc/openhab2/scripts/cpu_temp.sh", transform=“REGEX((.*?))”]

Script at Commandline:
pi@raspberrypi:/etc/openhab2/scripts $ ls -l cpu_temp.sh
-rwxr-xr-x 1 openhab openhab 151 Feb 4 22:57 cpu_temp.sh

pi@raspberrypi:/etc/openhab2/scripts $ sudo -u openhab /etc/openhab2/scripts/cpu_temp.sh
52582 / 1000

The Problem:
In my basicUI is novalue. whats wrong?
I unbinded the exec-binding and bind it again. restart openhab. nothing everytime the same

Logs:
2020-02-06 00:16:19.244 [hingStatusInfoChangedEvent] - ‘exec:command:oh2service’ changed from UNINITIALIZED to INITIALIZING
2020-02-06 00:16:19.285 [hingStatusInfoChangedEvent] - ‘exec:command:oh2service’ changed from INITIALIZING to ONLINE
2020-02-06 00:16:19.306 [hingStatusInfoChangedEvent] - ‘exec:command:piservice’ changed from UNINITIALIZED to INITIALIZING
2020-02-06 00:16:19.325 [hingStatusInfoChangedEvent] - ‘exec:command:piservice’ changed from INITIALIZING to ONLINE
2020-02-06 00:16:19.337 [hingStatusInfoChangedEvent] - ‘exec:command:cpu_temp’ changed from UNINITIALIZED to INITIALIZING
2020-02-06 00:16:19.373 [hingStatusInfoChangedEvent] - ‘exec:command:cpu_temp’ changed from INITIALIZING to ONLINE
2020-02-06 00:16:19.425 [hingStatusInfoChangedEvent] - ‘exec:command:CommandWiFiCheck_ExitValue’ changed from UNINITIALIZED to INITIALIZING
2020-02-06 00:16:19.429 [hingStatusInfoChangedEvent] - ‘exec:command:CommandWiFiCheck_ExitValue’ changed from INITIALIZING to ONLINE
2020-02-06 00:18:27.388 [me.event.InboxRemovedEvent] - Discovery Result with UID ‘airquality:aqi:local’ has been removed.
2020-02-06 00:34:18.664 [me.event.ThingUpdatedEvent] - Thing ‘exec:command:cpu_temp’ has been updated.

Welcome to the openHAB Forum :wave::wave::wave:

Can’t say much about the EXEC problem (I do not use it), but why aren’t you using the systeminfo binding for such information. This binding allows to monitor several data points using selectable time steps.

1 Like

You might find some tips in this recent exec thread

As you make use of REGEX in your thing: is RegEx Transformation Service installed ?

Thx for your answers but the problem is still there.

RegEx Transformation is installed.

some other ideas?

How about using the systeminfo binding, which has a channel for CPU temperature?

systeminfo binding is working. but i have some scripts (sh) and python-scripts and i want to bind them with the exec-binding. but not working

Not enough information to say further.
The thread I pointed you to shows how to gather more information.
You have to do that work.

As far as I understand the output of your shell script is an instruction for a calculation ( 52582 / 1000 ).
My suggestion would be to:

  • remove the transform part of the thing definition and
  • do the calculation ( 52582 / 1000 ) inside of the script
    Doing this the result just needs to be displayed.

Thx for helping…

Problem was the missing timeout, Intervall and Autorun after the command in the thing. And i removed the transform and make it in the script.

Everything is good now :slight_smile:

1 Like